Skip to content

Instantly share code, notes, and snippets.

@jdhitsolutions
Created January 18, 2021 16:47
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save jdhitsolutions/f33ec03729c019efacc738a762d9a725 to your computer and use it in GitHub Desktop.
Save jdhitsolutions/f33ec03729c019efacc738a762d9a725 to your computer and use it in GitHub Desktop.
A PowerShell function to list Group Policy links
@jdhitsolutions
Copy link
Author

jdhitsolutions commented Jan 18, 2021

These files are described at https://jdhitsolutions.com/blog/powershell/8041/get-group-policy-links-with-powershell/.
This script will not work properly in PowerShell 7. It must be run from Windows PowerShell 5.1.

@samredinet
Copy link

samredinet commented May 10, 2023

Is this still maintained? Tried to use this today and the following returned

Method invocation failed because [System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089]]] does not contain a method named 'new'.
At line:280 char:9
+         $targets = [System.Collections.Generic.list[string]]::new()
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

@jdhitsolutions
Copy link
Author

This function still works for me without error in Windows PowerShell 5.1. What version of PowerShell are you using, and on what OS?

@samredinet
Copy link

samredinet commented May 10, 2023 via email

@jdhitsolutions
Copy link
Author

That doesn't help me much. Can you run this line by itself?

$targets = [System.Collections.Generic.list[string]]::new()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment