I know it sounds odd. But if the execution policy for powershell is set to restricted you can't do an awful lot remotely and most of what I do is remote. To top that off a lot of times the multitude of remote managment tools don't work when you're troubleshooting an issues. So there are a couple ways to set execution policy remotely.
A lot of times I'll just do a psexec to run 'powershell set-executionpolicy unrestricted' but sometimes I've had issues with that erroring out for some reason, where dropping a script to the local machine and kicking it off locally works. I don't know why. So here's the script I drop on the box and then I use psexec to run it.
'---------------------------------------------------------------------------
' PowerShell Unlocker
' AUTH: David Bennett
' WEB : http://sccmbrokeit.blogspot.com/
'
' THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
' KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
' IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
' PURPOSE.
'
' Use : cscript UnlockPowerShell.vbs
' Desc: Just runs "Set-ExecutionPolicy Unrestricted" so that powershell
' scripts will run. Needs to be ran outside of PSH
' The intent of this version is to be dropped on a system and remotely
' executed with PSEXEC
'---------------------------------------------------------------------------
On Error Resume Next
Err.Clear
Dim objShell
set objShell = CreateObject("Wscript.shell")
strPS = "Powershell.exe Set-ExecutionPolicy Unrestricted"
objShell.Run(strPS,0)
No comments:
Post a Comment