# .\install-packages.ps1 : File …\install-packages.ps1 cannot be loaded because running ..

Running Windows 8.1 trying to use a simple Powershell script, in this case it was for the logging service for Enterprise Library 6 Semantic Logging Application Block (SLAB), when I got this error:


PS C:\code\Entlib\LoggingService> .\install-packages.ps1
.\install-packages.ps1 : File C:\code\Entlib\LoggingService\install-packages.ps1 cannot be loaded because running
At line:1 char:1
+ .\install-packages.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess



Check the link proffered in the error and you’d almost think you only need to do this:

Set-ExecutionPolicy Undefined

except if there is no existing execution policy, the above command does nothing, and worse the dialogue leads you to think it might work, since it asks if you want to change the policy [Y] Yes, [N] No, etc. as below:

as you can see, it still fails, because there was no policy in place (though that part is not obvious from the error).

The fix, create a new execution policy (to add one, when none exists) and then disable it.

in other words, type


Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

then


Set-ExecutionPolicy Undefined -scope LocalMachine

finally the Semantic Logging Application block logging service script will now run properly