Powershell 5


Powershell 5 is expected to be released with Windows 10. It’s currently (April 2015) in preview. It’s backward compatible with Windows 8, 8.1, 2012, and 2012 R2. To get PS5 install WMF5 from this link. Here’s the general PowershellGet architecture:

2677.1.png-550x0

For more information see the Powershell Gallery. PS5 installation requires a reboot

PS5-01After a reboot, in Powershell ISE, PS version shows as version 5

$PSVersionTable

PS5-02PS5 comes with PowershellGet module. To see its commands:

Get-Command -Module PowerShellGet

PS5-03

When running for the first time, run this command to automate the download of the needed nuget-anycpu.exe

Get-PackageProvider -Name NuGet -ForceBootstrap

PS5-04The default Repository is the Powershell Gallery, and it’s untrusted by default:

PS5-05To check out currently available modules:

$Modules = Find-Module
$Modules.Count # 153
$Modules | sort name | select * | Out-GridView

To install a module from the Gallery, use Install-Module as in:

Install-Module Pester

PS5-06Since the Powershell Gallery is untrusted by default, we’ll get the message above. If you want to trust the Powershell Gallery, use:

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

Alternatively, use the -Force parameter with the Install-Module command to avoid the untrusted repository prompt.

Pester is a great unit testing module to help test Powershell scripts, developed by David Wyatt and the Pester team. To see its commands:

Get-Command -Module Pester

For more information on Pester see Pester on GitHub and video presentation from Powershell Summit NA 2015.

Now I have this module and can use its commands.

One of the great benefits of a NuGet repository for PS modules like PowershellGet is version control, as it keeps track of module versions as they’re published. To see different versions of a module:

Find-Module -Name Pester -AllVersions | select version,PublishedDate  | FT -a

PS5-07

 

 

 

 

 

 

 

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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