When I run the command Get-LocalGroupMember administrators | where {$_.Name -notlike "*string*"} | Remove-LocalGroupMember administrators natively in PS it works fine.
When I runwaithidden powershell.exe -ExecutionPolicy Bypass -command "Get-LocalGroupMember administrators | where {{$_.Name -notlike "*admins*"} | Remove-LocalGroupMember administrators", it runs but doesn’t actually perform the intended task.
Could be a few things…the simplest is that sometimes PowerShell behaves differently when run in 32-bit mode (the default), so try adding
action uses wow64 redirection false
anywhere in the actionscript before running the ‘waithidden’ command.
There can also be some differences in how quoting works. If you’re up for it, I’d try using the native PowerShell script type (if you’re on BigFix 10.0.3 or higher), or download and try our preview “Script Task Builder” dashboard described at New BigFix Labs Dashboards
The Dashboard generates a PowerShell script and executes it on-the-fly, and can save the output to a text file so at least if there’s an error message you can get some indication of what’s happening.
This may be a forum artefact, but the -notlike needs wildcard(s) and also the quotes look iffy to me - the interpreter will match them in the order it finds them, not from the outside in
try replacing the double quotes around adminis and include the wildcards
To avoid much of the forum artefacts, use the button that looks like </> to format script contents (although it still likes to convert double quotes to (supposed) smart-quotes