PowerShell AD groupmembers

Simple script using dsquery to query groupmembers from an Active Directory group and return the results to screen. The script takes parameters from the commandline (groupmem.ps1 “DOMAIN” “GROUP_NAME”).

[string]$sADPath = dsquery group -domain "$($args[0])" -name "$($args[1])"
$sADPath = "LDAP://" + $sADPath | Foreach-Object {$_ -replace "`"", ""}
$oADGroup = [ADSI]("$sADPath")
$oADGroup.path
$oADGroup.member