Running Powershell Scripts on WinRT


It is quite amazing to see how much power is hidden inside the Windows RT operating system if you just go looking for it. Where the iPad iOS is basically a phone with a large screen, the Windows Surface and its brethren have so more to offer as a scaled down PC. You may never want this or need it, but if you do, it’s there.

For example I was playing yesterday with the WinRT command prompt, and found that both VBScript and Javascript  scripting is supported (cscript.exe and wscript.exe) which is kind of fun.

More useful is the fact that Powershell is supported. But when you try to run a script file, the classic Powershell message that comes up:

File C:\users\peh\documents\test.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.

On an ordinary PC you would then usually use the command Set-ExecutionPolicy RemoteSigned

If you do this on Windows RT, however, it will throw this message at you:

Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.

It took me a while to google an answer to this, but what helped me was this great post by Jeroen W. Pluimers.

The answer from Jeroen is to use a variation of the Set-ExecutionPolicy that only covers the current user – remember that, as opposed to iOS, the WinRT OS has the concept of user-based security:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s