- SmartDeploy: Rethinking software deployment to remote workers in times of a pandemic - Thu, Jul 30 2020
- Outlook attachments now blocked in Office 365 - Tue, Nov 19 2019
- PolicyPak MDM Edition: Group Policy and more for BYOD - Tue, Oct 29 2019
It has been six months since the release of Windows Management Framework (WMF) 4.0. The core component in WMF 4.0 is version 4.0 of PowerShell. The PowerShell team has been hard at work on the latest revision and has publically released the WMF 5.0 Preview. But what’s new in PowerShell 5.0?
$PSVersionTable Name Value ---- ----- PSVersion 5.0.9701.0 WSManStackVersion 3.0 SerializationVersion 1.1.0.1 CLRVersion 4.0.30319.34011 BuildVersion 6.3.9701.0 PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} PSRemotingProtocolVersion 2.2
Checking the installed PowerShell version
The two biggest features in PowerShell 5.0 are Windows PowerShell OneGet and a new module for managing layer 2 network switches. Smaller features include updates for Desired State Configuration (DSC), the PowerShell console, and the Integrated Scripting Environment (ISE).
As we cover these additions, you can follow along by installing the WMF 5.0 update on your machine. The update can be downloaded here. As of right now, PowerShell 5.0 can only be used on Windows 8.1 and Server 2012 R2 machines. Because it is a preview, it should not be used in a production environment, and it may come with specific server install conditions. For example, it is currently not supported on SCCM 2012, SCVMM 2008 R2, and Exchange 2007.
What is Windows PowerShell OneGet?
OneGet is the PowerShell team’s answer to the complexity of application installation. By using the Chocolatey repository, applications can be installed, updated, or removed with command line precision. Let’s start by viewing the commands in the OneGet module:
Get-Command -Module OneGet CommandType Name Source ----------- ---- ------ Cmdlet Add-PackageSource OneGet Cmdlet Find-Package OneGet Cmdlet Get-Package OneGet Cmdlet Get-PackageSource OneGet Cmdlet Install-Package OneGet Cmdlet Remove-PackageSource OneGet Cmdlet Uninstall-Package OneGet
The first version of OneGet contains seven new cmdlets.
By quickly reading the help file for each module, we can see that Find-Package will display available applications for installation. In fact, more than 1,800 packages are available. We can take find-package to Out-GridView to search the software content. In this example, we are going to search for the latest version of 7-Zip.
Filtering in Out-GridView makes finding applications super easy!
If we wanted to install 7-Zip 9.22 on our machine, we could use basic PowerShell syntax to find our application and install it. Here is an example:
Find-Package | where name -eq 7zip | Install-Package Name Version Status Source Su mm ar y ---- ------- ------ ------ -- 7zip.install 9.22.01.20130618 Installed chocolatey 7- 7zip 9.22.01.20130618 Installed chocolatey 7-
One line can install an application in PowerShell.
OneGet can potentially let you automate complex application installations, simplify network shares, and make reinstallation much easier. Imagine creating a OneGet script that installs all of your favorite applications automatically, and in just a few minutes! Imagine being able to uninstall an application with a simple PowerShell command. That is the power of OneGet.
Managing network switches with PowerShell
Windows Server 2012 R2 introduced native management of layer 2 network switches. When you have Windows Server certified equipment, you can use SCVMM 2012 R2 to manage the hardware. There are times when you might need to manage equipment with a PowerShell script. WMF 5.0 introduces that ability.
The new module, Network Switch, contains 19 cmdlets that allow you to do the following in a CIM session:
- Investigate the switch and available features with the Get-NetworkSwitchFeature cmdlet.
- Configure specific switch features or enable/disable switch features.
- Manage VLANs with the NetworkSwitchVLAN cmdlet set (Get, New, Disable, Enable, Remove, Set).
- Save or restore switch configurations.
Though this module isn’t widely available for use yet, Microsoft has documented a few ways in which it can be used. If you have compatible hardware, you can use the following commands to establish a session:
$Options = New-CimSessionOption -UseSsl -SkipCACheck -SkipCNCheck -SkipRevocationCheck $Session = New-CimSession -CN SWITCHIP -port 5986 -Auth Basic –Credential USERNAME -SessionOption $Options
With the session, you can begin using the Network Switch modules. For example, Get-NetworkSwitchFeature -CimSession $Session would list any available features. Disabling a port is a simple command: Disable-NetworkSwitchEthernetPort -PortNumber 1 -CimSession $Session.
OneGet and network switch management make PowerShell even better! Expect to see each be improved and blogged about over the next few months. Have you used PowerShell 5.0 yet? What features are the most exciting for you?