TLDR;尝试远程检查网络框架版本。
有用信息:
所有电脑均运行 win 7 home
将网络设置为公共(为什么我尝试-SkipNetworkProfileCheck)
所有 Windows 防火墙都应关闭
主 PC 运行代码来自 PS ver5
所有其他 PSv2
我运行了脚本,出现了错误,然后运行了 Winrm 代码,但似乎没有帮助。我研究了自制的安全证书,但我不确定是否需要走这条路。
我收到的错误:
[172.32.5.1] Connecting to remote server 172.32.5.1 failed with the following error message : The
client cannot connect to the destination specified in the request. Verify that the service on the
destination is running and is accepting requests. Consult the logs and documentation for the WS-
Management service running on the destination, most commonly IIS or WinRM. If the destination is the
WinRM service, run the following command on the destination to analyze and configure the WinRM
service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (172.32.5.1:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : CannotConnect,PSSessionStateBroken
我运行的代码:
# Read all the computers from the file
$computers = get-content C:\Users\Administrator\Desktop\DavidsStuff\ips.txt
# Perform an operation for each row in the file
foreach ($strComputer in $computers) {
$Username = 'Administrator'
$Password = 'password'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Write-Host -Fore Green “Enabling RemoteRegistry service”
sc.exe \\$strComputer config remoteregistry start= auto
$scriptblockToExecute = {
Write-Host "IP: $strComputer"
Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
}
Invoke-command -ComputerName $strComputer -Credential $Cred -Scriptblock $scriptblockToExecute
}
Winrm 代码:
$computers = get-content "C:\Users\Administrator\Desktop\DavidsStuff\ips.txt"
foreach ($strComputer in $computers) {
psexec \\$strComputer -u Administrator -p password
Set-WSManQuickConfig -SkipNetworkProfileCheck -Force
}
答案1
您根本没有正确设置工作组模式中的 PSRemoting。
• 在独立(工作组)计算机上启用 PowerShell Remoting https://4sysops.com/archives/enable-powershell-remoting-on-a-standalone-workgroup-computer
• 两台工作组计算机之间的 PowerShell 远程处理 https://blogs.msdn.microsoft.com/wmi/2009/07/24/powershell-remoting-between-two-workgroup-machines
• 独立工作组计算机之间的 Powershell Ps 远程处理 http://vcloud-lab.com/entries/active-directory/powershell-ps-remoting-between-standalone-workgroup-computers
• 两台工作组计算机之间的 PowerShell 远程处理 https://posh2scripting.wordpress.com/2013/06/07/powershell-remoting-between-two-workgroup-machines
• 在工作组计算机上启用远程 Powershell https://infrahouse.wordpress.com/2015/10/21/enabling-remote-powershell-on-workgroup-computers
• WinRM 安全 - PowerShell | Microsoft Docs https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/winrmsecurity
• 如何在工作组非域环境中设置 WinRM https://www.paulligocki.com/how-to-setup-winrm-in-a-workgroup-non-domain-environment
• 提示:使用 Windows PowerShell 进行远程工作,无需使用 Remoting 或 WinRM https://technet.microsoft.com/en-us/library/ff699046.aspx
Some cmdlets have a –ComputerName parameter that lets you work with a remote
computer without using Windows PowerShell remoting. This means you can use
the cmdlet on any computer that is running Windows PowerShell, even if the
computer is not configured for Windows PowerShell remoting. These cmdlets
include the following:
• Get-WinEvent
• Get-Counter
• Get-EventLog
• Clear-EventLog
• Write-EventLog
• Limit-EventLog
• Show-EventLog
• New-EventLog
• Remove-EventLog
• Get-WmiObject
• Get-Process
• Get-Service
• Set-Service
• Get-HotFix
• Restart-Computer
• Stop-Computer
• Add-Computer
• Remove-Computer
• Rename-Computer
• Reset-ComputerMachinePassword