1

If I run this command:

$LinkedGPOs = Get-ADOrganizationalUnit -Filter 'Name -like "*MyOU*"' | select -ExpandProperty LinkedGroupPolicyObjects 

I get back a list of linked GPO's. I need to run it with the filter looking for a variable, like this:

$LinkedGPOs = Get-ADOrganizationalUnit -Filter 'Name -like "*$_.OrganizationalUnit*"' | select -ExpandProperty LinkedGroupPolicyObjects 

I think it should be simple, but I've had no luck guessing around.

Thanks for the assist.

  • My rule of thumb is double quote outer, single quote inner for the AD cmdlet filters. mklement0 has an excellent answer with a full explanation if I can find it. – BenH Jun 20 '18 at 19:42
  • It isn't strictly a duplicate, but checking the question BenH referred to provided me with what I needed to deduce the answer. – B. Ferguson Jun 20 '18 at 19:54
  • @B.Ferguson: Your real problem was a misconception about PowerShell's string-expansion (string-interpolation) rules - see https://stackoverflow.com/a/40445998/45375 – mklement0 Jun 20 '18 at 20:36

0 Answers0