Link to home
Start Free TrialLog in
Avatar of IT _Admin0723
IT _Admin0723Flag for United States of America

asked on

Retrieving Unlinked/Unused GPOs Powershell

Dear powershell experts,

I have this working but for some reason the output is not exporting to csv. Could someone please help? Thanks a lot.

Get-GPO -all domain mydomain.com | Sort-Object displayname,ID | Where-Object { If ($_ | Get-GPOReport -ReportType XML | Select-String -NotMatch "<LinksTo>" )
{
$_.DisplayName, $_.Id | Export-CSV c:\temp\unlinkedgpos.txt -notypeinformation
}}
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

$report = @()
Get-GPO -All | 
    foreach-object { If ( $_ | Get-GPOReport -ReportType XML | Select-String -NotMatch "<LinksTo>" ) { $report += $_ }
    }
    $report | select-object displayname, id | Export-CSV c:\temp\unlinkedgpos.txt -notypeinformation

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IT _Admin0723

ASKER

Thank you!