#output file $DragDropCSV = "./DragDropLicenseManager.csv" #Run PowerShell As Administrator Set-ExecutionPolicy Bypass -scope Process -Force Install-Module -Name AzureAD Import-Module -Name AzureAD #Answer YES if prompted to install NuGet #Once modules above are installed you can use the command below to connect to Azure Connect-AzureAD function Convert-ObjectIdToSid { param([String] $ObjectId) $d=[UInt32[]]::new(4);[Buffer]::BlockCopy([Guid]::Parse($ObjectId).ToByteArray(),0,$d,0,16);"S-1-12-1-$d".Replace(' ','-') } #Get and convert active member Azure Users Get-AzureADUser -All $true | where {$_.UserType -eq 'Member' -and $_.AccountEnabled -eq $true} | ForEach { [pscustomobject] @{ Name=$_.UserPrincipalName.Split('@')[0]; Sid=Convert-ObjectIdToSid($_.ObjectId); Email=$_.userPrincipalName} | Export-Csv $DragDropCSV -notype -Append }