I am trying to set the execution policy for more than 150 users.... I wrote a script, it runs with out error, but I confirmed with the user that the change wasn't made...
$worstationobject = New-Object psobject Hostname
Add-Member -InputObject $worstationobject -MemberType NoteProperty -Name 'CORP\mkatherine' -Value 'FooBar23'
Add-Member -InputObject $worstationobject -MemberType NoteProperty -Name 'CORP\jshmoe' -Value 'FooBar12'
function Get-MemberValues {
$wslist = $worstationobject.psobject.Members |
? {$_.Membertype -eq "noteproperty"} |
%{ $_.Value }
$wslist -join ","
}
function Set-ThePolicies {
$devices = Get-MemberValues
Invoke-Command -InputObject $devices -ScriptBlock {Set-ExecutionPolicy RemoteSigned -Force}
}
Any idea why this isn't working?
If there is a more practical way to do this please let me know if this is over-complicating a simple situation