Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Hello everyone, hoping i can get some help on a strange issue i've been having.
As part of a script which includes some PowerCLI commands i need to connect to our vCenter server, since this takes a few moments i tried putting it into the "Start Job" Control Set, see code below.
$Credentials=New-Object System.Management.Automation.PSCredential -ArgumentList$User,$Password# <-- These variables are declared from textboxes earlier in the script
Now, no matter what i try i always get an error that i'm not connected to a vCenter server, i even tried hardcoding my username and password with the -User and -Password parameters instead but i get the same result. The strange thing is if i put the Connect-VIServer inside the -CompletedScript block then i connect just fine, but thats no good...
I'm guessing it's a scoping issue but as i said i just can't fiugre this one out,
This topic is 6 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.