I would like to run the PS Script on multiple Workgroup Machines where PSRemoting is enabled and All required Firewall Ports are opened. If I do Enter-PSSession Localhost it works fine. Problem is during remote execution.
[pre]
$Servers = Get-Content ‘C:\PSRemoting\VMList.txt’
$Scriptpath = ‘C:\PSRemoting\Temp.ps1’
$logfile =‘C:\PSRemoting\log.txt’
$Username = ‘support’
$Password = ‘MYPassword’
$Halt = ‘2’ #This value defines the pause between to execution in secs
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList $Username,$pass
foreach($s in $Servers)
{
$Credtest = gwmi win32_computersystem -computer $s -credential $cred
If($Credtest -eq $null)
{
Write-Output “$(Get-Date -Format g) : PasswordFailure : $S : Password is not working” | Out-File -FilePath $logfile -Append -Force
} else {
In above script $Credtest is success but Invoke is failing with below error:
3/18/2019 11:36 AM : ExecutionFailure : VMNAME: Exection Failed with Error: System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable “ErrorActionPreference” or common parameter is set to Stop: [VMNAME] Connecting to remote server VMNAME failed with the following error message : WinRM cannot process the request. The following error with errorcode 0x80090311 occurred while using Kerberos authentication: There are currently no logon servers available to service the logon request.
Possible causes are:
-The user name or password specified are invalid.
-Kerberos is used when no authentication method and no user name are specified.
-Kerberos accepts domain user names, but not local user names.
-The Service Principal Name (SPN) for the remote computer name and port does not exist.
-The client and remote computers are in different domains and there is no trust between the two domains.
After checking for the above issues, try the following:
-Check the Event Viewer for events related to authentication.
-Change the authentication method; add the destination computer to the WinRM TrustedHosts configuration setting or use HTTPS transport.
Note that computers in the TrustedHosts list might not be authenticated.
-For more information about WinRM configuration, run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic.
at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at lambda_method(Closure , Object , StrongBox`1 , InterpretedFrame )
Any assistance on above error is much appreciated or any better way to do PSRemoting on Workgroup VM’s.
You have to setup the environment for this and it is well documented in many places over the years…
Enable PowerShell Remoting on a standalone (workgroup) computer
https://4sysops.com/archives/enable-powershell-remoting-on-a-standalone-workgroup-computer
PowerShell remoting between two workgroup machines
POWERSHELL PS REMOTING BETWEEN STANDALONE WORKGROUP COMPUTERS
Understanding and troubleshooting WinRM connection and authentication: a thrill seeker's guide to adventure
http://www.hurryupandwait.io/blog/understanding-and-troubleshooting-winrm-connection-and-authentication-a-thrill-seekers-guide-to-adventure
While going through the articles found that issue with source VM trusted host config. After adding * in Trustedhost in Source VM it started working fine.
If this is you now self controlled environment, then doing this ‘adding * in Trustedhost’ is fine, but not something you’d want to do in an enterprise. For risk manager reasons, ‘adding * in Trustedhost’, is not recommended, specifically list the hosts you want to trust.