Using Wi-Fi hardware network interface information with Jamf Pro to identify macOS virtual machines
2024-6-7 22:43:41 Author: derflounder.wordpress.com(查看原文) 阅读量:8 收藏

Home > Jamf Pro, Scripting, Virtualization > Using Wi-Fi hardware network interface information with Jamf Pro to identify macOS virtual machines

Using Wi-Fi hardware network interface information with Jamf Pro to identify macOS virtual machines

A while back, I had a deployment requirement where I could deploy a specific something to regular Macs but under no circumstances could I deploy it to virtual machines. The reason was that someone could install the thing on a virtual machine, then copy the virtual machine’s files elsewhere.

The issue I was looking at was how to reliably identify a virtual machine. There are various virtualization solutions for macOS available and the macOS virtual machines hosted by them all report various information for model, serial number and other characteristics. However, one thing that macOS virtual machines should have in common regardless of virtualization solution is that they don’t have a hardware Wi-Fi interface. When you’re a VM, it’s an Ethernet world. Meanwhile, every single real Mac for decades has had Wi-Fi hardware installed. Even if it’s never used by the Mac, that Wi-Fi hardware interface should be there.

We can use this with Jamf Pro to help identify macOS virtual machines. For more details, please see below the jump.

Here’s an example Jamf Pro Extension Attribute:


#!/bin/bash
# Check_wifi_installation.sh
# Checks if there is a WiFi hardware network interface. Returns 1 if one or more WiFi
# hardware network interfaces are detected, otherwise returns 0.
WiFiInstalled=$(/usr/sbin/networksetup listallhardwareports | /usr/bin/grep -Ecm1 'Wi-?Fi')
echo "<result>$WiFiInstalled</result>"
exit 0

In this case, we’re using the networksetup tool’s listallhardwareports function and using it to filter for any hardware network interface with Wi-Fi (or similar enough to match) as part of the interface’s returned information. 

With the example EA, if at least one matching result is found, the following output is returned:

1

Otherwise, the following output is returned:

0

You can then use the returned result in a Jamf Pro smart group or advanced computer search to help you identify the macOS virtual machines enrolled with your Jamf Pro server.


文章来源: https://derflounder.wordpress.com/2024/06/07/using-wi-fi-hardware-network-interface-information-with-jamf-pro-to-identify-macos-virtual-machines/
如有侵权请联系:admin#unsafe.sh