Last time I wrote on this blog, Powershell 4 was king and it boasted more than 1300 cmdlets on its Windows 2012 R2 platform:
PS C:\Users\carlo> Get-Command| measure Count : 1301 Average : Sum : Maximum : Minimum : Property :There were more than 60 modules, covering most of the aspects of a server configuration:
Get-Module -ListAvailable
Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 2.0.0.0 AppLocker {Get-AppLockerFileInformation, Get-Ap
Manifest 2.0.0.0 Appx {Add-AppxPackage, Get-AppxPackage, Ge
Manifest 1.0 BestPractices {Get-BpaModel, Get-BpaResult, Invoke-
Manifest 1.0.0.0 BitsTransfer {Add-BitsFile, Complete-BitsTransfer,
Manifest 1.0.0.0 BranchCache {Add-BCDataCacheExtension, Clear-BCCa
Manifest 1.0.0.0 CimCmdlets {Get-CimAssociatedInstance, Get-CimCl
Manifest 1.0.0.0 DirectAccessClientComponents {Disable-DAManualEntryPointSelection,
Script 3.0 Dism {Add-AppxProvisionedPackage, Add-Wind
Manifest 1.0.0.0 DnsClient {Resolve-DnsName, Clear-DnsClientCach
Manifest 2.0.0.0 International {Get-WinDefaultInputMethodOverride, S
Manifest 1.0.0.0 iSCSI {Get-IscsiTargetPortal, New-IscsiTarg
Manifest 2.0.0.0 IscsiTarget {Add-ClusteriSCSITargetServerRole, Ad
Script 1.0.0.0 ISE {New-IseSnippet, Import-IseSnippet, G
Manifest 1.0.0.0 Kds {Add-KdsRootKey, Get-KdsRootKey, Test
Manifest 3.0.0.0 Microsoft.PowerShell.Diagnostics {Get-WinEvent, Get-Counter, Import-Co
Manifest 3.0.0.0 Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-It
Manifest 3.0.0.0 Microsoft.PowerShell.Security {Get-Acl, Set-Acl, Get-PfxCertificate
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Format-List, Format-Custom, Format-T
Manifest 3.0.0.0 Microsoft.WSMan.Management {Disable-WSManCredSSP, Enable-WSManCr
Manifest 1.0 MMAgent {Disable-MMAgent, Enable-MMAgent, Set
Manifest 1.0.0.0 MsDtc {New-DtcDiagnosticTransaction, Comple
Manifest 2.0.0.0 NetAdapter {Disable-NetAdapter, Disable-NetAdapt
Manifest 1.0.0.0 NetConnection {Get-NetConnectionProfile, Set-NetCon
Manifest 1.0.0.0 NetEventPacketCapture {New-NetEventSession, Remove-NetEvent
Manifest 2.0.0.0 NetLbfo {Add-NetLbfoTeamMember, Add-NetLbfoTe
Manifest 1.0.0.0 NetNat {Get-NetNat, Get-NetNatExternalAddres
Manifest 2.0.0.0 NetQos {Get-NetQosPolicy, Set-NetQosPolicy,
Manifest 2.0.0.0 NetSecurity {Get-DAPolicyChange, New-NetIPsecAuth
Manifest 1.0.0.0 NetSwitchTeam {New-NetSwitchTeam, Remove-NetSwitchT
Manifest 1.0.0.0 NetTCPIP {Get-NetIPAddress, Get-NetIPInterface
Manifest 1.0.0.0 NetworkConnectivityStatus {Get-DAConnectionStatus, Get-NCSIPoli
Manifest 1.0.0.0 NetworkTransition {Add-NetIPHttpsCertBinding, Disable-N
Manifest 1.0 NFS {Get-NfsMappedIdentity, Get-NfsNetgro
Manifest 1.0.0.0 PcsvDevice {Get-PcsvDevice, Start-PcsvDevice, St
Manifest 1.0.0.0 PKI {Add-CertificateEnrollmentPolicyServe
Manifest 1.1 PrintManagement {Add-Printer, Add-PrinterDriver, Add-
Binary 1.0 PSDesiredStateConfiguration {Set-DscLocalConfigurationManager, St
Script 1.0.0.0 PSDiagnostics {Disable-PSTrace, Disable-PSWSManComb
Binary 1.1.0.0 PSScheduledJob {New-JobTrigger, Add-JobTrigger, Remo
Manifest 2.0.0.0 PSWorkflow {New-PSWorkflowExecutionOption, New-P
Manifest 1.0.0.0 PSWorkflowUtility Invoke-AsWorkflow
Manifest 2.0.0.0 RemoteDesktop {Get-RDCertificate, Set-RDCertificate
Manifest 1.0.0.0 ScheduledTasks {Get-ScheduledTask, Set-ScheduledTask
Manifest 2.0.0.0 SecureBoot {Confirm-SecureBootUEFI, Set-SecureBo
Script 1.0.0.0 ServerCore {Get-DisplayResolution, Set-DisplayRe
Script 2.0.0.0 ServerManager {Get-WindowsFeature, Install-WindowsF
Cim 1.0.0.0 ServerManagerTasks {Get-SMCounterSample, Get-SMPerforman
Manifest 2.0.0.0 SmbShare {Get-SmbShare, Remove-SmbShare, Set-S
Manifest 2.0.0.0 SmbWitness {Get-SmbWitnessClient, Move-SmbWitnes
Manifest 1.0.0.0 SoftwareInventoryLogging {Get-SilComputer, Get-SilSoftware, Ge
Manifest 1.0.0.0 StartScreen {Export-StartLayout, Import-StartLayo
Manifest 2.0.0.0 Storage {Add-InitiatorIdToMaskingSet, Add-Par
Manifest 2.0.0.0 TLS {New-TlsSessionTicketKey, Enable-TlsS
Manifest 1.0.0.0 TroubleshootingPack {Get-TroubleshootingPack, Invoke-Trou
Manifest 2.0.0.0 TrustedPlatformModule {Get-Tpm, Initialize-Tpm, Clear-Tpm,
Manifest 1.0.0.0 UserAccessLogging {Enable-Ual, Disable-Ual, Get-Ual, Ge
Manifest 2.0.0.0 VpnClient {Add-VpnConnection, Set-VpnConnection
Manifest 1.0.0.0 Wdac {Get-OdbcDriver, Set-OdbcDriver, Get-
Manifest 2.0.0.0 Whea {Get-WheaMemoryPolicy, Set-WheaMemory
Manifest 1.0.0.0 WindowsDeveloperLicense {Get-WindowsDeveloperLicense, Show-Wi
Script 1.0 WindowsErrorReporting {Enable-WindowsErrorReporting, Disabl
Manifest 1.0.0.0 WindowsSearch {Get-WindowsSearchSetting, Set-Window
Starting from last May, Microsoft has published a preview release of the fifth version of its Management Framework (which corresponds to KB2894868), which includes Windows PowerShell 5 and brings updates to Desired State Configuration (DSC) as well as three new modules: OneGet, PowerShellGet, and NetworkSwitch.
The Microsoft download page gives you the possibility to download the framework for X86 and x64 computers. Each download is around 5 MBs:
For now these updates install only on Windows 8.1 or Windows 2012 R2, as stated in the release notes.
The MSU to use for Windows 2012 R2 is named WindowsBlue-KB2894868-x64.
Before the installation of the WMF 5.0, note that Windows 2012 R2 comes with the following versions of its components out-of-the-box:
PS C:\Users\carlo> $PSVersionTable Name Value ---- ----- PSVersion 4.0 WSManStackVersion 3.0 SerializationVersion 1.1.0.1 CLRVersion 4.0.30319.34014 BuildVersion 6.3.9600.16394 PSCompatibleVersions {1.0, 2.0, 3.0, 4.0} PSRemotingProtocolVersion 2.2
Let's go through the easy upgrade process to Powershell 5.0:
![]() |
Start the installer... |
![]() |
Wait for it... |
![]() |
Done! |
Then when Powershell starts, you can see that you have moved to version 5 just looking at the date as it appears in the logo: if it shows 2014 then you have Powershell 5.0. If it shows 2013 then you have Powershell 4.0.
Also the output of $PSVersionTable shows us new values:
PS C:\Users\carlo> $PSVersionTable Name Value ---- ----- PSVersion 5.0.9740.0 WSManStackVersion 3.0 SerializationVersion 1.1.0.1 CLRVersion 4.0.30319.34014 BuildVersion 6.3.9740.0 PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} PSRemotingProtocolVersion 2.2
With Powershell 5.0 some new cmdlets appear straight away:
PS C:\Users\carlo> Get-Command | measure Count : 1331 Average : Sum : Maximum : Minimum : Property :
Beside a refresh of Desired State Configuration (DSC) (you can read the complete post by Ravikanth Chaganti on PowershellMagazine), there are 30 new cmdlets, included in three new modules: OneGet, PowershellGet and NetworkSwitch:
PS C:\Users\carlo> gcm -Module NetworkSwitch CommandType Name Source ----------- ---- ------ Function Disable-NetworkSwitchEthernetPort NetworkSwitch Function Disable-NetworkSwitchFeature NetworkSwitch Function Disable-NetworkSwitchVlan NetworkSwitch Function Enable-NetworkSwitchEthernetPort NetworkSwitch Function Enable-NetworkSwitchFeature NetworkSwitch Function Enable-NetworkSwitchVlan NetworkSwitch Function Get-NetworkSwitchEthernetPort NetworkSwitch Function Get-NetworkSwitchFeature NetworkSwitch Function Get-NetworkSwitchGlobalData NetworkSwitch Function Get-NetworkSwitchVlan NetworkSwitch Function New-NetworkSwitchVlan NetworkSwitch Function Remove-NetworkSwitchEthernetPortIPAddress NetworkSwitch Function Remove-NetworkSwitchVlan NetworkSwitch Function Restore-NetworkSwitchConfiguration NetworkSwitch Function Save-NetworkSwitchConfiguration NetworkSwitch Function Set-NetworkSwitchEthernetPortIPAddress NetworkSwitch Function Set-NetworkSwitchPortMode NetworkSwitch Function Set-NetworkSwitchPortProperty NetworkSwitch Function Set-NetworkSwitchVlanProperty NetworkSwitch PS C:\Users\carlo> gcm -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 PS C:\Users\carlo> gcm -Module PowerShellGet CommandType Name Source ----------- ---- ------ Function Find-Module PowerShellGet Function Install-Module PowerShellGet Function Publish-Module PowerShellGet Function Update-Module PowerShellGet
These three new modules confirm Powershell as being the 'glue' which Microsoft wants to push in the limelight as the key tool for a holistic view of the DataCenter, as stated in the DAL:
"The datacenter abstraction layer (DAL) is our work with the industry to provide a common management abstraction for all the resources of a data center to make it simple and easy to adopt and deploy cloud computing. The DAL is not specific to one operating system; it benefits UNIX cloud-computing efforts every bit as much as Windows.
The DAL uses the existing DMTF standards-based management stack to manage all the resources of a data center: physical servers, storage devices, networking devices, hypervisors, operating systems, application frameworks, services, and applications. The DAL is different than other cloud efforts in that it uses - and builds on - proven management stack technologies, instead of inventing new ones."
As a matter of fact, for the moment there is no real tutorial for the usage of these network switch management Cmdlets:
PS C:\Users\carlo> man Get-NetworkSwitchVlan -Online
Get-Help : The online version of this Help topic cannot be displayed because the Internet address (URI) of the Help
topic is not specified in the command code or in the help file for the command.
At line:55 char:7
+ Get-Help @PSBoundParameters | more
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Get-Help], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.GetHelpCommand
While this is fully understandable (this is a Preview), I think that this reduces the explorability of those cmdlets and does not encourage IT staff to give them a try for the moment.
What it's clear reading the syntax instructions is that those cmdlets rely on CIM and then to manage the Layer 2 switches you will need to create CIM session connections:
PS C:\Users\carlo> man Get-NetworkSwitchVlan -full NAME Get-NetworkSwitchVlan SYNTAX Get-NetworkSwitchVlan -CimSession[-Name ] [ ] Get-NetworkSwitchVlan -CimSession -VlanId [ ] Get-NetworkSwitchVlan -CimSession -InstanceId [ ] Get-NetworkSwitchVlan -CimSession -Caption [ ] Get-NetworkSwitchVlan -CimSession -Description [ ]
The second Powershell improvement that comes with the WMF 5.0 is the introduction of OneGet module, which can be used to download packages from Chocolatey. The first time you run the Find-Package cmdlet, it asks for the permission to download NuGet:
Just from a first look to the previous screenshot, I can see that this is going to be funny! Just look at the following command:
PS C:\Users\carlo> Find-Package antivirus Name Version Status Source ---- ------- ------ ------ ad-awarefreeantivirus 11.2.5952.0 Available chocolatey avastfreeantivirus 9.0.2018 Available chocolatey AvgAntivirusBusiness 2013.3349 Available chocolatey avgantivirusfree 14.0.4592 Available chocolatey avirafreeantivirus 14.0.3.338 Available chocolatey
This is simply great! I can choose an antivirus to install and get it on my test machine using Powershell. What else?
Let's proceed with the installation of Avast!. The process is a breeze:
Install-Package avastfreeantivirus
As you can see in Resource Monitor, Powershell itself is downloading the source file and saving it to C:\Users\carlo\AppData\Local\Temp\2\Microsoft.OneGet.Utility\2\chocolatey\avastfreeantivirus
In my case the installation failed because Avast! can't be installed on a Windows Server version. So Find-Package does not shows us only packages which are available for our platform but all of them and it's up to the admin to choose the right ones to install:
Interesting enough, OneGet gives the possibility to install the Powershell Module for Azure. Nice shot!
PS C:\Users\carlo> find-package azure
Name Version Status Source Summary
---- ------- ------ ------ -------
AzureBuildSDKvs2012 2.2.2 Available chocolatey Azure
AzureConnectDnsSync 1.0.0 Available chocolatey
AzureStorageExplorer 5.0.0.0 Available chocolatey Azure
Boxstarter.Azure 2.4.15 Available chocolatey
CloudBerryExplorer.AzureStorage 2.1.0.37 Available chocolatey Cloud
Dogtail.AzureSDK 11.2.13230.3 Available chocolatey
Dogtail.AzureSDK.2.1.VisualSt... 11.2.13230.3 Available chocolatey
Sogeti.WindowsAzure.Plugins.E... 1.0.0 Available chocolatey A Win
WindowsAzureLibrariesForNet 2.2.20140119 Available chocolatey
WindowsAzureLibsForNet 2.2.20140128 Available chocolatey
WindowsAzurePowershell 0.8.0 Available chocolatey
Let's see if can make it through this time:
PS C:\Users\carlo> Install-Package windowsazurepowershell
Installing Package 'WindowsAzurePowershell' from untrusted source
WARNING: This package source is not marked as safe. Are you sure you want to install software from 'chocolatey'
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
Name Version Status Source Summary
---- ------- ------ ------ -------
DotNet4.5 4.5.20120822 Installed chocolatey The Microsoft .NET Framework 4.5
Install-Package : Process Failed:msiexec.exe
At line:1 char:1
+ Install-Package windowsazurepowershell
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package],
Exception
+ FullyQualifiedErrorId : errorid,Microsoft.PowerShell.OneGet.CmdLets.InstallPackage
The good thing is that Install-Package detects a dependency from DotNet 4.5 and gets this package too.
The bad thing is the installation fails (probably because OneGet and Chocolatey do not handle well the transition to msiexec), and that the failed package is wrongly shown as properly installed:
PS C:\Users\carlo> Get-Package Name Version Status Source ---- ------- ------ ------ avastfreeantivirus 9.0.2018 Installed Local File DotNet4.5 4.5.20120822 Installed Local File WindowsAzurePowershell 0.8.0 Installed Local File
Let's try again with more standard applications: Notepad++ and Vlc:
PS C:\Users\carlo> Install-Package notepadplusplus,vlc Installing Package 'notepadplusplus' from untrusted source WARNING: This package source is not marked as safe. Are you sure you want to install software from 'chocolatey' [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Name Version Status Source ---- ------- ------ ------ notepadplusplus.install 6.6.4 Installed chocolatey notepadplusplus 6.6.4 Installed chocolatey vlc 2.1.3 Installed chocolatey
This one worked, since I can see Notepad++ and Vlc in the list of the installed Apps. Good.
So, concerning OneGet, I can see that, while experimental, this is pretty wonderful stuff. In the future it would be nice to have an option to update installed packages when a new version becomes available, but, nonetheless, this is a great improvement to Powershell as a management language.
To complete this post, let me mention that the PowerShell Team also added the PowerShellGet module in the May 2014 update to the v5.0 Preview. It comes with an official Microsoft repository for pulling in the latest modules. The first time you use it, it ask for the permission to install NuGet.exe:
PS C:\Users\carlo> find-module
NuGet.exe is required to continue.
PowerShellGet requires NuGet.exe to interact with NuGet based galleries. NuGet.exe must be available in
'C:\Users\carlo\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet'. For more information about NuGet, see
http://www.nuget.org. Do you want PowerShellGet to download NuGet.exe to
'C:\Users\carlo\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet' now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
Version Name DateUpdated Description
------- ---- ----------- -----------
1.1.0.0 AutoVars 6/6/2014 11:38:07 PM Allows for t
2.0 BetterCredentials 6/6/2014 4:28:03 PM A (compatibl
5.0 Bing 6/6/2014 4:28:03 PM A few functi
1.0.0.0 CimInventory 6/6/2014 4:28:03 PM Module that
6.0 ConversionModule 6/6/2014 4:28:03 PM a module tha
1.0 EWS 6/8/2014 12:33:11 PM Module to en
2.1.0.2 FAQ 6/6/2014 4:28:03 PM A Frequently
1.0 GenericMethods 6/6/2014 4:28:03 PM The Invoke-G
1.2.0.0 HardwareManagement 6/6/2014 4:28:03 PM Out-of-band
1.1 IEFavorites 6/6/2014 4:28:03 PM Used to mana
1.0 InlineMailAttachments 6/6/2014 4:28:03 PM This module
0.1.0.0 ISEGit 6/6/2014 11:48:07 PM Module to wo
3.0 LocalUserManagement 6/6/2014 11:28:07 PM a module tha
1.0.0.5 LockObject 6/6/2014 4:28:03 PM Lock-Object
1.0.0.0 MyDefaults 6/6/2014 11:38:07 PM Sets and get
1.4 myModule 6/6/2014 4:28:03 PM My PowerShel
1.0.0.2 poke 6/6/2014 4:28:03 PM A PowerShell
1.0 Posh-Shodan 6/6/2014 4:28:03 PM Module for i
1.2 Posh-VirusTotal 6/5/2014 12:28:40 AM PowerShell m
1.0 PoshInternals 6/5/2014 12:28:40 AM Collection o
1.0 PoshNet 6/5/2014 4:39:40 PM Get-DNS is "
2.2.1 PoshWSUS 6/5/2014 4:39:40 PM PowerShell m
3.6 PowerBot 6/5/2014 12:28:40 AM PowerBot: th
0.4 PowerEvents 6/5/2014 4:34:40 PM PowerEvents
1.2 PowerShellCookbook 6/8/2014 1:03:09 AM Sample scrip
1.2 PowerShellHumanizer 6/5/2014 4:39:40 PM PowerShell H
4.0 PowerShellISEModule 6/6/2014 6:23:03 PM a module tha
1.1.0.1 PowerShellLogging 6/5/2014 4:39:40 PM Captures Pow
1.0 PreferenceVariables 5/28/2014 5:47:54 PM The Get-Call
3.1.0.0 Pscx 6/4/2014 8:58:40 PM PowerShell C
1.0.0.8 PSReadline 6/5/2014 4:39:40 PM Great comman
2.4 ResolveAlias 6/5/2014 12:28:40 AM A function f
1.2.1.0 ScriptBrowser 6/5/2014 12:28:40 AM Script Brows
1.0.4.0 ScriptCS 6/5/2014 4:39:40 PM Allows execu
1.0 ScriptTransforms 5/28/2014 5:47:54 PM Enables you
1.0.4.36 ScsmPx 5/28/2014 5:47:54 PM The ScsmPx m
1.0.0.1 SNMP 6/6/2014 9:03:06 PM Module to ma
2.0 SQLite 6/5/2014 4:39:40 PM The SQLite P
1.0 StringTokens 6/5/2014 4:39:40 PM The Get-Stri
1.0.4.2 StrongNaming 5/28/2014 5:47:54 PM The Strong N
1.1 TCPServer 6/5/2014 12:28:40 AM Module used
1.0.0.1 TestConnectionAsync 6/5/2014 4:39:40 PM Test-Connect
1.1.0.0 TxF 6/5/2014 4:39:40 PM Provides tra
1.0.2.2 TypeAccelerator 5/28/2014 5:47:54 PM The TypeAcce
2.0 xActiveDirectory 6/7/2014 2:08:09 PM The xActiveD
0.1.0 xAzure 6/7/2014 2:13:09 PM The xAzure m
1.1.5 xAzureVMResources 6/7/2014 1:08:09 PM Module with
1.2.1 xComputerManagement 6/7/2014 2:08:09 PM The xCompute
1.1.1 xDatabase 6/7/2014 2:08:09 PM The xDatabas
1.0 xDhcpServer 6/7/2014 2:13:09 PM The xDhcpSer
1.0 xDnsServer 6/7/2014 2:13:09 PM The xDnsServ
2.0 xDscDiagnostics 6/7/2014 2:08:09 PM Module to he
1.1.1 xDSCResourceDesigner 6/7/2014 2:08:09 PM The xDscReso
2.6.0.0 xEXOUserAvailability 6/7/2014 1:08:09 PM xEXOUserAvai
1.1.1 xFailOverCluster 6/7/2014 2:08:09 PM The xFailOve
2.1.1 xHyper-V 6/7/2014 2:08:09 PM The xHyper-V
0.2.16.1 xJea 6/7/2014 12:48:07 AM Module with
2.1.1 xNetworking 6/7/2014 2:08:09 PM The xNetwork
1.0.0 xOneGet 6/7/2014 2:13:09 PM DSC Resource
3.0.0.0 xPSDesiredStateConfiguration 6/7/2014 2:08:09 PM The xPSDesir
1.0.1 xRemoteDesktopSessionHost 6/7/2014 2:08:09 PM The xRemoteD
1.0.1 xSmbShare 6/7/2014 2:08:09 PM The xSmbShar
1.1.2 xSqlPs 6/7/2014 2:08:09 PM The xSqlPs m
1.0.1 xSystemSecurity 6/6/2014 12:58:02 PM The xSystemS
1.3.1 xWebAdministration 6/7/2014 2:08:09 PM The xWebAdmi
1.0 xWindowsUpdate 6/7/2014 2:13:09 PM Module with
0.0.0.1 xWinEventLog 6/7/2014 2:13:09 PM Configure Wi
A new world opens, with so many modules available for use. In a next post I will decisively continue exploring the new functionalities and features of Powershell 5.0. So stay tuned!