Good afternoon all!
Here is my current opportunity; Using the following script I’m unable to “Catch” the errors into the $ErrorMessage2012R2 variable.
Thanks in advance for your input and rebukes.
Norm
SCRIPT
$servers2012R2 = Get-Datacenter -Name “WVHQ” | Get-VM | where { ($.PowerState -eq “PoweredOn”) -and ($.Guest.OSFullName -like “2012” -and $.Name -cnotlike “TEST*” -and $.Name -cnotlike “Test*” -and $.Name -cnotlike “test*” -and $.Name -cnotlike “W2K*”) } `
| Select-Object -ExpandProperty Name | Sort
#Using a foreach loop to determine current version of PowerShell with try catch to collect errors.
Clear-Content -Path D:\PowerShell_temp\psversion_2012R2_error.txt
$result2012R2 = foreach ($server2012R2 in $servers2012R2) {
Try {
Invoke-Command -Computername $server2012R2 -Scriptblock {$PSVersionTable.psversion}
} catch [System.Management.Automation.Remoting.PSRemotingTransportException] {
$ErrorMessage2012R2 = "Server Name: $($_.TargetObject) $server2012R2, $($_.Exception.Message)"
}
}
Add-Content -Path D:\Powershell_temp\psversion_2012R2_error.txt -Value $ErrorMessage2012R2
OUTPUT FROM $ERROR
$error[0] | select -Property *
writeErrorStream : True
PSMessageDetails :
Exception : System.Management.Automation.Remoting.PSRemotingTransportException: Connecting to remote server FwSQL604 failed with the following error message : WinRM cannot
process the request. The following error with errorcode 0x80090322 occurred while using Kerberos authentication: An unknown security error occurred.
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.
TargetObject : FwSQL604
CategoryInfo : OpenError: (FwSQL604:String) , PSRemotingTransportException
FullyQualifiedErrorId : -2144108387,PSSessionStateBroken
ErrorDetails : [FwSQL604] Connecting to remote server FwSQL604 failed with the following error message : WinRM cannot process the request. The following error with errorcode
0x80090322 occurred while using Kerberos authentication: An unknown security error occurred.
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.
InvocationInfo :
ScriptStackTrace :
PipelineIterationInfo : {}