How to get a list of all GPOs linked to an ADComputer

Quick question

I’m trying to get all gpos that a Computer member of

I am trying

$Computers = (Get-ADComputer -Filter * | Select -Expand Name)
Get-GPResultantSetOfPolicy -Computer $Computers -ReportType HTML -path"Filepath"

But gives me error: Can’t convert “System Object[]” to the type ‘System.String’

$computers contains more than one name; -Computer only accepts one name. You’ll need to use a ForEach loop.

Get-ADComputer -Filter * | 
Select -Expand Name |
ForEach { 
 Get-GPResultantSetOfPolicy -Computer $_ -ReportType HTML -path "$($_).html"
}

That’ll generate an HTML apiece, if I mangled the syntax correctly.

where it’s gonna save the html report ?

Thanks

The -path parameter specifies the output path and in Don’s example he’s just using the current pipeline value which should be just the computer name so it will output a single html file named for each computer name in the current working location for your console session.

Get-ChildItem .\*.html | foreach {Invoke-Item $_.fullname}

That will open all html files in the current directory from your console.

I see the below error on some of the servers.

“Get-GPResultantSetOfPolicy : The Resultant Set of Policy (RSoP) report cannot be generated for user domain\Harish on the MYPC99 computer because there is no RSoP logging data for that user on that computer. This could be because the user has never logged onto that computer.”

I haven’t logged in to the error servers even once. its only giving me the results from the servers which I have logged in at least one time before.