Azure AD User Principal Name (UPN) and sAMAccountName. Let’s go. To find this data we found 2 working queries towards SCCM: ... What is the correct query to have one machine name connected to one primary user with SamAccountName and FullUserName? These collections demonstrate different queries you can use to create all the collection you need. Someone made some great PowerShell scripts, but I couldn't always get them to work and/or it was fairly slow. Get-ADComputer -Filter … If you want to join in, open PowerShell (powershell.exe) or PowerShell ISE (ise.exe). There are a few choices, including UniqueUserName which follows the syntax DOMAIN\Pre-W2K name (eg. Excellent tip that saved me a massive amount of time. In the Monitoring workspace, select Queries. I had to do something similar but ended up writing a custom SCCM Report that took a plain text variable which I then queried from powershell to create an object that was returned for a simple menu to select which would then launch the remote control tool for that computer ID. This guide is a hands-on step by step showing how to write a Powershell script to Get AD Group Members. So, the standard configuration of the Azure AD UPN looks like this: username@ "" and returns the samaccountname. This article helped me get the job done. Thank you for your help. Or you can point it to another text file or the screen - just suit yourself.$servers = Get-Content C:\temp\nopatch.txt[array]$serversNew = $servers | Foreach-Object{ '"' + $_ + '",' } [string]$string = "select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where name in ("$code = invoke-command -ScriptBlock {Write-output $string $($serversnew | fl) ")" }$code2 = $code | out-string$code2 | Add-Content C:\temp\nopatch.txt Invoke-Item C:\temp\nopatch.txt.