Connecting to SRM servers

Before you can manage SRM from PowerCLI, you have to connect to the SRM servers you want to manage. Because SRM fails over virtual machines from a protected site to a recovery site, both sites need a vCenter Server and an SRM server. So, if you want to manage both SRM servers, you will have to connect to each of them. After connecting to an SRM server, you can use the ExtensionData property of the output of the Connect-SrmServer cmdlet to access the SRM API.

The Connect-SrmServer cmdlet establishes a connection to an SRM server. The syntax of the Connect-SrmServer cmdlet is given here. The first parameter set is the default. You can use this parameter set if you have a connection to a vCenter Server that has an SRM server associated with it:

Connect-SrmServer [-User <String>] [-Password <SecureString>]
    [-Port <Int32>] [-Protocol <String>] [-Credential <PSCredential>]
    [-RemoteCredential <PSCredential>] [-RemoteUser <String>] 
    [-RemotePassword <SecureString>] [-NotDefault] 
    [-IgnoreCertificateErrors] [-Server <VIServer[]>] [<CommonParameters>]

This parameter set has no required parameters.

The second parameter set is for manually connecting to an SRM server:

Connect-SrmServer [-User <String>] [-Password <SecureString>]
    [-SrmServerAddress] <String> [-Port <Int32>] [-Protocol <String>]
    [-Credential <PSCredential>] [-RemoteCredential <PSCredential>]
    [-RemoteUser <String>] [-RemotePassword <SecureString>] 
    [-NotDefault] [-Locale <String>] [-IgnoreCertificateErrors] 
    [<CommonParameters>]

The -SrmServerAddress parameter is required.

In the following example, we will connect to an SRM server named srmserver and save the output in the variable $srm for later use:

PowerCLI C:> $srm = Connect-SrmServer -SrmServerAddress
    srmserver -User [email protected] -Password TopSecret

After executing the preceding command, the variable $srm has the following value:

PowerCLI C:> $srm


    Name                           Port  User
----                           ----  ----
srmserver                      9086  [email protected]

If you have not saved the output of the Connect-SrmServer cmdlet in a variable, you can use the $DefaultSrmServers variable. The value of this variable is an array containing all of the connected SRM servers.

The ExtensionData property of the $srm variable is our entry to the SRM API. In the following command, we will create a variable $srmApi as a shortcut to the $srm.ExtensionData property. In the rest of this chapter, we will use the variable $srmApi as our connection to the SRM API:

PowerCLI C:> $srmApi = $srm.ExtensionData

In the following command, we will use the Get-member cmdlet to retrieve the methods and properties of the object in the $srmApi variable, as follows:

PowerCLI C:> $srmApi | Get-Member

The output of the preceding command is as follows:

   TypeName: VMware.VimAutomation.Srm.Views.SrmServiceInstance


    Name                          MemberType Definition
----                          ---------- ----------
Equals                        Method     bool Equals(System.Objec...
GetHashCode                   Method     int GetHashCode()
GetPairedSite                 Method     VMware.VimAutomation.Srm...
GetPairedSiteSolutionUserInfo Method     VMware.VimAutomation.Srm...
GetSiteName                   Method     string GetSiteName()
GetSolutionUserInfo           Method     VMware.VimAutomation.Srm...
GetType                       Method     type GetType()
LoginLocale                   Method     void LoginLocale(string ...
LoginRemoteSite               Method     void LoginRemoteSite(str...
LoginRemoteSiteByToken        Method     void LoginRemoteSiteByTo...
LogoutLocale                  Method     void LogoutLocale()
RetrieveContent               Method     VMware.VimAutomation.Srm...
SrmLoginByTokenLocale         Method     void SrmLoginByTokenLoca...
SrmLoginSites                 Method     void SrmLoginSites(strin...
SrmLoginSitesByToken          Method     void SrmLoginSitesByToke...
ToString                      Method     string ToString()
Content                       Property   VMware.VimAutomation.Srm...
MoRef                         Property   VMware.Vim.ManagedObject...
Protection                    Property   VMware.VimAutomation.Srm...
Recovery                      Property   VMware.VimAutomation.Srm...

In the rest of this chapter, you will see some examples of using the methods and properties in the preceding output.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.1.136