Wednesday, June 24, 2015

Powershell Oneliner Contest 2015 - Win a Hyper-V book

I have always enjoyed taking part in most of the Powershell contests out there since Powershell is kind of a recreational administration language to me. I am thinking, for example, of the fun I had taking part in the oneliner contest (which I won) organized by fellow MVP Mike F Robbins, or of the Powershell Golf organized in 2013 by Robert Robelo on Twitter.
 
THE IDEAS BEHIND THE CONTEST
 
Being quite proud of my blog, and despite the fact that I am more of a system administrator than a developer, I have unilaterally decided to organize my self-hosted, self-managed Powershell Oneliner Contest.
 

The three ideas behind this game are that:
  1. experienced competitors (and I, of course!) should come away with a lot of tips from the brightest Powershell minds that will hopefully take part in the event
  2. novice Powershell scripters should learn that persistence pays off when looking for a solution to such a contest
  3. this is a fairly good occasion to sharpen your skills for the soon-to-start Powershell Scripting Games held by the Powershell.org community
GENERAL RULES
 
  • The contest is split into three tasks. Each task consists of a simple scenario for which you have to produce a oneliner solution.
  • Submit your solutions via a comment to this blog article by 11AM (PDT) on Wednesday, July 1st, which is the deadline.
  • You MUST submit only one task solution per comment, so that I can easily see who was the first to submit the shortest solution on a per-task basis.
  • Should you find a shorter oneliner to solve a task you are allowed to post additional comments (just remember to sign your comments so that I know who's who).
  • Aliases are of course accepted
  • Backticks accepted for readability
  • No semi-colons
  • UPDATE - No Here-String
  • UPDATE - Please don't sign your comments as Unknown or I won't be able to know who you are.
  • If you use a Powershell version other than v4, I am okay with it, but please mention it in the comment so that I can test it on the same version. Powershell v5 is welcome.
  • Entries (comments) will not be made public until after the submission deadline.

SCORING
  • The shortest solution in terms of chars wins.
  • The first person to produce the shortest working solutions to a task will get 1 point, the second 2 points, the third 3 points and so on.
  • The person with the lowest total score over the three mandatory tasks will be the winner.
  • The winner will be announced on Saturday, July 4th on this blog and the prize will be awarded at that time.
  • I'll be the only judge.

THE PRIZE
 
What? Is there a prize? Yes, of course. The prize will be a printed copy of the excellent book 'Hyper-V Best Practices' (5-Stars on amazon.com) by fellow MVP Benedict Berger  (@Benedict_Berger) offered by Packt Publishing!!!
I was the reviewer of the book as well of the ton of Powershell code it contains. I can tell you this is the book to read in these Hyper-V times!


As a bonus, and if the winner agrees, he/she will intervene as a guest blogger on this blog and will explain how one goes about learning the hidden bits of Windows Powershell. Sounds cool, doesn't it?

Let's now dive into the contest tasks.
 
TASK 1 - Who's taller?
 
This is a rather easy challenge and I hope it will make for a good warm-up session for your Powershell muscles, especially if you are a beginner. Given a $n variable showed below, write the shortest possible oneliner that outputs the absolute value of the largest double-precision floating-point number in the array.
$n = -1,-2,-5,-8.9,'b',-9.11,-6,-3,-2,-9.1,-1,-1.4,'a'

Expected output
Task-specific rules
  • The object in the output can be of any type
  • UPDATE - The one-liner must work also with different values of $n

TASK 2 - Can you count to five?

Time to delve into something harder. Write the shortest possible Powershell oneliner that outputs the number 12345.

Expected output
 
Task-specific rules
  • You are not allowed to use the digits 0 to 9 in your oneliner
  • The object in the output must be of type Int32
  • Your displayed output shouldn't contain any other char

TASK 3 - Powershell is the secret word

I hope that by this time you are enjoying the competition. It's time for the last hard task. Write the shortest possible Powershell oneliner that outputs the word 'PowerShell' starting from a text string composed only of uppercase Xs' and whitespaces.

Expected output
Task-specific rules
  • The string composed of X's and whitespaces must be part of the oneliner (backticks accepted!) and not be a variable defined on a separate line
  • You can use as many X's and empty spaces you like or need
  • P and S in the output must be uppercase
  • UPDATE - No Here-String
  • UPDATE - I consider jokes answers like "X "|%{"Powershell"}
On your marks, set, go! And remember to have fun, it's just a game meant to produce something useful for the growing and growing Powershell community!

UPDATE - Check-Task Function

I have decided to update this blog post with a function that will allow you to check if your proposed solutions are correct in terms of output and respect the task assignments. Kudos for this function go to my friend Joey!

function Check-Task ([int] $Task, [scriptblock] $Command) {
        $n = -1,-2,-5,-8.9,'b',-9.11,-6,-3,-2,-9.1,-1,-1.4,'a'
        $result = & $command
        $check = $false
        switch ($Task) {
            1 { $check = $result -eq '1.4' -or 
                [double]::Parse("$result") -eq 1.4 }
            2 {
                $check = ($result -is [int] -and $result -eq 12345) -and
                    ("$Command" -notmatch '[0-9]')
              }
            3 {
                $check = ($result -is [string] -and $result -ceq 'PowerShell') -and
                    ("$Command" -match '([''"])[X`\s]+\1')
            }
        }
        if (!$check) {
            Write-Host -Fore Yellow "Expected: $((1.4,12345,'PowerShell')[$Task - 1])"
            Write-Host -Fore Red    "Actual:  $result"
        }
        $color = ('Red','Green')[$check]
        Write-Host -Fore $color ('{0,4}: {1}' -f "$Command".Trim().Length,$command)
    }
Sample usage:
Check-Task 1 { $n.gettype() }
Do not hesitate to test your solutions before posting them to my blog! Better safe than sorry.

SPREAD THE WORD

If you want to give some visibility to this contest, feel free to twit about it. You can use the hashtags #poshcontest2015 and #powershell so that other competitors can share their thoughts (not the solutions of course!).

Thanks again to Packt Publishing (and to Mary in particular) for sponsoring this event!

UPDATEClick here to find the winner's name and his solutions!

Tuesday, June 2, 2015

Copy-Item improvements to support file copy over WinRM to NanoServers

If you follow this blog (you should!), then you know that I have just published a post on the procedure to install a Microsoft NanoServer.

If you read through the whole post, you know that this small footprint operating system is supposed to be managed through Powershell Remoting since it has no local logon capabilities.

Now, if you look well into the new cmdlets/parameters that come with the Windows Management Framework 5 (the one that comes with Windows 2016 TP2), you'll see that Copy-Item now supports file copy operations through WinRM.

The new key parameters are -ToSession and -FromSession.

Let's see with an example how they shoud be used., even do they are pretty self-explanatory.
 
First of all open a remoting session to the NanoServer:

$session = New-PSSession -ComputerName 192.168.1.5 -Credential administrator
Then, to copy any file to the NanoServer over WinRM, just use the following syntax:

Copy-Item -ToSession $session -Path .\samplescript.ps1 -Destination c:\temp\
The operation can be performed both directions, so to retrieve a file just use:

Copy-Item -FromSession $session -Path c:\results.txt -Destination .
If you liked this post, please share!

How to build your first fantastic Nano Server

As it has been announced in recent events such as Ignite, Microsoft is working hard for the introduction of Nano Server, a cloud-oriented, GUI-less, small-everything, Powershell-managed version of Windows Server. This server version comes with no logon capability, which means that management tasks are performed remotely, from the very first logon. And, since the system is built to be extremely light, we can suppose that it will be blatantly fast for the specific workloads that come from the devops/virtualization/containerization world.
 
NanoServer goes even further than Server Core in terms of lightness
Sounds good, you say. But how to test it? Well, today Nano Server is part of Windows 2016 Technical Preview 2, which has been announced less than a month ago and that I have had the occasion to test in one of my labs. It was a tricky job that I am going to detail as long as the issues I faced during the deployment.
 
STEP 1: PREPARE THE VHD

The starting point is the NanoServer folder stored in the Windows 2016 TP2 iso:


The folder size is a mere 181 MB, and it contains a .wim file as well as the following six file cabinets:

Directory: H:\NanoServer\Packages

Mode            LastWriteTime     Length Name
----            -------------     ------ ----
--r--    09/05/2015     03:01   10849819 Microsoft-NanoServer-Compute-Package.cab
--r--    09/05/2015     03:01    7690908 Microsoft-NanoServer-FailoverCluster-Package.cab
--r--    09/05/2015     03:01     327347 Microsoft-NanoServer-Guest-Package.cab
--r--    09/05/2015     03:01   12785830 Microsoft-NanoServer-OEM-Drivers-Package.cab
--r--    09/05/2015     03:01    6900267 Microsoft-NanoServer-Storage-Package.cab
--r--    09/05/2015     03:01      49656 Microsoft-OneCore-ReverseForwarders-Package.cab
Let's begin with building the source repository by copying the whole content of this folder:

Copy-Item H:\NanoServer\* D:\nanoserver -Recurse
Then we have to convert the WIM file contained in the Windows iso file to a VHD that we can mount in Hyper-V. This is easily achieved with the Powershell script that Pronichkin developed and that you can download from here.

Put the script in the same repository you created above:

Set-Location D:\NanoServer

.\Convert-WindowsImage.ps1 -WIM .\NanoServer.wim -VHD .\NanoServer.vhd -DiskType Fixed -VHDFormat VHD -SizeBytes 1GB -Edition 1

Windows(R) Image to Virtual Hard Disk Converter for Windows(R) 8
Copyright (C) Microsoft Corporation.  All rights reserved.
Version 6.3.9600.7.amd64fre.fbl_core1_hyp_dev(mikekol).140217-3000 Release to Web

INFO   : Image 1 selected ()...
INFO   : Creating fixed disk...
INFO   : Attaching VHD...
INFO   : Disk initialized with MBR...
INFO   : Disk partitioned...
INFO   : Volume formatted...
INFO   : Access path (D:\) has been assigned...
INFO   : Applying image to VHD. This could take a while...
INFO   : Signing disk...
INFO   : Image applied. Making image bootable...
INFO   : Fixing the Device ID in the BCD store on VHD...
INFO   : Drive is bootable. Cleaning up...
INFO   : Closing VHD...
INFO   : Closing Windows image...
INFO   : Done.
As you can see, I created a 1GB disk, and this is enough for a test environment.

STEP 2: ADD PACKAGES

Next we need to stream in some dlls and packages into the VHD.

New-Item Dism -ItemType Directory
Set-Location Dism
Copy-Item H:\Sources\api*downlevel*.dll
Copy-Item H:\Sources\*dism*
Copy-Item H:\Sources\*provider*
This will copy 30 files in your Dism folder. 
Preparing the vhd...
Now mount the image:

Mount-DiskImage D:\NanoServer\NanoServer.vhd
In my case it got mounted as G:

Then to add the packages I mentioned before (the ones under H:\NanoServer\Packages), you can leverage the Add-WindowsPackage cmdlet:

ISSUE 1: LOW LEVEL DISM AGAINST LEVEL UP IMAGE

In my case I encountered an issue with this action when I performed it on my Windows 2012 R2 server:

Add-WindowsPackage -Path G: -PackagePath *.cab
Add-WindowsPackage : To service this Windows image requires the latest version of the DISM. See http://go.microsoft.com/fwlink/?LinkId=293395 to find the latest version of DISM, 
and http://go.microsoft.com/fwlink/?LinkId=293394 to learn how to install the latest version of DISM from the ADK on your computer.
At line:1 char:1
+ Add-WindowsPackage -Path G: -PackagePath *.cab
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-WindowsPackage], COMException
    + FullyQualifiedErrorId : Microsoft.Dism.Commands.AddWindowsPackageCommand
