Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

For-Each Get-ADPrincipalGroupMembership - Get Computer Name to Export-CSV

$
0
0

How would i to get the AD security group name and the computer name for each on my spreadsheet. 

Right now I am only getting the group. Need the Computer Name. 

$Get2008s = "TEXTFILEPATHHERE"

 Get-Content $Get2008s | ForEach-Object { 

    Get-ADPrincipalGroupMembership (Get-ADComputer $_) | select name | Where-Object {$_.name -like '*SCCM*' } | Sort Name

    } | 
Export-Csv "FILEPATHHERE" -NoTypeInformation -UseCulture


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images