A nice way to Set-ExecutionPolicy without confirmation

rated by 0 users
This post has 2 Replies | 2 Followers

Top 10 Contributor
Posts 258
Top Contributor
Felipe Posted: 10-15-2010 2:44 AM

$shell = New-Object -ComObject Wscript.Shell

Set-ExecutionPolicy Unrestricted | echo $shell.sendkeys("Y`r`n")

That's just an exemple on how this method can be used.

I think it can be very useful in some situations. Big Smile

Top 10 Contributor
Posts 634
Idera Employee

Just use the force switch to suppress prompts:

Set-ExecutionPolicy Unrestricted -force

Top 10 Contributor
Posts 258
Top Contributor

Yes. But yet it is a good method for any cmdlets or any prompt that do not have the -force switch.

Page 1 of 1 (3 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.