1. State the problem
With the release of Windows Server 2016 TP2 a few weeks ago, I was wondering what new PowerShell cmdlets are now included (when you compare to Windows Server 2012 R2). However, the list of cmdlets is so long now that it is hard to spot the differences by hand.
However, there a cmdlet in PowerShell to show all the cmdlets available (Get-Command) and a little bit of programming would make it easy to find out what are the main differences. So I set out to collect the data and compare the list.
DISCLAIMER: As you probably know already, the Technical Preview is subject to change so all the information about Windows Server 2016 TP2 is preliminary and may not make it into the final product. Use with care, your mileage may vary, not available in all areas, some restrictions apply, professional PowerShell operator on a closed Azure VM course, do not attempt.
2. Gather the data
First, I needed the list of cmdlets from both versions of the operating system. That was actually pretty easy to gather, with a little help from Azure. I basically provisioned two Azure VM, one running Windows Server 2012 R2 and one running Windows Server 2016 Technical Preview 2 (yes, TP2 is now available in the regular Azure VM image gallery).
Second, I installed all of the Remote Server Administration Tools (RSAT) on both versions. That loads the PowerShell modules used for managing features that are not installed by default, like Failover Cluster or Storage Replica.
Finally, I ran a simple cmdlet to gather the list from Get-Command and save it to an XML file. This made it easier to put all the data I needed in a single place (my desktop machine running Windows 10 Insider Preview). Here's a summary of what it took:
- Create WS 2012 R2 Azure VM
- Install RSAT in the WS 2012 R2 VM
- Get-WindowsFeature RSAT* | Install-WindowsFeature
- Capture XML file with all the WS 2012 R2 cmdlet information
- Get-Command | Select * | Export-CliXml C:\WS2012R2Cmdlets.XML
- Create WS 2016 TP2 Azure VM
- Install RSAT in the WS 2016 TP2 VM
- Get-WindowsFeature RSAT* | Install-WindowsFeature
- Capture XML file with all the WS 2016 TP2 cmdlet information
- Get-Command | Select * | Export-CliXml C:\WS2016TP2Cmdlets.XML
3. Process the data
With the two XML files at hand, all I had left to do was to compare them to produce a good list of what's new. The first attempt resulted in a long list that was hard to understand, so I decided to do it module by module.
The code starts by creating a combined list of modules from both operating systems. Then it builds a dictionary of all cmdlets for a given module, assigning the value 1 if it's in WS 2012 R2, 2 if it's in WS 2016 TP2 and 3 if it's in both.
Then I would show the total number of cmdlets per module per OS, then number of new cmdlets and the actual list of new cmdlets. Since the goal was to publish this blog, I actually wrote the script to format the output as an HTML table. Quite handy :-).
4. Show the results
Finally, here is resulting table with all the new PowerShell cmdlets (by module) in Windows Server 2016 TP2, compared to Windows Server 2012. Enjoy!
Module | New Cmdlets | WS 2016 TP2 Cmdlets | WS 2012 R2 Cmdlets |
0 | 38 | 38 | |
ActiveDirectory | 0 | 147 | 147 |
ADRMSAdmin | 0 | 21 | 21 |
AppLocker | 0 | 5 | 5 |
Appx | 8 | 14 | 6 |
+ Add-AppxVolume + Dismount-AppxVolume + Get-AppxDefaultVolume + Get-AppxVolume + Mount-AppxVolume + Move-AppxPackage + Remove-AppxVolume + Set-AppxDefaultVolume | |||
BestPractices | 0 | 4 | 4 |
BitLocker | 0 | 13 | 13 |
BitsTransfer | 0 | 8 | 8 |
BranchCache | 0 | 32 | 32 |
CimCmdlets | 0 | 14 | 14 |
CIPolicy | 1 | 1 | 0 |
+ ConvertFrom-CIPolicy | |||
ClusterAwareUpdating | 0 | 17 | 17 |
ConfigCI | 10 | 10 | 0 |
+ Edit-CIPolicyRule + Get-CIPolicy + Get-CIPolicyInfo + Get-SystemDriver + Merge-CIPolicy + New-CIPolicy + New-CIPolicyRule + Remove-CIPolicyRule + Set-HVCIOptions + Set-RuleOption | |||
Defender | 11 | 11 | 0 |
+ Add-MpPreference + Get-MpComputerStatus + Get-MpPreference + Get-MpThreat + Get-MpThreatCatalog + Get-MpThreatDetection + Remove-MpPreference + Remove-MpThreat + Set-MpPreference + Start-MpScan + Update-MpSignature | |||
DFSN | 0 | 23 | 23 |
DFSR | 3 | 45 | 42 |
+ Get-DfsrDelegation + Grant-DfsrDelegation + Revoke-DfsrDelegation | |||
DhcpServer | 0 | 121 | 121 |
DirectAccessClientComponents | 0 | 11 | 11 |
Dism | 4 | 43 | 39 |
+ Add-WindowsCapability + Expand-WindowsCustomDataImage + Get-WindowsCapability + Remove-WindowsCapability | |||
DnsClient | 0 | 17 | 17 |
DnsServer | 21 | 122 | 101 |
+ Add-DnsServerClientSubnet + Add-DnsServerQueryResolutionPolicy + Add-DnsServerRecursionScope + Add-DnsServerZoneScope + Add-DnsServerZoneTransferPolicy + Disable-DnsServerPolicy + Enable-DnsServerPolicy + Get-DnsServerClientSubnet + Get-DnsServerQueryResolutionPolicy + Get-DnsServerRecursionScope + Get-DnsServerZoneScope + Get-DnsServerZoneTransferPolicy + Remove-DnsServerClientSubnet + Remove-DnsServerQueryResolutionPolicy + Remove-DnsServerRecursionScope + Remove-DnsServerZoneScope + Remove-DnsServerZoneTransferPolicy + Set-DnsServerClientSubnet + Set-DnsServerQueryResolutionPolicy + Set-DnsServerRecursionScope + Set-DnsServerZoneTransferPolicy | |||
EventTracingManagement | 14 | 14 | 0 |
+ Add-EtwTraceProvider + Get-AutologgerConfig + Get-EtwTraceProvider + Get-EtwTraceSession + New-AutologgerConfig + New-EtwTraceSession + Remove-AutologgerConfig + Remove-EtwTraceProvider + Remove-EtwTraceSession + Send-EtwTraceSession + Set-AutologgerConfig + Set-EtwTraceProvider + Set-EtwTraceSession + Start-AutologgerConfig | |||
FailoverClusters | 2 | 84 | 82 |
+ New-ClusterNameAccount + Update-ClusterFunctionalLevel | |||
GroupPolicy | 0 | 29 | 29 |
HgsClient | 11 | 11 | 0 |
+ Export-HgsGuardian + Get-HgsAttestationBaselinePolicy + Get-HgsClientConfiguration + Get-HgsGuardian + Grant-HgsKeyProtectorAccess + Import-HgsGuardian + New-HgsGuardian + New-HgsKeyProtector + Remove-HgsGuardian + Revoke-HgsKeyProtectorAccess + Set-HgsClientConfiguration | |||
Hyper-V | 26 | 204 | 178 |
+ Add-VMGroupMember + Add-VMSwitchTeamMember + Add-VMTPM + Disable-VMConsoleSupport + Enable-VMConsoleSupport + Get-VHDSet + Get-VHDSnapshot + Get-VMGroup + Get-VMHostCluster + Get-VMSwitchTeam + Get-VMTPM + Get-VMVideo + New-VMGroup + Optimize-VHDSet + Remove-VHDSnapshot + Remove-VMGroup + Remove-VMGroupMember + Remove-VMSwitchTeamMember + Rename-VMGroup + Set-VMHostCluster + Set-VMSwitchTeam + Set-VMTPM + Set-VMVideo + Start-VMTrace + Stop-VMTrace + Update-VMVersion | |||
IISAdministration | 17 | 17 | 0 |
+ Get-IISAppPool + Get-IISConfigCollectionItem + Get-IISConfigElement + Get-IISConfigSection + Get-IISConfigValue + Get-IISServerManager + Get-IISSite + New-IISConfigCollectionItem + New-IISSite + Remove-IISConfigCollectionItem + Remove-IISSite + Reset-IISServerManager + Set-IISConfigValue + Start-IISCommitDelay + Start-IISSite + Stop-IISCommitDelay + Stop-IISSite | |||
International | 0 | 18 | 18 |
iSCSI | 0 | 13 | 13 |
IscsiTarget | 0 | 28 | 28 |
ISE | 0 | 3 | 3 |
Kds | 0 | 6 | 6 |
Microsoft.PowerShell.Archive | 2 | 2 | 0 |
+ Compress-Archive + Expand-Archive | |||
Microsoft.PowerShell.Core | 5 | 60 | 55 |
+ Debug-Job + Enter-PSHostProcess + Exit-PSHostProcess + Get-PSHostProcessInfo + Register-ArgumentCompleter | |||
Microsoft.PowerShell.Diagnostics | 0 | 5 | 5 |
Microsoft.PowerShell.Host | 0 | 2 | 2 |
Microsoft.PowerShell.Management | 4 | 86 | 82 |
+ Clear-RecycleBin + Get-Clipboard + Get-ItemPropertyValue + Set-Clipboard | |||
Microsoft.PowerShell.ODataUtils | 1 | 1 | 0 |
+ Export-ODataEndpointProxy | |||
Microsoft.PowerShell.Security | 0 | 13 | 13 |
Microsoft.PowerShell.Utility | 11 | 105 | 94 |
+ ConvertFrom-String + Convert-String + Debug-Runspace + Disable-RunspaceDebug + Enable-RunspaceDebug + Format-Hex + Get-Runspace + Get-RunspaceDebug - GetStreamHash + New-Guid + New-TemporaryFile + Wait-Debugger + Write-Information | |||
Microsoft.WSMan.Management | 0 | 13 | 13 |
MMAgent | 0 | 5 | 5 |
MsDtc | 0 | 41 | 41 |
NetAdapter | 4 | 68 | 64 |
+ Disable-NetAdapterPacketDirect + Enable-NetAdapterPacketDirect + Get-NetAdapterPacketDirect + Set-NetAdapterPacketDirect | |||
NetConnection | 0 | 2 | 2 |
NetEventPacketCapture | 0 | 23 | 23 |
NetLbfo | 0 | 13 | 13 |
NetNat | 0 | 13 | 13 |
NetQos | 0 | 4 | 4 |
NetSecurity | 0 | 85 | 85 |
NetSwitchTeam | 0 | 7 | 7 |
NetTCPIP | 0 | 34 | 34 |
NetWNV | 0 | 19 | 19 |
NetworkConnectivityStatus | 0 | 4 | 4 |
NetworkController | 141 | 141 | 0 |
+ Add-NetworkControllerNode + Clear-NetworkControllerNodeContent + Disable-NetworkControllerNode + Enable-NetworkControllerNode + Export-NetworkController + Get-NetworkController + Get-NetworkControllerCanaryConfiguration + Get-NetworkControllerCluster + Get-NetworkControllerCredential + Get-NetworkControllerDevice + Get-NetworkControllerDeviceGroupingTestConfiguration + Get-NetworkControllerDeviceGroups + Get-NetworkControllerDeviceGroupUsage + Get-NetworkControllerDeviceUsage + Get-NetworkControllerDiagnostic + Get-NetworkControllerDiscoveredTopology + Get-NetworkControllerExternalTestRule + Get-NetworkControllerFabricRoute + Get-NetworkControllerGoalTopology + Get-NetworkControllerInterface + Get-NetworkControllerInterfaceUsage + Get-NetworkControllerIpPool + Get-NetworkControllerIpPoolStatistics + Get-NetworkControllerIpSubnetStatistics + Get-NetworkControllerLogicalNetwork + Get-NetworkControllerLogicalSubnet + Get-NetworkControllerMonitoringService + Get-NetworkControllerNode + Get-NetworkControllerPhysicalHostInterfaceParameter + Get-NetworkControllerPhysicalHostParameter + Get-NetworkControllerPhysicalSwitchCpuUtilizationParameter + Get-NetworkControllerPhysicalSwitchInterfaceParameter + Get-NetworkControllerPhysicalSwitchMemoryUtilizationParameter + Get-NetworkControllerPhysicalSwitchParameter + Get-NetworkControllerPSwitch + Get-NetworkControllerPublicIpAddress + Get-NetworkControllerServer + Get-NetworkControllerServerInterface + Get-NetworkControllerSwitchBgpPeer + Get-NetworkControllerSwitchBgpRouter + Get-NetworkControllerSwitchConfig + Get-NetworkControllerSwitchNetworkRoute + Get-NetworkControllerSwitchPort + Get-NetworkControllerSwitchPortChannel + Get-NetworkControllerSwitchVlan + Get-NetworkControllerTopologyConfiguration + Get-NetworkControllerTopologyDiscoveryStatistics + Get-NetworkControllerTopologyLink + Get-NetworkControllerTopologyNode + Get-NetworkControllerTopologyTerminationPoint + Get-NetworkControllerTopologyValidationReport + Get-NetworkControllerVirtualInterface + Get-NetworkControllerVirtualNetworkUsage + Get-NetworkControllerVirtualPort + Get-NetworkControllerVirtualServer + Get-NetworkControllerVirtualServerInterface + Get-NetworkControllerVirtualSwitch + Get-NetworkControllerVirtualSwitchPortParameter + Import-NetworkController + Install-NetworkController + Install-NetworkControllerCluster + New-NetworkControllerCanaryConfiguration + New-NetworkControllerCredential + New-NetworkControllerDevice + New-NetworkControllerDeviceGroupingTestConfiguration + New-NetworkControllerDeviceGroups + New-NetworkControllerExternalTestRule + New-NetworkControllerInterface + New-NetworkControllerIpPool + New-NetworkControllerLogicalNetwork + New-NetworkControllerMonitoringService + New-NetworkControllerNodeObject + New-NetworkControllerPhysicalHostInterfaceParameter + New-NetworkControllerPhysicalHostParameter + New-NetworkControllerPhysicalSwitchCpuUtilizationParameter + New-NetworkControllerPhysicalSwitchInterfaceParameter + New-NetworkControllerPhysicalSwitchMemoryUtilizationParameter + New-NetworkControllerPhysicalSwitchParameter + New-NetworkControllerPSwitch + New-NetworkControllerPublicIpAddress + New-NetworkControllerServer + New-NetworkControllerServerInterface + New-NetworkControllerSwitchBgpPeer + New-NetworkControllerSwitchBgpRouter + New-NetworkControllerSwitchNetworkRoute + New-NetworkControllerSwitchPortChannel + New-NetworkControllerSwitchVlan + New-NetworkControllerTopologyLink + New-NetworkControllerTopologyNode + New-NetworkControllerTopologyTerminationPoint + New-NetworkControllerVirtualInterface + New-NetworkControllerVirtualPort + New-NetworkControllerVirtualServer + New-NetworkControllerVirtualServerInterface + New-NetworkControllerVirtualSwitch + New-NetworkControllerVirtualSwitchPortParameter + Remove-NetworkControllerCanaryConfiguration + Remove-NetworkControllerCredential + Remove-NetworkControllerDevice + Remove-NetworkControllerDeviceGroupingTestConfiguration + Remove-NetworkControllerDeviceGroups + Remove-NetworkControllerExternalTestRule + Remove-NetworkControllerFabricRoute + Remove-NetworkControllerInterface + Remove-NetworkControllerIpPool + Remove-NetworkControllerLogicalNetwork + Remove-NetworkControllerLogicalSubnet + Remove-NetworkControllerNode + Remove-NetworkControllerPhysicalSwitchCpuUtilizationParameter + Remove-NetworkControllerPhysicalSwitchMemoryUtilizationParameter + Remove-NetworkControllerPSwitch + Remove-NetworkControllerPublicIpAddress + Remove-NetworkControllerServer + Remove-NetworkControllerServerInterface + Remove-NetworkControllerSwitchBgpPeer + Remove-NetworkControllerSwitchBgpRouter + Remove-NetworkControllerSwitchNetworkRoute + Remove-NetworkControllerSwitchPortChannel + Remove-NetworkControllerSwitchVlan + Remove-NetworkControllerTopologyLink + Remove-NetworkControllerTopologyNode + Remove-NetworkControllerTopologyTerminationPoint + Remove-NetworkControllerVirtualInterface + Remove-NetworkControllerVirtualPort + Remove-NetworkControllerVirtualServer + Remove-NetworkControllerVirtualServerInterface + Remove-NetworkControllerVirtualSwitch + Repair-NetworkControllerCluster + Set-NetworkController + Set-NetworkControllerCluster + Set-NetworkControllerDiagnostic + Set-NetworkControllerFabricRoute + Set-NetworkControllerGoalTopology + Set-NetworkControllerLogicalSubnet + Set-NetworkControllerNode + Set-NetworkControllerSwitchConfig + Set-NetworkControllerSwitchPort + Set-NetworkControllerTopologyConfiguration + Start-NetworkControllerTopologyDiscovery + Uninstall-NetworkController + Uninstall-NetworkControllerCluster | |||
NetworkLoadBalancingClusters | 0 | 35 | 35 |
NetworkSwitchManager | 19 | 19 | 0 |
+ Disable-NetworkSwitchEthernetPort + Disable-NetworkSwitchFeature + Disable-NetworkSwitchVlan + Enable-NetworkSwitchEthernetPort + Enable-NetworkSwitchFeature + Enable-NetworkSwitchVlan + Get-NetworkSwitchEthernetPort + Get-NetworkSwitchFeature + Get-NetworkSwitchGlobalData + Get-NetworkSwitchVlan + New-NetworkSwitchVlan + Remove-NetworkSwitchEthernetPortIPAddress + Remove-NetworkSwitchVlan + Restore-NetworkSwitchConfiguration + Save-NetworkSwitchConfiguration + Set-NetworkSwitchEthernetPortIPAddress + Set-NetworkSwitchPortMode + Set-NetworkSwitchPortProperty + Set-NetworkSwitchVlanProperty | |||
NetworkTransition | 0 | 34 | 34 |
NFS | 0 | 42 | 42 |
Nps | -6 | 7 | 13 |
- Get-NpsRemediationServer - Get-NpsRemediationServerGroup - New-NpsRemediationServer - New-NpsRemediationServerGroup - Remove-NpsRemediationServer - Remove-NpsRemediationServerGroup | |||
PackageManagement | 10 | 10 | 0 |
+ Find-Package + Get-Package + Get-PackageProvider + Get-PackageSource + Install-Package + Register-PackageSource + Save-Package + Set-PackageSource + Uninstall-Package + Unregister-PackageSource | |||
PcsvDevice | 4 | 9 | 5 |
+ Clear-PcsvDeviceLog + Get-PcsvDeviceLog + Set-PcsvDeviceNetworkConfiguration + Set-PcsvDeviceUserPassword | |||
Pester | 20 | 20 | 0 |
+ AfterAll + AfterEach + Assert-MockCalled + Assert-VerifiableMocks + BeforeAll + BeforeEach + Context + Describe + Get-MockDynamicParameters + Get-TestDriveItem + In + InModuleScope + Invoke-Mock + Invoke-Pester + It + Mock + New-Fixture + Set-DynamicParameterVariables + Setup + Should | |||
PKI | 0 | 17 | 17 |
PnpDevice | 4 | 4 | 0 |
+ Disable-PnpDevice + Enable-PnpDevice + Get-PnpDevice + Get-PnpDeviceProperty | |||
PowerShellGet | 11 | 11 | 0 |
+ Find-Module + Get-InstalledModule + Get-PSRepository + Install-Module + Publish-Module + Register-PSRepository + Save-Module + Set-PSRepository + Uninstall-Module + Unregister-PSRepository + Update-Module | |||
PrintManagement | 0 | 22 | 22 |
PSDesiredStateConfiguration | 5 | 17 | 12 |
+ Connect-DscConfiguration + Find-DscResource + Get-DscConfigurationStatus + Invoke-DscResource + Publish-DscConfiguration | |||
PSDiagnostics | 0 | 10 | 10 |
PSReadline | 5 | 5 | 0 |
+ Get-PSReadlineKeyHandler + Get-PSReadlineOption + Remove-PSReadlineKeyHandler + Set-PSReadlineKeyHandler + Set-PSReadlineOption | |||
PSScheduledJob | 0 | 16 | 16 |
PSWorkflow | 0 | 2 | 2 |
PSWorkflowUtility | 0 | 1 | 1 |
RemoteAccess | 14 | 121 | 107 |
+ Add-BgpRouteAggregate + Add-VpnSstpProxyRule + Clear-BgpRouteFlapDampening + Disable-BgpRouteFlapDampening + Enable-BgpRouteFlapDampening + Get-BgpRouteAggregate + Get-BgpRouteFlapDampening + Get-VpnSstpProxyRule + New-VpnSstpProxyRule + Remove-BgpRouteAggregate + Remove-VpnSstpProxyRule + Set-BgpRouteAggregate + Set-BgpRouteFlapDampening + Set-VpnSstpProxyRule | |||
RemoteDesktop | 5 | 78 | 73 |
+ Export-RDPersonalSessionDesktopAssignment + Get-RDPersonalSessionDesktopAssignment + Import-RDPersonalSessionDesktopAssignment + Remove-RDPersonalSessionDesktopAssignment + Set-RDPersonalSessionDesktopAssignment | |||
ScheduledTasks | 0 | 19 | 19 |
SecureBoot | 0 | 5 | 5 |
ServerCore | 0 | 2 | 2 |
ServerManager | 0 | 7 | 7 |
ServerManagerTasks | 0 | 11 | 11 |
ShieldedVMDataFile | 3 | 3 | 0 |
+ Import-ShieldingDataFile + New-VolumeIDQualifier + Protect-ShieldingDataFile | |||
ShieldedVMTemplate | 1 | 1 | 0 |
+ Protect-ServerVHDX | |||
SmbShare | 0 | 35 | 35 |
SmbWitness | 0 | 3 | 3 |
SoftwareInventoryLogging | 0 | 11 | 11 |
StartScreen | 0 | 3 | 3 |
Storage | 32 | 140 | 108 |
+ Block-FileShareAccess + Clear-StorageDiagnosticInfo + Debug-FileShare + Debug-StorageSubSystem + Disable-PhysicalDiskIdentification + Disable-StorageDiagnosticLog + Enable-PhysicalDiskIdentification + Enable-StorageDiagnosticLog + Get-DedupProperties + Get-DiskSNV + Get-DiskStorageNodeView + Get-FileShare + Get-FileShareAccessControlEntry + Get-StorageAdvancedProperty + Get-StorageDiagnosticInfo + Get-StorageEnclosureSNV + Get-StorageEnclosureStorageNodeView + Get-StorageFaultDomain + Get-StorageFileServer + Grant-FileShareAccess + New-FileShare + New-StorageFileServer + Optimize-StoragePool + Remove-FileShare + Remove-StorageFileServer + Revoke-FileShareAccess + Set-FileShare + Set-StorageFileServer + Start-StorageDiagnosticLog + Stop-StorageDiagnosticLog + Stop-StorageJob + Unblock-FileShareAccess | |||
StorageQoS | 6 | 6 | 0 |
+ Get-StorageQoSFlow + Get-StorageQoSPolicy + Get-StorageQoSVolume + New-StorageQoSPolicy + Remove-StorageQoSPolicy + Set-StorageQoSPolicy | |||
StorageReplica | 11 | 11 | 0 |
+ Get-SRGroup + Get-SRPartnership + New-SRGroup + New-SRPartnership + Remove-SRGroup + Remove-SRPartnership + Set-SRGroup + Set-SRPartnership + Suspend-SRGroup + Sync-SRGroup + Test-SRTopology | |||
TLS | 3 | 7 | 4 |
+ Disable-TlsCipherSuite + Enable-TlsCipherSuite + Get-TlsCipherSuite | |||
TroubleshootingPack | 0 | 2 | 2 |
TrustedPlatformModule | 0 | 11 | 11 |
UpdateServices | 4 | 16 | 12 |
+ Add-WsusDynamicCategory + Get-WsusDynamicCategory + Remove-WsusDynamicCategory + Set-WsusDynamicCategory | |||
UserAccessLogging | 0 | 14 | 14 |
VpnClient | 0 | 19 | 19 |
Wdac | 0 | 12 | 12 |
WebAdministration | 0 | 80 | 80 |
Whea | 0 | 2 | 2 |
WindowsDeveloperLicense | 0 | 3 | 3 |
WindowsErrorReporting | 0 | 3 | 3 |
WindowsSearch | 0 | 2 | 2 |
5. Share the code
For those wondering about the script I used to compile the results, here it goes.
#
# Enumerating all the modules from both OS versions
#
# Load XML files into memory: $Files[0] and $Files[1]
$Files= ( (Import-Clixml"C:\WS2012R2Cmdlets.XML"),
(Import-Clixml"C:\WS2016TP2Cmdlets.XML") )
# Create empty dictionary for modules
$ModuleDict= @{}
# Loop through the two files to gather module info
$Files|% {
$_|GroupModuleName|SortName|% {
$Module=$_.Name
# If found, increase count. If not, add to dictionary
If ($ModuleDict.ContainsKey($Module)) {
$ModuleDict.$Module++
} Else {
$ModuleDict.Add($Module,1)
} # End If
} # End Import
} # End $Files
#
# Enumerate the cmdlets in every module
#
# Add the HTML table header
Write-Host"<table border=1><tr><td><b>Module</b></td><td>New Cmdlets</td><td>WS 2016 TP2</td><td>WS 2012 R2</td></tr>"
# Loop through the modules in the dictionary
$ModuleDict.GetEnumerator() |SortName|% {
# Initialize variables for a new module
$Module=$_.Name
$VersionCount= (0,0)
$CmdletDict= @{}
# Loop through the two files, filtering by module
0..1|% {
$WSVersion=$_
$Files[$_]|?ModuleName-eq$Module|% {
$Cmdlet=$_.Name
# Count cmdlets by module for each OS version
$VersionCount[$WSVersion]++
# Increase per-cmdlet value by 1 (WS2012R2) or by 2 (WS2016TP2)
# If cmdlet exists in both OSes, value will be 3
If ($CmdletDict.ContainsKey($Cmdlet)) {
$CmdletDict.$Cmdlet+= ($WSVersion+1)
} Else {
$CmdletDict.Add($Cmdlet, ($WSVersion+1))
} # End If
} # End %
} # End 0..1
#
# Output the list of cmdlets that changed in every module
#
# Copy data to single variables for easy use with Write-Host
$WS0=$VersionCount[0]
$WS1=$VersionCount[1]
$Dif=$WS1-$WS0
$CrLf="<BR>"+[char]10+[char]13
# Write HTML table row with module summary information
Write-Host"<tr><td><b>$Module</b></td><td align=`"right`">$Dif</td><td align=`"right`">$WS1</td><td align=`"right`">$WS0</td></tr>"
# If there are cmdlets in the module
If ($CmdletDict.Count -gt0) {
# Gather all new and removed cmdlets in a variable
$CmdletList=""
$CmdletDict.GetEnumerator() |? {$_.Value -eq2-or$_.Value -eq1} |SortName|% {
# 1 means removed cmdlet. 2 means new cmdlet
$Name=$_.Name
If ($_.Value -eq1) {
$CmdletList+="- $Name"+$CrLf
} else {
$CmdletList+="+ $Name"+$CrLf
} # End If
} # End Enumerator
# If new or removed exist, write another HTML table row
If ($CmdletList-ne"") {
Write-Host"<tr><td colspan=4>$CmdletList</td></tr>"
} # End If
} # End if
} # End Module
# Write HTML table end. All done.
Write-Host"</table>"