• This topic has 5 replies, 1 voice, and was last updated June 6, 2022 by .

Powershell ZertoModule

  • Hi everyone –

    I’ve created a wrapper for the REST API that converts most of the calls to pretty standard Powershell commands.  Its pretty simple to use and so far I’ve covered the majority of the API, although some of the VGPSettings are not finished.

    https://www.powershellgallery.com/packages/ZertoModule

    Example usage:

     
    <pre class=”EnlighterJSRAW” data-enlighter-language=”csharp”>PS C:\Scripts> Set-Item ENV:ZertoServer “il1zerto.test.com”
    PS C:\Scripts> Set-Item ENV:ZertoPort “9669”

    PS C:\Scripts> Set-ZertoAuthToken -ZertoUser MyDomain\MyUserName

    PS C:\Scripts> Get-ZertoLocalSite

    ContactEmail : noc@test.com
    ContactName : NOC
    ContactPhone : 847-555-1212
    IpAddress : 10.77.199.10
    IsReplicationToSelfEnabled : True
    Link : @{href=https://10.77.199.10:9669/v1/localsite; identifier=d492497e-6793-4ec8-b44b-f60a43aef445; rel=; type=LocalSiteApi}
    Location : Franklin Park, IL
    SiteIdentifier : d492497e-6793-4ec8-b44b-f60a43aef445
    SiteName : Zerto-IL1
    SiteType : VCenter
    UtcOffsetInMinutes : -360
    Version : 5.0.0

     

    Starting a VPG Failover  Test:
    <pre class=”EnlighterJSRAW” data-enlighter-language=”csharp”>Start-ZertoVPGFailoverTest -ZertoVpgIdentifier (Get-ZertoVPGID -VpgName ‘GROUP01-CHALB’)

    . . .

    Stop-ZertoVPGFailoverTest -ZertoVpgIdentifier (Get-ZertoVPGID -VpgName ‘GROUP01-CHALB’) -FailoverTestSuccess ‘True’ -FailoverTestSummary ‘Sucessful Test’ -Verbose

     

    Chris@ChristopherLewis.com

    Hi Christopher! Thanks for sharing!

    Have you also checked out our “Automating Zerto Virtual Replication with PowerShell & REST APIs” whitepaper? If not, please do and let us know what you think!

    Thanks and keep going! 🙂

    ~harry

    Follow me: www.twitter.com/HarrySiii

    Harry –

    Yes, that doc was the primary inspiration for the module. I initially just wrote a function to do the authentication, then a function to retrieve a VM’s ID, next thing you know, I had made functions for 80% of the REST GET commands.

    Chris

    Chris@ChristopherLewis.com

    Christopher,

    Great Module. I’ve been trying to use it to create a VPG with Failover Network Configurations and I’ve been getting the error:

    VERBOSE: POST https://<fqdn of ZVM>:9669/v1/vpgSettings/81d32cca-faa0-4b7a-a003-985aae567136/commit with
    0-byte payload
    Unknown web error: 400 : Bad Request
    At C:\Program Files\WindowsPowerShell\Modules\ZertoModule\1.0.8\ZertoModule.psm1:1830 char:17
    + … throw “Unknown web error: ” + $err.Exception.Response.Sta …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OperationStopped: (Unknown web error: 400 : Bad Request:String) [], RuntimeException
    + FullyQualifiedErrorId : Unknown web error: 400 : Bad Request

    Also, is there a way to pass credentials to the cmdlets e.g Set-ZertoAuthToken, which accepts -ZertoUser but no password.

    Regards

     

    Mike van

     

    First off, Brilliant Module!

    +1 for passing creds to the cmdlets. would be super useful for adding into an existing decom script I have

You must be logged in to create new topics. Click here to login