Launch Windows Server 2016 Nano in AWS with Powershell
Amazon Web Services yesterday announced they now have Amazon Machine images available for Windows Server 2016. This includes Nano Server, a perfect solution for a roll your own IaaS server to host your .NET Core APIs.
Windows Server 2016 Nano Server -A cloud-native, minimal install that takes up a modest amount of disk space and boots more swiftly than the Datacenter version, while leaving more system resources (memory, storage, and CPU) available to run apps and services.
One of the interesting things about Nano for existing Windows server users, is you can only access it via PowerShell/WinRM for managment of the server. You can quickly spin up a new instance of nano in your PowerShell console (already configured for AWS):
Once the instance has started up, you can get the Admin credentials using your EC2 Key, and establish a remote PowerShell session:
This leaves you with an established PowerShell session to the remote server, which can be shown as follows:C:\> $session<br /> Id Name ComputerName ComputerType State ConfigurationName Availability<br /> -- ---- ------------ ------------ ----- ----------------- ------------<br /> 2 Session2 172.19.1.67 RemoteMachine Opened Microsoft.PowerShell Available
You are now able to invoke remote commands on your Nano server:C:\> Invoke-Command -Session $session -ScriptBlock { Get-Process | Select ProcessName, Id |ft }<br /> ProcessName Id<br /> ----------- --<br /> amazon-ssm-agent 1792<br /> csrss 496<br /> EMT 1088<br /> Idle 0<br /> LiteAgent 828<br /> lsass 556<br /> services 544<br /> smss 360<br /> svchost 648<br /> svchost 692<br /> svchost 768<br /> System 4<br /> wininit 520<br /> WmiPrvSE 1236<br /> wsmprovhost 1468
If you just want to jump onto the remote server, you can Enter the Session:
`C:> Enter-PSSession -Session $session
[172.19.1.67]: PS C:\Users\Administrator\Documents> $StartTime = (Get-Date) - (New-TimeSpan -Day 1)
[172.19.1.67]: PS C:\Users\Administrator\Documents> Get-WinEvent -FilterHashTable @{LogName=‘System’; Level=2; StartTime=$StartTime}
| select TimeCreated, Message
TimeCreated Message
———– ——-
10/21/2016 2:36:36 AM Task Scheduler service failed to start Task Compatibility module. Tasks m…
10/21/2016 2:36:15 AM The Virtualization Based Security enablement policy check at phase 6 fail…
10/21/2016 2:36:15 AM The Virtualization Based Security enablement policy check at phase 0 fail…
10/20/2016 4:18:55 AM Task Scheduler service failed to start Task Compatibility module. Tasks m…
10/20/2016 4:18:48 AM The Virtualization Based Security enablement policy check at phase 6 fail…
10/20/2016 4:18:48 AM The Virtualization Based Security enablement policy check at phase 0 fail…
10/20/2016 4:14:42 AM Task Scheduler service failed to start Task Compatibility module. Tasks m…
10/20/2016 4:14:11 AM The Virtualization Based Security enablement policy check at phase 6 fail…
10/20/2016 4:14:11 AM The Virtualization Based Security enablement policy check at phase 0 fail…
10/20/2016 11:12:05 AM The Virtualization Based Security enablement policy check at phase 6 fail…
10/20/2016 11:12:05 AM The Virtualization Based Security enablement policy check at phase 0 fail…
Don’t forget once you are finished to remove the session:Remove-PSSession -Session $session
Given that this instance has no local console, you will have to maintain and access it fully using PowerShell. Time to skill up on your PowerShell skills. If you would like to read more on remotely managing the instance, Microsoft have documented how to manage Nano Server. It’s a good next step to read.