I have put together a quick GUI to log into vcenter and when the user clicks connect it executes "connect-viserver $server -Notdefault -Credential(Get-Credential)
It will popup and get the input; the console screen will show the normal certs error but the session never shows as connected and therefore all the rest of the program fails?
Any tips? Timing issue? Can a wait task be used and how?
Thanks
Can you give more information about the GUI? It looks like the output is redirected and is not going to the console. Error output is a different output stream and does go to the console. But where is the normal output going?
Robert
Perhaps you're running the GUI in another (implicit) namespace ?
Are you using WPF for the GUI ?
Run the rest of your script while you're in the form.
Have a look at my PSTop to see how this can be done.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes I am using WPF for the gui
It is a Add_Click Event:
$connbtn.Add_Click({
$OV = (Connect-VIServer viserver -NotDefault -Credential(Get-Credential))
}
I guess I don't fully understand the - options well enough.. I removed -notdefault option and it worked fine. I am not sure I like that but it will have to do for now unless sombody out there can help me understand the behaviour.
When you do a Connect-VIServer the indentification of that server (beit vCenter of ESX/ESXI server) is stored in the variable $defaultVIServers.
With the -NoDefault switch, the server is not stored in the $defaultVIServers variable.
That means you will have to pass the variable on most of the following PowerCLI cmdlets with the -Server parameter.
By default the other cmdlets take the last connected server for the other PowerCLI cmdlets.
For example
$mySrv = Connect-VIServer -Server xyz -NoDefault $vms = Get-VM -Server $mySrv ... Connect-VIServer -Server xyz $vms = Get-VM ...
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference