Disconnect from vCenter Server within PowerCLI script

In my previous article I wrote about the problems during logging in to a vCenter Server. The fully automated script disconnecting phase was a little bit problematic. Here is my solution.

The default Disconnect-VIServer command needs a user intervention.

As I check the command help, there are the following useful switches: -Force and -Confirm.

The Disconnect-VIServer –Confirm or the Disconnect-VIServer –Confirm –Force commands not helped for me.

Here is the right syntax.

</pre>
<pre class="brush: powershell;">Disconnect-VIServer -Confirm:$False</pre>
<div>

That’s all!

Advertisements