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  Peter Jurgens 5 months, 2 weeks ago.

  • Author
  • #67920


    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

    $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


      where it's gonna save the html report ?


  • #67941

    Peter Jurgens

    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.