win10使用 PowerShell 远程访问服务器

1.以管理员身份运行powershell;
2.

Enable-PSRemoting -Force

报错:

Set-WSManQuickConfig : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859113" M
achine="localhost"><f:Message><f:ProviderFault provider="Config provider" path="%systemroot%\system32\WsmSvc.dll"><f:WS
ManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859113" Machine="LAPTOP-7CNJP3NB"><f:
Message>由于此计算机上的网络连接类型之一设置为公用,因此 WinRM 防火墙例外将不运行。 将网络连接类型更改为域或专用,然后
再次尝试。 </f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault>
所在位置 行:116 字符: 17
+                 Set-WSManQuickConfig -force
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Set-WSManQuickConfig],InvalidOperationException
    + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand

解决方法:解决方法:将网络类型更改为“专用”(Private)
运行

Get-NetConnectionProfile

得到

Name                     : 未识别的网络
InterfaceAlias           : 以太网
InterfaceIndex           : 8
NetworkCategory          : Private
DomainAuthenticationKind : None
IPv4Connectivity         : LocalNetwork
IPv6Connectivity         : NoTraffic

Name                     : you_name
InterfaceAlias           : WLAN
InterfaceIndex           : 6
NetworkCategory          : Private
DomainAuthenticationKind : None
IPv4Connectivity         : Internet
IPv6Connectivity         : NoTraffic

运行

Set-NetConnectionProfile -NetworkCategory Private

再次运行

Enable-PSRemoting -Force

解决。

3.添加单个IP

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "101.102.103.104" -Force

4.使用 Enter-PSSession 连接远程服务器

Enter-PSSession -ComputerName 10.42.1.10 -Credential administrator

win10使用 PowerShell 远程访问服务器_第1张图片

你可能感兴趣的:(服务器,运维)