Script to get media agents associated to a client/sublicent

Last post 13 hours, 11 minutes ago by jng. 4 replies.
Sort Posts: Previous Next
  • Script to get media agents associated to a client/sublicent
    Posted: 01-25-2018, 11:36 AM

    Hello, I have a list of about 100 clients, and I would like to do a powershell script, using the REST API, to loop through them, and for each, check for each agent/subclient all storagepolicies associated and for each of those, get all media agents.

    Is this possibe using the REST API or should I go another path?

     

    Thank you!

    Diego

  • Re: Script to get media agents associated to a client/sublicent
    Posted: 01-25-2018, 5:49 PM

    Looking at the POSTMAN collection on https://api.commvault.com

    • GET /Client would give you a list of Clients & their respective Client IDs
    • GET /Subclient would then give you all subclients for a given client irrespective of backupsets, instances, agents
    • GET /Subclient/{x} (Subclient Properties) would then give you the storage policy/policies
    Then...
    • GET /MediaAgent would get you a list of MA's
    • GET /StoragePolicyListAssociatedToMediaAgent would get you a list of Storage Policies associated with each MA
    At which point you could then blend the data and end up with your mapping of subclients <-> media agents.
    Curious question - what's the solution you're trying to script here?

    Cheers,
    Luke
    (@cv_skywalker)
  • Re: Script to get media agents associated to a client/sublicent
    Posted: 01-26-2018, 7:43 AM

    Thanks! I will try that

  • Re: Script to get media agents associated to a client/sublicent
    Posted: 21 hours, 46 minutes ago

    How'd you go with trying those API calls? :)


    Cheers,
    Luke
    (@cv_skywalker)
  • Re: Script to get media agents associated to a client/sublicent
    Posted: 13 hours, 11 minutes ago

    Hi Diegoxom,

    here's an example to try:

    $URL = "http://localhost:81/SearchSvr/CVWebService.svc/QCommand"

    $SCPClientArray = @()

    $SubClientPolicyName = "MySubClientPolicy1"

    $RESTHeaders = @{"Accept" = "application/xml";"Authtoken" = $AuthToken}

    $Body = "qoperation execscript -sn GetSubclientPolicy.sql -si scp=$SubClientPolicyName"

    $ResponseXML = Invoke-RestMethod -Uri $URL -Method Post -ContentType 'text/plain' -Headers $RESTHeaders -Body $Body

    <#output will be something like: <?xml version="1.0" encoding="UTF-8" standalone="no"?><ExecScriptOutput><FieldValue BackupsetName="defaultBackupSet" ClientName="proxy01" /><FieldValue BackupsetName="[] or subclientPolicy [MySubClientPolicy1]. ErrorCode (0)." ClientName="GetSubclientPolicycompleted at Feb 15 2018 12:55PM with parameters client " /></ExecScriptOutput>#>

    If($ResponseXML.CVGui_GenericResp.errorCode){ # Error handling } else {

    $ResponseXML.ExecScriptOutput.FieldValue.Clientname | ForEach-Object {
    If($_ -notlike "*GetSubclientPolicycompleted*") {
    $SCPClientArray += $_ }
The content of the forums, threads and posts reflects the thoughts and opinions of each author, and does not represent the thoughts, opinions, plans or strategies of Commvault Systems, Inc. ("Commvault") and Commvault undertakes no obligation to update, correct or modify any statements made in this forum. Any and all third party links, statements, comments, or feedback posted to, or otherwise provided by this forum, thread or post are not affiliated with, nor endorsed by, Commvault.
Commvault, Commvault and logo, the “CV” logo, Commvault Systems, Solving Forward, SIM, Singular Information Management, Simpana, Commvault Galaxy, Unified Data Management, QiNetix, Quick Recovery, QR, CommNet, GridStor, Vault Tracker, InnerVault, QuickSnap, QSnap, Recovery Director, CommServe, CommCell, SnapProtect, ROMS, and CommValue, are trademarks or registered trademarks of Commvault Systems, Inc. All other third party brands, products, service names, trademarks, or registered service marks are the property of and used to identify the products or services of their respective owners. All specifications are subject to change without notice.
Close
Copyright © 2018 Commvault | All Rights Reserved. | Legal | Privacy Policy