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

This topic contains 4 replies, has 4 voices, and was last updated by  Harish M 1 week, 1 day ago.

  • Author
    Posts
  • #67920

    Del
    Participant

    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'

  • #67921

    Don Jones
    Keymaster

    $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.

    • #67924

      Del
      Participant

      where it's gonna save the html report ?

      Thanks

    • #87100

      Harish M
      Participant

      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.

  • #67941

    Peter Jurgens
    Participant

    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.

You must be logged in to reply to this topic.