With PowerCLI you can save your server session and restore it later. The VimClient class includes several methods for saving and restoring server sessions. This enables you to maintain sessions across applications.

Instead of storing passwords in applications, you can call the LoadSession() method with the name of the session file. The session file does not expose password information, and this enhances security.

This example illustrates how to save a server session to a file by calling SaveSession() with the file name.

VimClient client1 = new VimClient();
client1.Connect("https://hostname/sdk");
client1.Login("user", "pass");
client1.SaveSession("VimSession.txt");

This example illustrates how to load a server session in another application by calling LoadSession() with the name of the session file.

VimClient client2 = new VimClient();
client2.Connect("https://hostname/sdk");
client2.LoadSession("VimSession.txt");
client2.FindEntityView(typeof(VirtualMachine), null, null, null);