I'm trying to run a .ps1 (PowerCLI) through Operator ' Run Script', and setting its extension like .ps1 and putting the code below:
Param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $Server,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string[]] $VM
)
try
{
#force this to run in 32 bit
if ($env:Processor_Architecture -ne "x86")
{
&"$env:WINDIR\syswow64\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile $myInvocation.Line
exit
}
cd "${env:ProgramFiles(x86)}\VMware\Infrastructure\vSphere PowerCLI"
Add-PSSnapin -Name VMware.VimAutomation.Core | Out-Null
Connect-VIServer 10.8.8.8 -User domain\user -Password 123
Set-Annotation -Entity hostpdi -CustomAttribute "Contact" -Value Poyato
}
catch
{
$error[0].Exception
Exit 1
}
I pointed the user ID and password for a dataset with data from the PAM server (where is installed PowerCLI), as the image below:
When I run the process is looped never stopping.
Someone could tell me why?
tks!
Poyato