I'm having a very weird problem with VMware SRM running a script written in PowerShell during a custom step in a test/recovery plan.
The code in question is very simple (edited here for brevity):
$pwx = Get-Content C:\SRM_Scripts\credentials\$($Vserver).txt | ConvertTo-SecureString
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ClusterUser,$pwx
if($Credential.UserName -ne $ClusterUser){
mylogger -LogFile $Log -Message " Unable to retrieve credentials for $Cluster. Cannot continue." -Color Red
exit 1
} else {
mylogger -LogFile $Log -Message " Retrieved credentials for $($Credential.UserName)" -Color Green
}
$ClusterConn = Connect-NcController -Name $Cluster -Vserver $Vserver -Credential $Credential
mylogger -LogFile $Log -Message "Returned properties: Name:$($ClusterConn.Name) Address:$($ClusterConn.Address) Vserver:$($ClusterConn.Vserver) Version:$($ClusterConn.Version)" -Color Yellow
if($ClusterConn.Name -ne $Cluster){
mylogger -LogFile $Log -Message "Unable to connect to $Cluster, check credentials or other connection attributes. Cannot continue." -Color Red
exit 1
} else {
mylogger -LogFile $Log -Message "Connection to $($ClusterConn.Name) established" -Color Green
}
When I run this script (the above code is just a snippit from the larger script) from a PowerShell command prompt launched as the local account that SRM runs as, srmadmin, my script works correctly. When I call this script from within SRM as a custom step in a test/recovery plan, the script dies because Connect-NcController fails to return anything.
I've peppered debugging write-host/logging statements everywhere can I can't for the life of me figure out why this works perfectly when NOT run from within SRM.
Surely someone else has done something with SRM and the PSTK here? Any pointers? I've been beating my head against the wall for quite some time on this. Thanks a lot.