Obtain iOS UDID using USB and Windows PowerShell

Joe Bologna
2 min readOct 21, 2021

A lot of people have a Windows computer and an iOS device. Developers have a hard time getting feedback from these users because they cannot install apps unless the app is downloaded from the Apple App Store. The developer can distribute the app using Ad Hoc distribution, however, this requires obtaining the UDID of the iOS device. There are lot’s of articles about how to do this, I’ve even written one, see: Obtaining an iOS Device UDID using a USB Cable. However, it would be nice to just run a script to get the info. To this end, I wrote this PowerShell script that can be run on any Windows 10 or newer computer.

# Save as: getudid.ps1
# Find UDID from Apple Device
if ($args.Count -ge 1) {
$appledevice = $args[0]
} else {
$appledevice = "Apple Mobile"
}
$devicedata = (Get-WmiObject -Class Win32_PnpEntity -Namespace "root\CIMV2" -Filter "Name like '$appledevice%'")
if ($devicedata.PNPDeviceID.Length -gt 0) {
$deviceid = $devicedata.PNPDeviceID.Substring(22)
if ($args.Count -eq 2) {
$left = $deviceid.substring(0,8) -replace "[0-9A-F]",$args[1]
} else {
$left = $deviceid.substring(0,8)
}
$right = $deviceid.substring(8)
$udid = "$left-$right"
Write-Output $udid
} else {
Write-Warning "Device Like '$appledevice' Not Found"
}

--

--