gpupdate /force /wait:60 | Out-Null Write-Output '--- dsregcmd device state ---' $d = dsregcmd /status $d | Select-String 'AzureAdJoined|DomainJoined|DeviceId|TenantName|EnterpriseJoined' | ForEach-Object { $_.Line.Trim() } Write-Output '--- SSO state ---' $d | Select-String 'AzureAdPrt\s|OnPremTgt|CloudTgt' | ForEach-Object { $_.Line.Trim() }