@@ -532,6 +532,189 @@ function Get-CVClientGroup {
532532 }
533533}
534534
535+ function Add-EntitytoSchedulePolicy {
536+ <#
537+ . SYNOPSIS
538+ Method to add an entity to a schedule policy
539+
540+ . DESCRIPTION
541+ Method to add an entity to a schedule policy
542+
543+ . LINK
544+ https://documentation.commvault.com/11.24/essential/48824_rest_api_post_schedule_policy_add_entity.html
545+
546+ . PARAMETER taskId
547+ Schedule policy ID
548+
549+ . OUTPUTS
550+ Outputs [PSCustomObject]
551+
552+ . EXAMPLE
553+ PS C:\>$body = "subclientId=300"
554+ PS C:\>$policy = Get-CVSchedulePolicy -Name testpolicy
555+ PS C:\>$policy | Add-EntitytoSchedulePolicy -Body $body -Forc
556+
557+ Output:
558+ errorMessage errorCode
559+ ------------ ---------
560+ 0
561+ . NOTES
562+ Author: Jnanesh D
563+ Company: Commvault
564+ #>
565+
566+ [CmdletBinding (DefaultParameterSetName = ' Default' )]
567+ [OutputType ([PSCustomObject ])]
568+ param (
569+
570+ [Parameter (Mandatory = $True , ParameterSetName = " ByObject" , ValueFromPipeline = $True , ValueFromPipelineByPropertyName = $True )]
571+ [ValidateNotNullorEmpty ()]
572+ [System.Object ] $taskObject ,
573+
574+ [Alias (' RequestBody' )]
575+ [Parameter (Mandatory = $True )]
576+ [ValidateNotNullorEmpty ()]
577+ [PSObject ] $Body ,
578+
579+ [Switch ] $Force ,
580+
581+ # Parameter help description
582+ [Parameter (Mandatory = $True , ParameterSetName = " ById" )]
583+ [ValidateNotNullorEmpty ()]
584+ [Int64 ] $taskId
585+
586+ )
587+ begin {
588+ Write-Debug - Message " $ ( $MyInvocation.MyCommand ) : process"
589+ try {
590+ $sessionObj = Get-CVSessionDetail $MyInvocation.MyCommand.Name
591+ $endpointSave = $sessionObj.requestProps.endpoint
592+ }
593+ catch {
594+ throw $_
595+ }
596+ }
597+ process { Write-Debug - Message " $ ( $MyInvocation.MyCommand ) : process"
598+
599+ try {
600+ $sessionObj.requestProps.endpoint = $endpointSave
601+ if ($PSCmdlet.ParameterSetName -eq " ById" ){
602+ $sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace (' {taskId}' , $taskId )
603+ }
604+ else {
605+ $taskId = $taskObject.task.taskId
606+ $sessionObj.requestProps.endpoint = $sessionObj.requestProps.endpoint -creplace (' {taskId}' , $taskId )
607+ }
608+
609+ $body = $Body
610+ $payload = @ { }
611+ $headerObj = Get-CVRESTHeader $sessionObj
612+ $payload.Add (' headerObject' , $headerObj )
613+ $payload.Add (' body' , $body )
614+ $validate = ' errorMessage'
615+
616+ if ($Force ) {
617+ $response = Submit-CVRESTRequest $payload $validate
618+ Write-Output $response.Content
619+ }
620+ else {
621+ $response = Submit-CVRESTRequest $payload $validate - DryRun
622+ }
623+
624+ }
625+ catch {
626+ throw $_
627+ }
628+ }
629+
630+ end { Write-Debug - Message " $ ( $MyInvocation.MyCommand ) : end"
631+ }
632+ }
633+
634+ function Set-CVSubclient {
635+ <#
636+ . SYNOPSIS
637+ Method to create a new subclient.
638+
639+ . DESCRIPTION
640+ Method to create a new subclient.
641+
642+ . PARAMETER Body
643+ Request body for the subclient creation : Refer to https://documentation.commvault.com/11.24/essential/49174_rest_api_post_subclient.html.
644+
645+ . EXAMPLE
646+ PS C:\>$req = @"
647+ {
648+ "subClientProperties": {
649+ "subClientEntity": {
650+ "clientName": "Side1",
651+ "appName": "File System",
652+ "backupsetName": "DefaultBackupset",
653+ "subclientName": "subclient001"
654+ }
655+ }
656+ }
657+ "@
658+ PS C:\>$propobj = $prop | ConvertFrom-Json
659+ PS C:\>Set-CVSubclient -body $propobj
660+
661+ . OUTPUTS
662+ Outputs [PSCustomObject]
663+
664+ . NOTES
665+ Author: Jnanesh D
666+ Company: Commvault
667+ #>
668+ [CmdletBinding (DefaultParameterSetName = ' Default' , SupportsShouldProcess )]
669+ [OutputType ([PSCustomObject ])]
670+ param (
671+ [Alias (' RequestBody' )]
672+ [Parameter (Mandatory = $True )]
673+ [ValidateNotNullorEmpty ()]
674+ [PSObject ] $Body ,
675+
676+ [Switch ] $Force
677+ )
678+
679+ begin { Write-Debug - Message " $ ( $MyInvocation.MyCommand ) : begin"
680+
681+ try {
682+ $sessionObj = Get-CVSessionDetail $MyInvocation.MyCommand.Name
683+ $endpointSave = $sessionObj.requestProps.endpoint
684+ }
685+ catch {
686+ throw $_
687+ }
688+ }
689+ process { Write-Debug - Message " $ ( $MyInvocation.MyCommand ) : process"
690+
691+ try {
692+ $sessionObj.requestProps.endpoint = $endpointSave
693+ $body = ($Body | ConvertTo-Json - Depth 10 )
694+ $payload = @ { }
695+ $headerObj = Get-CVRESTHeader $sessionObj
696+ $payload.Add (' headerObject' , $headerObj )
697+ $payload.Add (' body' , $body )
698+ $validate = ' errorMessage'
699+
700+ if ($Force -or $PSCmdlet.ShouldProcess ($Body )) {
701+ $response = Submit-CVRESTRequest $payload $validate
702+ }
703+ else {
704+ $response = Submit-CVRESTRequest $payload $validate - DryRun
705+ }
706+ Write-Output $response.Content
707+ }
708+ catch {
709+ throw $_
710+ }
711+ }
712+
713+ end { Write-Debug - Message " $ ( $MyInvocation.MyCommand ) : end"
714+ }
715+
716+ }
717+
535718
536719function Get-CVSubclient {
537720<#
0 commit comments