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

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Peter Jurgens Peter Jurgens 2 months, 3 weeks ago.

  • Author
    Posts
  • #67920
    Profile photo of Del
    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
    Profile photo of Don Jones
    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
      Profile photo of Del
      Del
      Participant

      where it's gonna save the html report ?

      Thanks

  • #67941
    Profile photo of Peter Jurgens
    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.