In the DISM log I found the following error:

DISM Manager: PID=3092 TID=4604 It is an unsupported scenario to service an up level image using low level dism. - CDISMManager::CreateImageSessionFromLocation(hr:0x80070032)

I checked the version of the DISM cmdlets on Windows 2012 R2:

Add-WindowsPackage -Path G: -PackagePath .\Microsoft-NanoServer-Compute-Package.cab -Verbose
VERBOSE: Dism PowerShell Cmdlets Version 6.3.0.0
On Windows 10 Insider Preview we have version 10:

VERBOSE: Dism PowerShell Cmdlets Version 10.0.0.0
I tried to solve this by downloading the Windows Assessment and Deployment Kit (Windows ADK) for Windows 8.1 Update which I found here.

For your information, the adksetup.exe must be run from c:\ as an administrator otherwise it will fail with such an error:

Could not acquire privileges; GLE=0x514
Returning status 0x514

In any case it kept not working on Windows 2012 R2.

SOLUTION TO ISSUE 1: USE WINDOWS 10 DISM

The known workaround is to use DISM from either Windows 10 or Windows Server 2016 Technical Preview 2 machine. In my case I luckily had a freshly installed Windows 10 CTP2 sitting there in a VM. I just copied the vhd over there, enable the administrator account, which is needed to be able to mount the vhd file, through the command

