1

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

9
  • 5
    I would say the best way to set this on many machines is to use group policy, not a script. Commented Feb 7, 2017 at 20:15
  • 1
    Set-ExecutionPolicy RemoteSigned -Force -Scope MachinePolicy? Commented Feb 7, 2017 at 20:42
  • 1
    Err, yup, Group Policy is the way forward. Also useful for deploying profile scripts... Commented Feb 7, 2017 at 21:01
  • 1
    @Badlarry I would, but it would amount to a link-only answer, or I would include the steps, which is more appropriate for Server Fault, so I'm not quite sure what to do. I would think deleting/closing the question? Having trouble resolving this one haha. Commented Feb 7, 2017 at 22:56
  • 1
    @briantist Meta created: meta.stackoverflow.com/questions/343225/… Commented Feb 7, 2017 at 23:11

1 Answer 1

2

The best way to achieve this is generally to use Group Policy to set execution policy on a number of machines.

From the link:

To configure, navigate under Computer Configuration to Policies\Administrative Templates\Windows Components\Windows PowerShell You should see a setting called Turn on Script Execution

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.