Solved

How to use Powershell to Disable Subclient?

  • 3 August 2023
  • 10 replies
  • 335 views

Badge +1

Hello All.  I’m attempting to write a script to disable a subclient.  We have hundreds that we don’t require the backup of the File System, so I’d like to disable them.

I can find information about the subclient...

Get-CVSubclient -ClientName qct0bjsql01 | Where-Object { $_.appName -eq "File System" }


clientName    : qct0bjsql01
instanceName  : DefaultInstanceName
displayName   : qct0bjsql01
backupsetId   : 2068
_type_        : 7
commCellName  : cvt0comsrv01
instanceId    : 1
csGUID        : xxxxx
subclientGUID : xxxxx
subclientId   : 4777
clientId      : 5087
appName       : File System
backupsetName : defaultBackupSet
applicationId : 33
subclientName : default
entityInfo    : @{companyId=0; companyName=Commcell}

 

However when I attempt to disable the subclient with this command it fails.

Disable-CVBackupSubclient -SubclientId 4777
Disable-CVBackupSubclient : Invalid URI: The format of the URI could not be determined.
At line:1 char:1
+ Disable-CVBackupSubclient -SubclientId 4777
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Disable-CVBackupSubclient_Disable], UriFormatException
    + FullyQualifiedErrorId : Commvault.Powershell.Cmdlets.DisableCVBackupSubclient_Disable

 

I wonder if there is another way to disable these subclients via Powershell?

Thank you.

icon

Best answer by Rajiv 3 August 2023, 16:41

View original

10 replies

Userlevel 4
Badge +11

Hello @dgzagm4q4cv 

You could try to copy and paste the same command in a notepad line by line, change the required values, make a script of it (.bat) and place it under the path (C:\ProgramFiles\Content Store\Base\DBUpgrade\Commserver\MainUpgrade\DBStoredProcedure) and run the script like this:

Since the values like default backup set name, sub client name, IDA agent type can change, you can easily change it in the script before running it, that would reduce a bit of task for you. 

Best,

Rajiv Singal

Badge +1

Your idea works just fine; use a bit of Excel magic to get all the server names in and it’s good to go. 

Because I wanted to use Powershell and use a foreach loop I did this… 

 


$loginsso = "qlogin"
$command = "qoperation"
$argumentsTemplate = "execscript -sn EnableSCActivityControl.sql -si c={0} -si a=Q_FILESYSTEM -si i=DefaultInstanceName -si b=defaultBackupSet -si s=default -si 0"

# working directory
Set-Location -Path "C:\Program Files\Commvault\ContentStore\Base"

# Login
Start-Process -FilePath $loginsso -ArgumentList "-sso" -NoNewWindow -Wait

$servers = Get-Content -Path "C:\scripts\Servers.txt"

foreach ($server in $servers) {
    $arguments = $argumentsTemplate -f $server
    Start-Process -FilePath $command -ArgumentList $arguments -NoNewWindow -Wait
}
 

 

I’m sure there are ways to make this more efficient, but I’m not a powershell expert.  :-)

Userlevel 4
Badge +11

@dgzagm4q4cv Your script looks far better than mine of course :) since I am also not an expert on power shell. I am glad you found a way out for now to get going, its far better than doing it manually one by one. 

Do let us know if you need any further assistance. 

Best,

Rajiv Singal 

Userlevel 4
Badge +11

Hello @dgzagm4q4cv 

Could you please check https://documentation.commvault.com/2022e/expert/18664_deleting_windows_file_system_subclient_from_command_line_interface.html and let me know if it helps? 

There are alot of subclient configurations via command line using .xml  here: https://documentation.commvault.com/2022e/expert/18657_subclient_configuration.html

Please note for deletion, if you delete a sub client, the data associated to it will also be deleted. 

Best,

Rajiv Singal

Userlevel 3
Badge +10

@dgzagm4q4cv 

Please try the below and let us know if this helps:

Disable-CVSubclient -ClientName <String> -SubclientName <String>

Else you can run the API request as well:

https://documentation.commvault.com/2022e/essential/49184_rest_api_post_subclient_properties.html

Badge +1

I don’t want to delete the subclient, just disable it.  I’m attempting to stay within PowerShell, if possible.

Disable-CVSubclient doesn’t have -ClientName as an option.

Here’s the syntax for the command, which shows some URI stuff the error shows.  How do I form the command to make this disable the client?

SYNTAX
    Disable-CVBackupSubclient -SubclientId <Int64> [-EnableAfterADelay <Int64>] [-Break] [-HttpPipelineAppend <SendAsyncStep[]>] [-HttpPipelinePrepend <SendAsyncStep[]>] [-Proxy <Uri>] 
    [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm] [<CommonParameters>]
    
    Disable-CVBackupSubclient -InputObject <ICommvaultPowerShellIdentity> [-EnableAfterADelay <Int64>] [-Break] [-HttpPipelineAppend <SendAsyncStep[]>] [-HttpPipelinePrepend <SendAsyncStep[]>] [-Proxy 
    <Uri>] [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Also, I wonder if I can use another PowerShell command to disable the subclient vs. using Disable-CVSubclient.  Can one of these do the job?  Backup-CVsubclient or Set-CVsubclient?

 

Thanks,

Dan

 

 

 

 

Userlevel 4
Badge +11

Hello @dgzagm4q4cv 

I believe you are looking to disable the activity control for a specific sub client, like this:

 

Please check this document https://documentation.commvault.com/2022e/expert/EnableSCActivityControl.html

I tested it in my lab as well and it works fine. For disabling the backup, you would have to use -si 0 in the end.

Let me know if that helps. 

Best,

Rajiv Singal

Badge +1

oh!  this is getting good.  I’m able to run the qoperation execute script for one client manually.  Now to figure out how to perform a Powershell foreach loop to execute the qoperation execute for multiple servers. 

Badge +2

Has anyone tried making a similar script for disabling client activity on VM’s?  We tried taking the script above and replacing the a=Q_FILESYSTEM with a=Q_VIRTUAL_SERVER but it does not work.

Badge +2

Has anyone tried making a similar script for disabling client activity on VM’s?  We tried taking the script above and replacing the a=Q_FILESYSTEM with a=Q_VIRTUAL_SERVER but it does not work.

We were able to resolve this today. We don’t use SSO so the script was silently failing. We reviewed the qcommand.log file on the server and found that the script errored out on SSO.

By removing -ArgumentList “-sso” from the script it now prompts for username and password at each run. It now works to disable VM activity without error.

Reply