net user administrator /active:yes

On Windows 10, Add-WindowsPackage worked flawlessly (apart for the drivers package which took much longer):
Add-WindowsPackage –Path G:\ –PackagePath C:\NanoServer\Packages\Microsoft-NanoServer-Compute-Package.cab
Add-WindowsPackage –Path G:\ –PackagePath C:\NanoServer\Packages\Microsoft-NanoServer-FailoverCluster-Package.cab
Add-WindowsPackage –Path G:\ –PackagePath C:\NanoServer\Packages\Microsoft-NanoServer-Guest-Package.cab
Add-WindowsPackage –Path G:\ –PackagePath C:\NanoServer\Packages\Microsoft-NanoServer-OEM-Drivers-Package.cab
Add-WindowsPackage –Path G:\ –PackagePath C:\NanoServer\Packages\Microsoft-NanoServer-Storage-Package.cab
Add-WindowsPackage –Path G:\ –PackagePath C:\NanoServer\Packages\Microsoft-OneCore-ReverseForwarders-Package.cab

Add-WindowsPackage in action on my Windows 10 Enterprise Insider Preview

Once all the packages are added, I dismounted the vhd image.

Dismount-DiskImage -ImagePath C:\Nanoserver\NanoServer.vhd
The vhd file is now ready.

