什么是Windows Nano Server

Windows Nano Server,号称无头server,它是真正的没有图形化GUI界面的 ,而不像Server Core只是没有图形化的Shell。其好处是体积小:默认安装只有400多MB,远低于Server Core的6GB左右,当然更加低于传统的图形化Windows Server。

特点

1)非常的小,VHD文件只有500多MB; 2)轻量级的OS,比server core占用资源更少,初始安装完成后,默认的进程、服务更少; 3)需要的补丁更新少,更小的涉及面; 4)适合部署IIS、DNS等应用程序; 5)适合部署windows container、docker程序; 6)专门支持基于本地私有云的应用程序或服务; 关于这些特点,在官方的Nano Server页面有详细的说明,可以参考:getting-started-with-nano-server

关闭防火墙服务

Disable The Firewall On A Windows Nano Server Using PowerShell netsh advfirewall set allprofiles state off 或: Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled false (恢复防火墙服务:netsh advfirewall set allprofiles state on)

从宿主机复制文件到nano server

请添加链接描述

  1. Disable The Firewall On A Windows Nano Server Using PowerShell netsh advfirewall set allprofiles state off
  2. 宿主机访问nano的共享目录:
\\NanoServerHostOrIP\C$

输入用户名密码即可访问

Powershell远程连接Windows Server Nano

https://serverfault.com/questions/657918/remote-ps-session-fails-on-non-domain-server

  1. 服务端:
Enable-PSRemoting -Force
winrm quickconfig
  1. 客户端:
winrm quickconfig
winrm set winrm/config/client '@{TrustedHosts="192.168.1.105"}'

Enter-PSSession -ComputerName 10.168.9.28  -Credential administrator    -authentication default

$cred = get-credential -username "administrator" -message "Enter password"
New-PSSession -ComputerName 10.168.9.28 -Credential administrator

弹出输入框输入密码,成功后会显示: Id Name ComputerName ComputerType State ConfigurationName Availability


1 WinRM2 192.168.18.9 RemoteMachine Opened Microsoft.PowerShell Available 进入PSSession: Enter-PSSession 1 [192.168.18.9]: PS C:\Users\Administrator\Documents>

查看winrm配置:

winrm get winrm/config

==== ps脚本无法执行:is not digitally signed ... ====

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
ref: http://tritoneco.com/2014/02/21/fix-for-powershell-script-not-digitally-signed/

服务器配置工具

Server Configuration Tool
Sconfig.cmd

netsh interface ip set address "em1" static 10.168.9.220 255.255.255.0 10.168.9.1 1

参考地址

国际设置

## 导入国际设置模块
ipmo international
## 显示区域设置信息
Get-WinSystemLocale
## 设置区域
Set-WinSystemLocale zh-CN
## 重启机器
Restart-Computer -Force

参考地址

设置静态IP地址

Configure Windows Nano Server 2016 IP Address Using PowerShell
Get-NetAdapter
Get-NetAdapter | fl
The important value In the cmdlet Is the InterfaceIndex

New-NetIPAddress -InterfaceIndex 4 -IPAddress 192.168.18.9 -PrefixLength 24 -DefaultGateway 192.168.18.2

Get-NetIPInterface -InterfaceIndex 4

参考地址

其它设置

设置DNS服务器IP#

Sets DNS server addresses associated with the TCP/IP properties on an interface. https://docs.microsoft.com/en-us/powershell/module/dnsclient/set-dnsclientserveraddress?view=win10-ps

Set-DnsClientServerAddress -InterfaceIndex 5 -ServerAddresses ("114.114.114.114")

设置环境变量

[Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://16.153.99.11:8080", [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://16.153.99.11:8080", [EnvironmentVariableTarget]::Machine)

[Environment]::GetEnvironmentVariable("HTTP_PROXY", [EnvironmentVariableTarget]::Machine)
[Environment]::GetEnvironmentVariable("HTTPS_PROXY", [EnvironmentVariableTarget]::Machine)

删除环境变量

[Environment]::SetEnvironmentVariable("HTTP_PROXY", $null, [EnvironmentVariableTarget]::Machine)
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", $null, [EnvironmentVariableTarget]::Machine)

Write-Host命令的用法(脚本中输出文字)

Write-Host [[-Object] <Object>] [-NoNewline] [-Separator <Object>] [-ForegroundColor <ConsoleColor>] [-BackgroundColor <ConsoleColor>] [<CommonParameters>] 参考地址

删除一个HSNNetwork Get-HNSNetworks

Get-HNSNetwork f84fb0f2-5ed0-4bdf-a20c-a826505ef82b | Remove-HNSNetwork

curl

curl 192.168.18.90 -UseBasicParsing
Invoke-WebRequest -uri "http://www.google.com" -UseBasicParsing

压缩文件

Compress-Archive -Path c:/k/ -CompressionLevel Optimal -DestinationPath C:\Archives\Draft.Zip

解压缩文件

Expand-Archive master.zip -DestinationPath master

查看系统信息

[Environment]::OSVersion
[System.Environment]::OSVersion.Version
gwmi win32_operatingsystem | % caption
systeminfo
Get-ComputerInfo

windows server 1709 jan-2018 update:
10.0.16299.0

Get-CimInstance -ClassName SoftwareLicensingProduct |
     where {$_.PartialProductKey} |
     select Description, LicenseStatus

其他

欢迎有问题及时交流~ 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多交流