Tuesday, May 17, 2016

Life is far easier with PowerShell 5

PowerShell is a scripting language that allows you to control and automate a whole lot of technology. It is really the premier administration tool for managing Office 365 and Azure. Unfortunately, because of its ‘programming’ nature many IT Professionals have avoided it.

One of the issues with PowerShell has been configuring the environment to allow access to everything you need. Typically, you needed to download and install separate modules to allow commands to be execute for Office 365 service and Azure. PowerShell 5 has overcome that problem by allowing you to download and install these modules directly from the PowerShell command line.

Thus, you need to firstly have PowerShell 5.0 on your machine. PowerShell 5 is included with the latest versions of Windows 10 but unfortunately it isn’t currently installed by default on Windows Server 2012 R2. This means if you want to use PowerShell version 5 on a server you’ll typically need to firstly download and install it.

image

For a Windows Server 2012 R2 you’ll need to download and install the Windows Management Framework 5,0 which you can find here:

https://www.microsoft.com/en-us/download/details.aspx?id=50395

image

When executed it will scan the machine to determine what updates need to be installed.

image

You’ll then be promoted to install any updates.

image

After these updates have been installed you may need to be reboot the machine.

image

To download and install the Azure module for PowerShell simply open a new PowerShell command prompt now and type:

install-module azure

You maybe be prompted to install the NuGet provider. Enter Y here to accept this.

image

You may also be prompted that you are installing from an untrusted repository. Again, select Y here to continue.

image

You should now see the module package being downloaded and installed as shown above.

When complete you’ll be returned to the command prompt.

image

To install the Azure Resource Manager module now type:

install-module azurerm

You should again see this module being downloaded and installed as shown above.

You’ll again be returned to the command prompt when complete.

image

Now if you issue the command:

get-module –listavailable

You will see all the see all the PowerShell modules that are available to you. In the above example you can see both the Azure and AzureRM modules are listed as available.

image

If you now issue the command:

$psversiontable.psversion

You will see the version of PowerShell installed (here version 5 as expected).

That’s a lot easier than it ever used to be with PowerShell and another reason why you should be using the latest version!