STEP 3: CREATE A HYPER-V VIRTUAL MACHINE

One I copied the vhd back to my Windows 2012 R2 test bed I created the VM descriptors with Powershell:

New-VM -Name 'NanoServer1' -Generation 1 -MemoryStartupBytes 512MB -SwitchName LAN -Path 'N:\Hyper-V Virtual Machines\Virtual Machines\' -NoVHD
Copy-Item 'D:\NanoServer\NanoServer.vhd' -Destination 'N:\Hyper-V Virtual Machines\'
Get-VM 'NanoServer1' | Add-VMHardDiskDrive -Path 'N:\Hyper-V Virtual Machines\NanoServer.vhd'
Start-VM 'NanoServer1'
The machine booted, but the boot took almost twenty minutes. After a long wait a black screen with an underscore appeared. I didn't really expect something on the console to show, but I must admit I was unpleasantly surprised by the long boot up times.

BUG 1: LONG BOOT-UP TIME

After a long analysis and a bunch of re-deployments, I discovered that, even do the NanoServer virtual machines show the following screen, in reality they are already pingable and manageable:

Windows Nano Server is online well before the start-up is replaced by the black screen
Once Nano is up and running, the following screen appears:

The famous black screen with un underscore of a Windows NanoServer
As you can see it differs from the welcome screen of a standard Windows 2016 Technical Preview 2 installation in the fact that it lacks logon capabilities:

Windows 2016 logon screen
At this point you can connect to it remotely using PowerShell Remoting.

STEP 4: REMOTING INTO A NANOSERVER
 
From a PowerShell prompt on a management PC, run the following two commands, replacing the IP address with the one of your Nano Server (you can check this on your local DHCP server list of leases):

Set-Item WSMan:\localhost\Client\TrustedHosts -Value 192.168.5 -Concatenate
Enter-PSSession -ComputerName 192.168.1.5 -Credential Administrator
The Set-Item cmdlet is used to add Nano server to the list of trusted hosts for Remoting.

Note that the administrator password is blank by default, so when Enter-PSSession asks for a password just hit Enter.

Once you are logged in, you can check the default name that a NanoServer is given, which is "miniwinpc".

