Home > Jamf Pro, Scripting, Virtualization > 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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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.