我使用的是Windows 7机器,安装了Windows Power shell。如何确保 Windows 防火墙配置为允许来自工作站的 Windows 远程管理连接。例如: netsh advfirewall 防火墙设置规则名称 =“Windows 远程管理(HTTP-In)”配置文件 = 公共协议 = tcp 本地端口 = 5985 远程 IP = 本地子网 新远程 IP = 任何
我正在执行上述命令,但无法配置它。
Enable-PSRemoting -force
就是您要找的!
winrm quickconfig
也是一个很好的预防措施,启动 WinRM 服务并将该服务设置为自动启动。
但是,如果您希望对所有 Windows 7 计算机执行此操作,您可以通过 组策略
启用它这取决于您使用的协议。
以下一项对我有用:
Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP-PUBLIC" -RemoteAddress Any
几年前我使用它连接到远程服务器并更新 WinRM,然后将其加入域。 ($server 变量是 foreach 语句的一部分)。 我的脚本的这一部分更新 -:
$RequestingServer = $env:COMPUTERNAME
#Local Server Admin Account
[STRING] $LocalUser = "Administrator" #Obviously Change Account
[STRING] $LocalPassword = "Password01" #Obviously Change Password
$LocalSecurePassword = $LocalPassword | ConvertTo-SecureString -AsPlainText -Force
$LocalCredentials = New-Object System.Management.Automation.PSCredential -ArgumentList $LocalUser, $LocalSecurePassword
#Update Windows Firewall Remotely
$LocalSession = New-PSSession -Computername $Server -Credential $LocalCredentials
Invoke-Command -Session $LocalSession -ScriptBlock {
$AddServer = $Using:RequestingServer
#Update Windows Firewall from Public to Private
Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private
#Update Windows Firewall to allow remote WMI Access
netsh advfirewall firewall set rule group="Windows Management Instrumentation (WMI)" new enable=yes
#Update Trusted Hosts is not domain-joined and therefore must be added to the TrustedHosts list
Set-Item wsman:\localhost\Client\TrustedHosts -Value $AddServer -Force
#Update Windows Firewall to allow RDP
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
#Enable RDP : 1 = Disable ; 0 = Enable
Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0
}