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"

This script must be run manually because Windows does not allow running unsigned scripts by clicking on them. To run it use the command prompt (cmd.exe). Assuming you have used notepad or something to copy/paste/save this script to getudid.ps1, you can execute it using PowerShell. I supplied "X" to mask the output so I can post it here. Otherwise you'd have my UDID, which you should keep as secret as possible. Hopefully, you trust the developer you are working with.

C:> powershell .\getudid.ps1 "Apple Mobile" "X"

You can copy it to the clipboard to mask it and paste it in to a message for your developer:

C:> powershell .\getudid.ps1 | clip

Note, normally your device will have a name like “Apple Mobile”, if not, you’ll need to find it. You can use this PowerShell command to get a full list before and after plugging your iOS device into your computer:

C:> powershell PS C:> (Get-WmiObject -Class Win32_PnpEntity -Namespace "root\CIMV2").Description

You’ll get a long list, hopefully your Apple device will be one of them.

Originally published at https://focusedforsuccess.com on October 21, 2021.