Forum Discussion
DarrenRD
Jul 09, 2021Copper Contributor
get-content and foreach loop
Hi I am trying to set permissions to all GPOs names in the file. I got the first PS script working by using -eq to name of a GPO in the file, but i need to set permissions to all GPOs in the file...
farismalaeb
Jul 10, 2021Steel Contributor
Hi
Surely this won't be matching,
You are comparing a single item to an array of items with will never match.
Also, please tell me more about this line
foreach ($gpo in $gpos) {
if ($_ -eq $gpos) {Set-GPPermission ...
You are checking each item from a text file you have and checking if each line (Item=$GPO) of the text is part of the $gpos.
Yes, sure it's all part you get the data from there.
I guess you need to check if each item $gpo name is exist between all other domain GPO.