Reputation: 27
hello so my code is the following:
$securePassword = $password |ConvertTo-SecureString -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $securePassword
Invoke-Command -FilePath "C:\Users\CompName\Desktop\PowerShell Scripts\CloseWinCC.ps1" -ComputerName "CompName" -Credential $cred
Connecting to remote server "CompName" failed with the following error message :
The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if
the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated.
I also tried running on localhost with the following code:
Invoke-Command -FilePath "C:\Users\CompName\Desktop\PowerShell Scripts\CloseWinCC.ps1" -ComputerName localhost -Credential $cred
and yet even on localhost it gives the following error:
Connecting to remote server localhost failed with the following error message : Access is denied.
Any idea why?
update: I did run
Enable-PSRemoting - SkipNetworkProfileCheck -Force
and now the error is :
Connecting to remote server CompName failed with the following error message : The WinRM
client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the
destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated.
Upvotes: 0
Views: 530
Reputation: 27606
This registry entry must be set for a non-domain account, and also running as administrator:
$path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
set-ItemProperty $path LocalAccountTokenFilterPolicy 1 -Type DWord
User Account Control and remote restrictions - Windows Server | Microsoft Learn https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/user-account-control-and-remote-restriction#how-to-disable-uac-remote-restrictions
Upvotes: 0