Failure add 'Add-PSSnapin Pscx'

Topics: User Forum
Jan 16, 2007 at 9:48 PM
I'm also new to powershell, I'm sure this is something stupid and easy... but I'm getting the following issue that seems to be related to the script signing:
-------------------------------------------------------------------------------------------------------
PS C:\Documents and Settings\alenards> Add-PSSnapin Pscx
Add-PSSnapin : Windows PowerShell snap-in "Pscx" is loaded with the following warnings: Error loading the extended type data file:
Pscx, C:\Program Files\PowerShell Community Extensions\Pscx.Types.ps1xml : File skipped because of validation exception: "File C:\Program Files\PowerShell Community Extensions\Pscx.Types.ps1xml cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.".
There were errors in loading the format data file:
Pscx, C:\Program Files\PowerShell Community Extensions\Pscx.Format.ps1xml : File skipped because of validation exception: "File C:\Program Files\PowerShell Community Extensions\Pscx.Format.ps1xml cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.".
At line:1 char:13
+ Add-PSSnapin <<<< Pscx

-------------------------------------------------------------------------------------------------------
blindly running the command a second time gets the following:
-------------------------------------------------------------------------------------------------------
PS C:\Documents and Settings\alenards> Add-PSSnapin Pscx
Add-PSSnapin : Cannot add Windows PowerShell snap-in Pscx because it is already added. Verify the name of the snap-in and try again.
At line:1 char:13
+ Add-PSSnapin <<<< Pscx
Jan 16, 2007 at 11:07 PM
I figured it out - I had the script execution policy set to the default of "Restricted" and changing it to RemoteSigned allowed the snap-in to be added without error.

Thanks for the extensions...

Coordinator
Jan 17, 2007 at 6:00 AM
That's the ticket. Opening up the execution policy to RemoteSigned is a pretty good way to go.
Jun 5, 2007 at 12:27 AM
I had the sme problem and found this solution on a search (so as not to bug you guys by asking all over again). But it seems that setting the execution policy to RemoteSigned versus AllSigned opens up some security concerns. What is the thinking on that?
Coordinator
Jun 5, 2007 at 6:38 AM
Edited Jun 5, 2007 at 6:39 AM
Well having to sign the scripts you write yourself is a royal PITA especially when the point of a tool like PowerShell is to provide a productive way to bang out one-off solutions. However getting a script from the internet and executing it (or having one from the internet somehow surreptiously execute) could certainly cause problems. When it comes down to it it is just a personal preference. I've seen quite a few folks just set it to Unrestricted. I think RemoteSigned is a reasonable compromise. However in an environment that requires stricter security then AllSigned is probaby a better way to go. In the end, that is why the team provided us a way to set the security policy to best meet our individual needs.