VMware Cloud Community
wwsj1967
Contributor
Contributor

Some PowerShell eyes pls.

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.

Reply
0 Kudos
3 Replies
ASavener2
Enthusiast
Enthusiast

Are you sending the path explicitly?

(e.g., $pwdTxt = Get-Content "d:\scripts\localuserpassword.txt")

Reply
0 Kudos
igaydajiev
VMware Employee
VMware Employee

What is the error received?

Reply
0 Kudos
wwsj1967
Contributor
Contributor

I found my problem.  Unfortunately I didn't encrypt the password.  :smileysilly:

Reply
0 Kudos