I have used the cmdlet / script to prompts for a username and generates a text file listing the groups that the AD user belongs to. The cmdlet of Get-AdPrinciplaGroupMembership produces the list with headers, then by using the select and sort parameters the list is narrowed to Name and sort ascending order.
Is there a way to remove the three lines of text before the actual groups’ names are listed and exrta spaces after each group ?
cmdlets used
$username = Read-host "Enter Username"
Get-ADPrincipleGroupMembership -identity $username |select name |sort name |out-file -literlpath "c:\scirpts\MemberofLookup_${username}.txt" -encoding ascii
#open file in notepad
$report = "c:\scripts\memberoflookup_${username}.txt"
notepad $report
Smaple of the text file
name
----
4620
ADAuditAlerts
Admins.
BI USA Marketing
CrystalReports
By piping the file to |format-table -autosize -hidetabelheader helped a little, the three lines of text before groups still is visable.
Thanks - Pat W