[192.168.1.5]: PS C:\Users\Administrator\Documents> hostname
minwinpc
[192.168.1.5]: PS C:\Users\Administrator\Documents> ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : minwinpc
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Hybrid
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Hyper-V Network Adapter
   Physical Address. . . . . . . . . : 00-15-5D-01-64-03
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::b47c:4c39:433b:5628%4(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.1.5(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Monday, June 1, 2015 11:07:57 AM
   Lease Expires . . . . . . . . . . : Monday, June 1, 2015 11:07:57 PM
   Default Gateway . . . . . . . . . : 192.168.1.254
   DHCP Server . . . . . . . . . . . : 192.168.1.254
   DHCPv6 IAID . . . . . . . . . . . : 67114333
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-FE-57-D3-00-15-5D-01-64-03
   DNS Servers . . . . . . . . . . . : 192.168.1.254
   NetBIOS over Tcpip. . . . . . . . : Disabled

Tunnel adapter Local Area Connection* 2:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Failover Cluster Virtual Adapter
   Physical Address. . . . . . . . . : 02-92-9B-4B-EB-13
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
Here's the output of some other generic commands on a NanoServer:
[192.168.1.5]: PS C:\> ls


    Directory: C:\


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         5/6/2015  10:05 AM                EFI
d-----         5/6/2015  10:32 AM                Program Files
d-----         5/6/2015  10:05 AM                Program Files (x86)
d-r---         6/1/2015  12:40 PM                Users
d-----         6/1/2015  11:22 AM                Windows
-a----         6/1/2015   6:44 AM            300 Convert-WindowsImageInfo.txt
[192.168.1.5]: PS C:\> Get-Process

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
     94       6      596       1540 ...61     0.33    380 csrss
      0       0        0          4     0               0 Idle
    615      17     3160       9900 ...86     0.34    428 lsass
    243      10     2340       9140 ...81     0.34   1076 MsMpEng
    168       8     1452       4912 ...65     0.30    416 services
     44       3      280       1076 ...56     0.23    296 smss
    189       8     1396       5240 ...75     0.09    536 svchost
    223      12     1388       5484 ...75     0.06    576 svchost
    721      20    10732      20864 ...14     1.33    636 svchost
    354      14     3976      11628 ...26     0.13    692 svchost
    110       7     1136       5540 ...74     0.08    752 svchost
     93       6     1040       4552 ...71     0.00    768 svchost
    284      15     6972      11116 ...92     0.20    780 svchost
    209      14     2216       7180 ...80     0.00    884 svchost
    567      55     6152      15288 ...63     0.89    904 svchost
    263      26     3760       9264 ...86     0.23   1000 svchost
    329       0       76         80     2     4.16      4 System
     69       7      640       3476 ...63     0.05    404 wininit
    379      36    34160      54288 ...24     9.19   1544 wsmprovhost
[192.168.1.5]: PS C:\> gcim win32_operatingsystem | fl *


Status                                    : OK
Name                                      : Microsoft Windows Server Technical Preview 2
                                            Tuva|C:\Windows|\Device\Harddisk0\Partition1
FreePhysicalMemory                        : 3883052
FreeSpaceInPagingFiles                    : 233724
FreeVirtualMemory                         : 4188272
Caption                                   : Microsoft Windows Server Technical Preview 2 Tuva
Description                               :
InstallDate                               : 6/1/2015 11:07:56 AM
CreationClassName                         : Win32_OperatingSystem
CSCreationClassName                       : Win32_ComputerSystem
CSName                                    : MINWINPC
CurrentTimeZone                           : -420
Distributed                               : False
LastBootUpTime                            : 6/1/2015 11:07:46 AM
LocalDateTime                             : 6/1/2015 12:47:26 PM
MaxNumberOfProcesses                      : 4294967295
MaxProcessMemorySize                      : 137438953344
NumberOfLicensedUsers                     : 0
NumberOfProcesses                         : 20
NumberOfUsers                             : 0
OSType                                    : 18
OtherTypeDescription                      :
SizeStoredInPagingFiles                   : 233724
TotalSwapSpaceSize                        :
TotalVirtualMemorySize                    : 4427568
TotalVisibleMemorySize                    : 4193844
Version                                   : 10.0.10074
BootDevice                                : \Device\HarddiskVolume1
BuildNumber                               : 10074
BuildType                                 : Multiprocessor Free
CodeSet                                   : 1252
CountryCode                               : 1
CSDVersion                                :
DataExecutionPrevention_32BitApplications : True
DataExecutionPrevention_Available         : True
DataExecutionPrevention_Drivers           : True
DataExecutionPrevention_SupportPolicy     : 2
Debug                                     :
EncryptionLevel                           :
ForegroundApplicationBoost                :
LargeSystemCache                          :
Locale                                    : 0409
Manufacturer                              : Microsoft Corporation
MUILanguages                              : {en-US}
OperatingSystemSKU                        : 109
Organization                              : Microsoft
OSArchitecture                            : 64-bit
OSLanguage                                : 1033
OSProductSuite                            : 272
PAEEnabled                                :
PlusProductID                             :
PlusVersionNumber                         :
PortableOperatingSystem                   : False
Primary                                   : True
ProductType                               : 3
RegisteredUser                            : Microsoft
SerialNumber                              :
ServicePackMajorVersion                   : 0
ServicePackMinorVersion                   : 0
SuiteMask                                 : 272
SystemDevice                              : \Device\HarddiskVolume1
SystemDirectory                           : C:\Windows\system32
SystemDrive                               : C:
WindowsDirectory                          : C:\Windows
PSComputerName                            :
CimClass                                  : root/cimv2:Win32_OperatingSystem
CimInstanceProperties                     : {Caption, Description, InstallDate, Name...}
CimSystemProperties                       : Microsoft.Management.Infrastructure.CimSystemProperties
As a side note, notice that the good old Get-WMIObject (alias gwmi) is not implemented on NanoServer:

[192.168.1.5]: PS C:\>  Get-WmiObject win32_computersystem
The term 'Get-WmiObject' is not recognized as the name of a cmdlet, function, script file, or operable program. Checkhe the spelling of the name, or if a path was included, verify that the path is correct and try again.
    + CategoryInfo          : ObjectNotFound: (Get-WmiObject:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Concerning Powershell, version 5 of the WMF is installed, exactly like on a Windows 2016:

[192.168.1.5]: PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSRemotingProtocolVersion      2.3
CLRVersion                     4.0.30319.34011
WSManStackVersion              3.0
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.10074.0
PSVersion                      5.0.10074.0
SerializationVersion           1.1.0.1
STEP 5: COMPARE POWERSHELL MODULES OF NANOSERVE AND WINDOWS 2016 TP2
 
Now it would be interesting to compare Powershell capabilities in terms of accepted cmdlets on both Windows 2016 TP2 and Windows NanoServer.

Here's what you have on a Nano Server:

[192.168.1.5]: PS C:\> Get-Command | Select Name,Module | Group Module | Sort Count -Descending

Count Name                      Group
----- ----                      -----
  140 Storage                   {@{Name=Disable-PhysicalDiskIndication; Module=Storage}, @{Name=Disable-StorageDiagn...
   92                           {@{Name=A:; Module=}, @{Name=B:; Module=}, @{Name=C:; Module=}, @{Name=cd..; Module=...
   74 Microsoft.PowerShell.U... {@{Name=Add-Member; Module=Microsoft.PowerShell.Utility}, @{Name=Clear-Variable; Mod...
   68 NetAdapter                {@{Name=Disable-NetAdapter; Module=NetAdapter}, @{Name=Disable-NetAdapterBinding; Mo...
   43 Dism                      {@{Name=Add-ProvisionedAppxPackage; Module=Dism}, @{Name=Apply-WindowsUnattend; Modu...
   38 Microsoft.PowerShell.M... {@{Name=Add-Content; Module=Microsoft.PowerShell.Management}, @{Name=Clear-Content; ...
   35 SmbShare                  {@{Name=Block-SmbShareAccess; Module=SmbShare}, @{Name=Close-SmbOpenFile; Module=Smb...
   34 NetTCPIP                  {@{Name=Find-NetRoute; Module=NetTCPIP}, @{Name=Get-NetCompartment; Module=NetTCPIP}...
   23 NetEventPacketCapture     {@{Name=Add-NetEventNetworkAdapter; Module=NetEventPacketCapture}, @{Name=Add-NetEve...
   14 EventTracingManagement    {@{Name=Add-EtwTraceProvider; Module=EventTracingManagement}, @{Name=Get-AutologgerC...
   14 CimCmdlets                {@{Name=Export-BinaryMiLog; Module=CimCmdlets}, @{Name=Get-CimAssociatedInstance; Mo...
   13 Microsoft.WSMan.Manage... {@{Name=Connect-WSMan; Module=Microsoft.WSMan.Management}, @{Name=Disable-WSManCredS...
   11 Defender                  {@{Name=Add-MpPreference; Module=Defender}, @{Name=Get-MpComputerStatus; Module=Defe...
    9 PcsvDevice                {@{Name=Clear-PcsvDeviceLog; Module=PcsvDevice}, @{Name=Get-PcsvDevice; Module=PcsvD...
    6 StorageQoS                {@{Name=Get-StorageQoSFlow; Module=StorageQoS}, @{Name=Get-StorageQoSPolicy; Module=...
    5 Microsoft.PowerShell.S... {@{Name=Get-AuthenticodeSignature; Module=Microsoft.PowerShell.Security}, @{Name=Get...
    4 PnpDevice                 {@{Name=Disable-PnpDevice; Module=PnpDevice}, @{Name=Enable-PnpDevice; Module=PnpDev...
    3 SmbWitness                {@{Name=Move-SmbClient; Module=SmbWitness}, @{Name=Get-SmbWitnessClient; Module=SmbW...
That's just a subset of what one can find on the last version of the Windows Server OS:

[192.168.1.10]: PS C:\> Get-Command | Select Name,Module | Group Module | Sort Count -Descending

Count Name                      Group
----- ----                      -----
  140 Storage                   {@{Name=Disable-PhysicalDiskIndication; Module=Storage}, @{Name=Disable-StorageDiagn...
  105 Microsoft.PowerShell.U... {@{Name=Format-Hex; Module=Microsoft.PowerShell.Utility}, @{Name=Get-FileHash; Modul...
   98                           {@{Name=A:; Module=}, @{Name=B:; Module=}, @{Name=C:; Module=}, @{Name=cd..; Module=...
   86 Microsoft.PowerShell.M... {@{Name=Add-Computer; Module=Microsoft.PowerShell.Management}, @{Name=Add-Content; M...
   85 NetSecurity               {@{Name=Copy-NetFirewallRule; Module=NetSecurity}, @{Name=Copy-NetIPsecMainModeCrypt...
   78 RemoteDesktop             {@{Name=Add-RDServer; Module=RemoteDesktop}, @{Name=Add-RDSessionHost; Module=Remote...
   68 NetAdapter                {@{Name=Disable-NetAdapter; Module=NetAdapter}, @{Name=Disable-NetAdapterBinding; Mo...
   43 Dism                      {@{Name=Add-ProvisionedAppxPackage; Module=Dism}, @{Name=Apply-WindowsUnattend; Modu...
   42 NFS                       {@{Name=Disconnect-NfsSession; Module=NFS}, @{Name=Get-NfsClientConfiguration; Modul...
   41 MsDtc                     {@{Name=Add-DtcClusterTMMapping; Module=MsDtc}, @{Name=Get-Dtc; Module=MsDtc}, @{Nam...
   35 SmbShare                  {@{Name=Block-SmbShareAccess; Module=SmbShare}, @{Name=Close-SmbOpenFile; Module=Smb...
   34 NetTCPIP                  {@{Name=Find-NetRoute; Module=NetTCPIP}, @{Name=Get-NetCompartment; Module=NetTCPIP}...
   34 NetworkTransition         {@{Name=Add-NetIPHttpsCertBinding; Module=NetworkTransition}, @{Name=Disable-NetDnsT...
   32 BranchCache               {@{Name=Add-BCDataCacheExtension; Module=BranchCache}, @{Name=Clear-BCCache; Module=...
   27 IscsiTarget               {@{Name=Expand-IscsiVirtualDisk; Module=IscsiTarget}, @{Name=Export-IscsiTargetServe...
   23 NetEventPacketCapture     {@{Name=Add-NetEventNetworkAdapter; Module=NetEventPacketCapture}, @{Name=Add-NetEve...
   20 Pester                    {@{Name=AfterAll; Module=Pester}, @{Name=AfterEach; Module=Pester}, @{Name=Assert-Mo...
   19 ScheduledTasks            {@{Name=Disable-ScheduledTask; Module=ScheduledTasks}, @{Name=Enable-ScheduledTask; ...
   18 International             {@{Name=Get-WinAcceptLanguageFromLanguageListOptOut; Module=International}, @{Name=G...
   17 PSDesiredStateConfigur... {@{Name=Configuration; Module=PSDesiredStateConfiguration}, @{Name=Find-DscResource;...
   17 DnsClient                 {@{Name=Add-DnsClientNrptRule; Module=DnsClient}, @{Name=Clear-DnsClientCache; Modul...
   17 PKI                       {@{Name=Add-CertificateEnrollmentPolicyServer; Module=PKI}, @{Name=Export-Certificat...
   16 PSScheduledJob            {@{Name=Add-JobTrigger; Module=PSScheduledJob}, @{Name=Disable-JobTrigger; Module=PS...
   14 CimCmdlets                {@{Name=Export-BinaryMiLog; Module=CimCmdlets}, @{Name=Get-CimAssociatedInstance; Mo...
   14 UserAccessLogging         {@{Name=Disable-Ual; Module=UserAccessLogging}, @{Name=Enable-Ual; Module=UserAccess...
   14 EventTracingManagement    {@{Name=Add-EtwTraceProvider; Module=EventTracingManagement}, @{Name=Get-AutologgerC...
   13 Microsoft.PowerShell.S... {@{Name=ConvertFrom-SecureString; Module=Microsoft.PowerShell.Security}, @{Name=Conv...
   13 NetNat                    {@{Name=Add-NetNatExternalAddress; Module=NetNat}, @{Name=Add-NetNatStaticMapping; M...
   13 NetLbfo                   {@{Name=Add-NetLbfoTeamMember; Module=NetLbfo}, @{Name=Add-NetLbfoTeamNic; Module=Ne...
   13 Microsoft.WSMan.Manage... {@{Name=Connect-WSMan; Module=Microsoft.WSMan.Management}, @{Name=Disable-WSManCredS...
   13 iSCSI                     {@{Name=Connect-IscsiTarget; Module=iSCSI}, @{Name=Disconnect-IscsiTarget; Module=iS...
   12 Wdac                      {@{Name=Add-OdbcDsn; Module=Wdac}, @{Name=Disable-OdbcPerfCounter; Module=Wdac}, @{N...
   11 ServerManagerTasks        {@{Name=Get-SMCounterSample; Module=ServerManagerTasks}, @{Name=Get-SMPerformanceCol...
   11 SoftwareInventoryLogging  {@{Name=Get-SilComputer; Module=SoftwareInventoryLogging}, @{Name=Get-SilComputerIde...
   11 DirectAccessClientComp... {@{Name=Disable-DAManualEntryPointSelection; Module=DirectAccessClientComponents}, @...
   11 PowerShellGet             {@{Name=Find-Module; Module=PowerShellGet}, @{Name=Get-InstalledModule; Module=Power...
   11 Defender                  {@{Name=Add-MpPreference; Module=Defender}, @{Name=Get-MpComputerStatus; Module=Defe...
   10 PackageManagement         {@{Name=Find-Package; Module=PackageManagement}, @{Name=Get-Package; Module=PackageM...
   10 PSDiagnostics             {@{Name=Disable-PSTrace; Module=PSDiagnostics}, @{Name=Disable-PSWSManCombinedTrace;...
    9 PcsvDevice                {@{Name=Clear-PcsvDeviceLog; Module=PcsvDevice}, @{Name=Get-PcsvDevice; Module=PcsvD...
    8 BitsTransfer              {@{Name=Add-BitsFile; Module=BitsTransfer}, @{Name=Complete-BitsTransfer; Module=Bit...
    7 NetSwitchTeam             {@{Name=Add-NetSwitchTeamMember; Module=NetSwitchTeam}, @{Name=Get-NetSwitchTeam; Mo...
    7 ServerManager             {@{Name=Add-WindowsFeature; Module=ServerManager}, @{Name=Remove-WindowsFeature; Mod...
    7 TLS                       {@{Name=Disable-TlsCipherSuite; Module=TLS}, @{Name=Disable-TlsSessionTicketKey; Mod...
    6 Kds                       {@{Name=Add-KdsRootKey; Module=Kds}, @{Name=Clear-KdsCache; Module=Kds}, @{Name=Get-...
    5 AppLocker                 {@{Name=Get-AppLockerFileInformation; Module=AppLocker}, @{Name=Get-AppLockerPolicy;...
    5 PSReadline                {@{Name=Get-PSReadlineKeyHandler; Module=PSReadline}, @{Name=Get-PSReadlineOption; M...
    5 Microsoft.PowerShell.D... {@{Name=Export-Counter; Module=Microsoft.PowerShell.Diagnostics}, @{Name=Get-Counter...
    4 NetworkConnectivityStatus {@{Name=Get-DAConnectionStatus; Module=NetworkConnectivityStatus}, @{Name=Get-NCSIPo...
    4 PnpDevice                 {@{Name=Disable-PnpDevice; Module=PnpDevice}, @{Name=Enable-PnpDevice; Module=PnpDev...
    4 NetQos                    {@{Name=Get-NetQosPolicy; Module=NetQos}, @{Name=New-NetQosPolicy; Module=NetQos}, @...
    4 BestPractices             {@{Name=Get-BpaModel; Module=BestPractices}, @{Name=Get-BpaResult; Module=BestPracti...
    3 SmbWitness                {@{Name=Move-SmbClient; Module=SmbWitness}, @{Name=Get-SmbWitnessClient; Module=SmbW...
    3 WindowsErrorReporting     {@{Name=Disable-WindowsErrorReporting; Module=WindowsErrorReporting}, @{Name=Enable-...
    2 ServerCore                {@{Name=Get-DisplayResolution; Module=ServerCore}, @{Name=Set-DisplayResolution; Mod...
    2 Microsoft.PowerShell.A... {@{Name=Compress-Archive; Module=Microsoft.PowerShell.Archive}, @{Name=Expand-Archiv...
    2 NetConnection             {@{Name=Get-NetConnectionProfile; Module=NetConnection}, @{Name=Set-NetConnectionPro...
    2 PSWorkflow                {@{Name=New-PSWorkflowSession; Module=PSWorkflow}, @{Name=New-PSWorkflowExecutionOpt...
    2 Microsoft.PowerShell.Host {@{Name=Start-Transcript; Module=Microsoft.PowerShell.Host}, @{Name=Stop-Transcript;...
    1 PSWorkflowUtility         {@{Name=Invoke-AsWorkflow; Module=PSWorkflowUtility}}
    1 Microsoft.PowerShell.O... {@{Name=Export-ODataEndpointProxy; Module=Microsoft.PowerShell.ODataUtils}}
As you can see NanoServer boasts the whole bunch of Storage, SmbShare or NetTCPIP cmdlets, while it lacks modules like Netlbfo, Pester, NFS or PSDesiredStateConfiguration.

CONCLUSION

As a matter of fact, NanoServer is not aimed at being an all-round do-everything operating system, like any previous Windows till now. Nano Server has been designed for the automation of Cloud services. As Snover, the inventor of Powershell and lead architect for the Windows Server Division, stated recently: "I want automation. One of the key principles of the cloud is we want configuration as code."

Today it is up to you to find the most convenient use for this newborn technology. And even if there is for sure a lot of work to be done to correct the bugs that will come up, you can already forget about old style server management. Things are changing faster and faster. Powershell somewhat opened the way to everything you see now, and NanoServer is maybe the reason why all of this happened.
 
Stay tuned for more on NanoServer and Powershell.
Related Posts Plugin for WordPress, Blogger...