I am "Invoking an external script". I have created and passed the VM name as an argument to the PS script. When I run the script on the PS host itself, it runs with no issues. However, when I run it as part of the event broker I get an error.
Here is the script. Pls note that XXX values are where I remarked out identifying information.
param (
$HostName
)
$localuser = "XXX"
$pwdTxt = Get-Content "XXX.txt"
$securePwd = $pwdTxt | ConvertTo-SecureString
$localCred = New-Object System.Management.Automation.PSCredential -ArgumentList $localuser, $securePwd
$domainuser = "XXX"
$pwdTxt2 = Get-Content "XXX2.txt"
$securePwd2 = $pwdTxt2 | ConvertTo-SecureString
$domainCred = New-Object System.Management.Automation.PSCredential -ArgumentList $domainuser, $securePwd2
add-computer -ComputerName $HostName -LocalCredential $localCred –domainname XXX -Credential $domainCred -OUPath XXX
As I mentioned, when running it from the PS server, it runs fine. However, when I run it as part of a vRO workflow, I get an error that my passwords are NULL. Its almost like it can't read the password files, but I checked permissions and they are wide open for testing purposes.