Blog Post

Running Powershell Scripts – #SQLNewBlogger

,

Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

When you install Windows, by default, the execution of scripts is prevented. If you try to run something on a new machine, you might get this error:

2020-01-08 09_39_25-cmd - powershell

The error message lets you know this is an issue with the Execution Policy. There’s a URL to help you, which takes you to the “About Execution Policies” page.

2020-01-08 09_40_17-about_Execution_Policies - PowerShell _ Microsoft Docs

You can set your execution policy to allow scripts, and Microsoft has a document that explains the implications.

For my laptop, I usually go with unrestricted, since I create and run lots of random PoSh scripts.

I DO NOT DOWNLOAD SCRIPTS and run them from the Internet. Be very, very careful about running scripts.

From an administrator PoSh console, you can change this.

2020-01-08 09_42_07-cmd - powershell (Admin)

Read the docs and be sure you understand what is going on. You can change to signed scripts and then learn how to do this, which likely makes some sense for privileged workstations and building scripts in production environments.

SQLNewBlogger

I had to set this on a new machine recently and decided to blog about it, since I’ve had to look it up over and over. Hopefully this will help me remember how to do this.

This took less than 10 minutes and it’s a good blog for you. Learn about signing and talk about why that is or isn’t appropriate for you in your own post.

Original post (opens in new tab)
View comments in original post (opens in new tab)

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating