Miritm
asked on
what's preventing me from invoking commands using powershell on my local desktop?
I'm learning how to work with PowerShell fore remote command execution.
I created a simple script - test.ps1 - that contains just "dir", and executes well from command line. However, when I try to execute it using invoke-command, it fails with the following message. Note that for this test I'm trying localhost, but it still fails with a security message.
Command and message text:
PS Desktop> invoke-command -ComputerName localhost -FilePath test.ps1
invoke-command : File C:\Users\mirit.VENOTION\De sktop\test .ps1 cannot be loaded because running scripts is disabled on
this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ invoke-command -ComputerName localhost -FilePath test.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~
+ CategoryInfo : SecurityError: (:) [Invoke-Command], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microso ft.PowerSh ell.Comman ds.InvokeC ommandComm and
I created a simple script - test.ps1 - that contains just "dir", and executes well from command line. However, when I try to execute it using invoke-command, it fails with the following message. Note that for this test I'm trying localhost, but it still fails with a security message.
Command and message text:
PS Desktop> invoke-command -ComputerName localhost -FilePath test.ps1
invoke-command : File C:\Users\mirit.VENOTION\De
this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ invoke-command -ComputerName localhost -FilePath test.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [Invoke-Command], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microso
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dear,
On the PowerShell Run set-executionpolicy unrestricted
then run the script
On the PowerShell Run set-executionpolicy unrestricted
then run the script
V_2Shaha solution is also given in the link I posted - its worth reading the whole thing to help you understand how/why powershell works the way it does
- for example why the 'unrestricted' option is potentially dangerous and how you can allow invoke for your own code but prevent someone else's from doing bad things to your computer
- for example why the 'unrestricted' option is potentially dangerous and how you can allow invoke for your own code but prevent someone else's from doing bad things to your computer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Qlemo - - the OP clearly needs more than just the ability to execute the Invoke commend if he is learning to work with powershell and as the first para of the article describes his specific problem in detail before providing more detail about powershell as a whole I feel the link is relevant.
However I do see that it was a 'lazy' response and I will be more explicit in future and make sure to quote specific commands where appropriate, my apologies
However I do see that it was a 'lazy' response and I will be more explicit in future and make sure to quote specific commands where appropriate, my apologies
Thanks Qlemo...
ASKER