ping.exe -t <hostname> | Foreach{"{0} - {1}" -f (Get-Date),$_}
$env:UserName $env:UserDomain $env:ComputerName
| grep -i <string> | findstr /I <string> | sort | sort-object | wc -l | Measure-Object -line
$(Get-WMIObject -class Win32_ComputerSystem)
([adsisearcher]"(&(objectCategory=computer)(cn=$env:COMPUTERNAME))").FindOne().Properties.memberof -replace '^CN=([^,]+).+$','$1'
$env:UserName
OR
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name
net user /domain <ad-username>
OR
(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=$($env:username)))")).FindOne().GetDirectoryEntry().memberOf
OR
(New-Object System.DirectoryServices.DirectorySearcher("(&(objectCategory=User)(samAccountName=ad.user.name))")).FindOne().GetDirectoryEntry().memberOf
(fullgroupname beeing the full CN with all OU and DC)
net group /domain fullgroupname
or
$Group = [ADSI]"LDAP://CN=<fullgroupname>" $Group.Member | ForEach-Object { $Searcher = [adsisearcher]"(distinguishedname=$_)" ; $Searcher.FindOne().Properties.userprincipalname }