I would like to connect to a windows 10 machine and run a remote command with powershell script. The script which runs on a windows 10 machine looks like
$RemoteMachine = "10.1.1.50"
$vcenter_server ="10.1.1.2"
Set-Item WSMan:\localhost\Client\TrustedHosts -Value $RemoteMachine -force
$Username = 'user'
$Password = ' '
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
Invoke-Command -ComputerName $RemoteMachine -Credential $Cred ` -ScriptBlock { diskpart /s c:\diskman.txt }However, the output says the machine is not accessible while the ping command works fine.
[10.1.1.50] Connecting to remote server 10.1.1.50 failed with the following error message : WinRM cannot complete the operation.
Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception
for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles
limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help
topic. + CategoryInfo : OpenError: (10.1.1.50:String) [], PSRemotingTransportException + FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionStateBroken
PS C:\Users\user> ping 10.1.1.50
Pinging 10.1.1.50 with 32 bytes of data:
Reply from 10.1.1.50: bytes=32 time<1ms TTL=128Any idea to find the root of the problem?
2 Reset to default