上QQ阅读APP看书,第一时间看更新
How to do it...
Method 1, using the Nano Server Recovery Console:
- Launch Hyper-V management console, and locate the VM running Nano Server.
- Double-click the VM to bring up the recovery console.
- Enter the username administrator and the password that you defined when you created the VM.
- Nano Server then display basic information about the server with a menu of options. Choose Networking from this menu by pressing Enter, then press Enter again to choose the default adapter.
- Your Nano Server's IP configuration is displayed, with key navigation options displayed at the bottom of the screen. Note your IP address to use to connect later in this recipe.
- Press F11 at this screen to configure your IP address, if desired. Then press F4 to change from DHCP to static IP, and use the Tab key to move between the IP Address, Subnet Mask, and Default Gateway fields, and enter the desired values.
Method 2, using PowerShell Direct:
- From the Hyper-V host, open PowerShell ISE. List the VMs:
Get-VM -Name N*
- Store the Nano Server VM name and administrator credential in variables:
$NanoComputerName = 'NANO1' $Credential = Get-Credential ` -Message "Enter administrator password for target VM:" ` -UserName administrator
- Get the running processes using Invoke-Command via PowerShell Direct:
Invoke-Command -VMName $NanoComputerName -Credential $Credential
-ScriptBlock { Get-Process }
- Enter an interactive PowerShell remoting session via PowerShell Direct:
Enter-PSSession -VMName $NanoComputerName -Credential $Credential
- You are connected just like that in a PowerShell remoting session! Create and use a test folder in your Nano server:
New-Item -ItemType Directory -Path C:\foo `
-ErrorAction SilentlyContinue Set-Location C:\foo
- Gather information about your server using the new Get-ComputerInfo cmdlet:
Get-ComputerInfo -Property CsName, WindowsEditionId,
OSServerLevel, ` OSType, OSVersion, WindowsBuildLabEx, BiosBIOSVersion
- Examine $PSVersionTable, noting the value of the PSEdition property:
$PSVersionTable
- Get the IP Address of your Nano Server, noting it for later recipe steps:
Get-NetIPAddress -AddressFamily IPV4 -InterfaceAlias Ethernet | Select-Object -ExpandProperty IPAddress
- If required, change the IP Address of your Nano Server, and display the new IP:
New-NetIPAddress -InterfaceAlias 'Ethernet' ` -IPAddress 10.10.10.131 ` -PrefixLength 24 ` -DefaultGateway 10.10.10.254 Get-NetIPAddress -InterfaceAlias 'Ethernet' -AddressFamily IPv4
- If required, set the DNS of your Nano Server, and display the DNS information:
Set-DnsClientServerAddress -InterfaceAlias 'Ethernet' ` -ServerAddresses 10.10.10.10,
10.10.10.11 Get-DnsClientServerAddress
- Exit your remoting session:
Exit-PSSession
Method 3, Using PowerShell Remoting:
- PowerShell remoting requires that the remoting target computer IP should be among the TrustedHosts defined on your computer. Add the IP Address of the Nano Server to our computer's TrustedHosts and verify the value:
$NanoServerIP = '10.10.10.131' Set-Item -Path WSMan:\localhost\Client\TrustedHosts `
-Value $NanoServerIP -Force Get-Item -Path WSMan:\localhost\Client\TrustedHosts
- Verify WSMan connectivity to the Nano Server:
Test-WSMan -Path $NanoServerIP
- Connect via PowerShell remoting to the Nano Server:
Enter-PSSession -ComputerName $NanoServerIP `
-Credential $Credential
- Use Get-ComputerInfo to inspect the Nano Server:
Get-ComputerInfo -Property CsName, WindowsEditionId,
OSServerLevel, OSType, OSVersion,
WindowsBuildLabEx, BiosBIOSVersion
- Exit your remoting session:
Exit-PSSession
Method 4, Using WMI with the CIM cmdlets:
- Create a new CIM session on the Nano Server, and view the $CimSession object:
$CimSession = New-CimSession -Credential $Credential `
-ComputerName $NanoServerIP $CimSession
- Examine the properties of the Win32_ComputerSystem CIM class:
Get-CimInstance -CimSession $CimSession `
-ClassName Win32_ComputerSystem |
Format-List -Property *
- Count the CIM classes available:
Get-CimClass -CimSession $CimSession | Measure-Object
- View the running processes using the CIM_Process WMI class and a WMI query:
Get-CimInstance -CimSession $CimSession `
-Query "SELECT * from CIM_Process"
- Remove your CIM Session:
Get-CimSession | Remove-CimSession