File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -97,8 +97,12 @@ if (![System.IO.File]::Exists($SecurePwdFilePath)) {
9797$secPwd = Get-Content $SecurePwdFilePath | ConvertTo-SecureString
9898$cred = New-Object System.Management.Automation.PSCredential - ArgumentList $UserName , $secPwd
9999
100- $env_user = Invoke-Command - ComputerName ([Environment ]::MachineName) - Credential $cred - ScriptBlock { $env: USERNAME }
101- Write-Host " About to execute inventory gathering as user: $env_user "
100+ try {
101+ $env_user = Invoke-Command - ComputerName ([Environment ]::MachineName) - Credential $cred - ScriptBlock { $env: USERNAME } - ErrorAction Stop
102+ Write-Host " Executing inventory gathering as user: $env_user ..."
103+ } catch [System.Management.Automation.Remoting.PSRemotingTransportException ] {
104+ Write-Host " Executing inventory gathering..."
105+ }
102106
103107# Load the ScriptBlock $ServerStats:
104108. $ServerStatsPath
You can’t perform that action at this time.
0 commit comments