94
CHAPTER 3 | Application platform
Remotely managing Nano Server
Nano Server is truly headless—there is no way to use Remote Desktop to connect remotely. As a
result, you must perform all Nano Server management remotely, either via Windows
PowerShell,
Windows Management Instrumentation (WMI), Windows Remote Shell (WinRS), Emergency
Management Services (EMS), or remote GUI tools.
Note The options discussed in this section to remotely manage Nano Server are the same
mechanisms that you can use to remotely manage Server Core. The only difference in managing
Nano Server is that you must do it all remotely.
Windows PowerShell
Nano Server includes a refactored subset of Windows PowerShell called Core PowerShell, which is
based on the CoreCLR. Core PowerShell provides the following:
Full Windows PowerShell language compatibility
Full Windows PowerShell remoting
Most core engine features
Support for all cmdlet types, including C#, Windows PowerShell, and CIM
Because Nano Server
includes Core PowerShell, it is possible to use Windows PowerShell Remoting to
manage Nano Server. To do so, you need to be an administrator on the Nano Server machine and add
its IP address to the management machine's trusted hosts. To do that, from an elevated Windows
PowerShell prompt, run the following command (which, for this example, assumes
the Nano Server
machine’s IP address is 192.168.1.10):
PS C:\> Set-Item WSMan:\localhost\Client\TrustedHosts "192.168.1.10"
The following is an example of how to start an interactive remoting session:
PS C:\NanoServer> $ip = "192.168.1.10"
PS C:\NanoServer> $user = "Administrator"
PS C:\NanoServer> Enter-PSSession -ComputerName $ip -Credential $user
After you have done this, you can now run any available Windows PowerShell command as if you
were entering it directly into the Nano Server console; for example:
[192.168.1.10]: PS C:\users\user1\Documents> Get-Process w*
[192.168.1.10]: PS C:\users\user1\Documents> ipconfig /all
Not all Windows PowerShell commands are available in Nano Server. To see which cmdlets are
available, run the following command:
[192.168.1.10]: PS C:\users\user1\Documents> Get-Command -CommandType Cmdlet
To
end the remoting session, run this command:
[192.168.1.10]: PS C:\users\user1\Documents> Exit-PSSession
WMI
Nano Server includes WMI v1 and WMI v2 as well as the providers for the included functionality.
95
CHAPTER 3 | Application platform
WinRM
You can use CIM sessions and CIM instances in Windows PowerShell to run WMI commands remotely
over WinRM, as demonstrated here:
PS C:\NanoServer> $ip = "192.168.1.10"
PS C:\NanoServer> $user = "Administrator"
PS C:\NanoServer> $cim = New-CimSession
–
Credential $user
–
ComputerName $ip
When the CIM session is established, you can run various WMI
commands, such as the following:
PS C:\NanoServer> Get-CimInstance
–
CimSession $cim
–
ClassName Win32_ComputerSystem | Format-List *
PS C:\NanoServer> Get-CimInstance -Query "SELECT * from Win32_Process WHERE name LIKE 'p%'"
WinRS
Using Windows Remote Management (WinRM), you can run programs remotely. Before you can use
WinRS, you need to configure the WinRM service and set the code page, as follows:
C:\NanoServer> winrm quickconfig
C:\NanoServer> winrm set winrm/config/client @{TrustedHosts="*"}
After you configure the WinRM service, you
can run commands remotely, as if you were running them
from the command line:
C:\NanoServer> winrs
–
r:192.168.1.10 -u:Administrator -p:Tuva ipconfig
Do'stlaringiz bilan baham: