### Retrieve Storage Libraries and Disk Space - PowerShell Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Demonstrates how to retrieve storage resource libraries (disk, tape, cloud) and their capacity information. Includes examples for getting specific libraries, libraries by media agent, and detailed disk space information for libraries. ```powershell # Get all libraries Get-CVLibrary # Get specific library with all properties $library = Get-CVLibrary -Name 'LIBRARY01' -AllProperties $library | Select-Object libraryName, @{N='TotalCapacityGB';E={[math]::Round($_.magLibSummary.totalCapacity/1GB,2)}}, @{N='FreeSpaceGB';E={[math]::Round($_.magLibSummary.freeSpace/1GB,2)}} # Get libraries by media agent Get-CVLibrary -MediaAgentName 'PRODDEDUPE3' # Get disk space for library $space = Get-CVDiskSpace -LibraryName 'LIBRARY01' $space | ForEach-Object { [PSCustomObject]@{MountPath = $_.mountPath TotalGB = [math]::Round($_.totalCapacity/1GB, 2) UsedGB = [math]::Round($_.usedSpace/1GB, 2) FreeGB = [math]::Round($_.freeSpace/1GB, 2) UsedPercent = [math]::Round(($_.usedSpace/$_.totalCapacity)*100, 2) } } | Format-Table # Monitor disk space across all libraries Get-CVLibrary | ForEach-Object { $space = Get-CVDiskSpace -LibraryName $_.libraryName if ($space.freeSpace/$space.totalCapacity -lt 0.2) { Write-Warning "Library $($_.libraryName) has less than 20% free space" } } ``` -------------------------------- ### Backup Commvault Virtual Machine Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Initiates backup jobs for Commvault virtual machines. Supports specifying backup type (Full, Incremental) and filtering by VM name, GUID, or through pipeline input. Includes examples for different scenarios and output format. ```powershell # Full VM backup Backup-CVVirtualMachine -Name 'WebServer01' -BackupType Full # Incremental VM backup Backup-CVVirtualMachine -Name 'AppServer01' -BackupType Incremental # Backup by VM GUID Backup-CVVirtualMachine -GUID '50234d56-789a-1234-bcde-f0123456789a' -BackupType Full # Output: # Initiated backup job [12453] for VM [WebServer01]... # Pipeline example: Backup all VMs matching pattern Get-CVVirtualMachine -Status Protected | Where-Object { $_.name -like 'Web*' } | ForEach-Object { Backup-CVVirtualMachine -GUID $_.GUID -BackupType Incremental } # Backup VMs in specific resource pool $vms = Get-CVVirtualMachine -ClientName 'vCenter01' -Status Protected | Where-Object { $_.resourcePool -eq 'Production' } foreach ($vm in $vms) { Backup-CVVirtualMachine -Name $vm.name -BackupType Full Start-Sleep -Seconds 5 } ``` -------------------------------- ### Get Commvault Storage Policy Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves Commvault storage policies, which define data retention, copy configurations, and deduplication settings. Examples show how to get all policies, a specific policy with all properties, and list basic information by ID. ```powershell # Get all storage policies Get-CVStoragePolicy # Get specific storage policy with all properties $policy = Get-CVStoragePolicy -Name 'PrimaryStorage' -AllProperties $policy | Select-Object storagePolicyName, @{N='Copies';E={$_.copy.count}}, @{N='RetentionDays';E={$_.copy[0].retentionRules.retainBackupDataForDays}} # Output: # storagePolicyName Copies RetentionDays # ----------------- ------ ------------- # PrimaryStorage 2 30 # Get policy by ID Get-CVStoragePolicy -Id 42 # List all storage policies with basic info Get-CVStoragePolicy | Select-Object storagePolicyId, storagePolicyName | Format-Table ``` -------------------------------- ### Start Commvault Workflow Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Executes a Commvault workflow on demand. Workflows can be started by name or ID. For workflows requiring input parameters, it prompts interactively. ```powershell # Start workflow by name Start-CVWorkflow -Name 'DBMaintenance' # Start workflow by ID Start-CVWorkflow -Id 7 # Output: # Initiated workflow job [12457]... # Pipeline example: Get and start workflow Get-CVWorkflow -Name 'NightlyCleanup' | Start-CVWorkflow # Start multiple workflows sequentially $workflows = @('DBMaintenance', 'LogCleanup', 'ReportGeneration') foreach ($workflow in $workflows) { try { Start-CVWorkflow -Name $workflow Write-Host "Started workflow: $workflow" Start-Sleep -Seconds 10 } catch { Write-Error "Failed to start $workflow: $_" } } # Note: Workflows with input parameters will prompt interactively # Example prompt: "Please provide value for parameter: ClientName" ``` -------------------------------- ### Get SQL Server Databases with Commvault CVPowerShellSDK Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves SQL Server databases from Commvault, supporting pagination and filtering by name, instance, availability group, or status. It can also fetch databases across multiple instances. Dependencies include the CVPowerShellSDK. ```powershell # Get databases with pagination Get-CVSQLDatabase -PageSize 100 -PageNumber 1 # Get database by name $db = Get-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' $db | Select-Object databaseName, status, recoveryModel, lastBackupTime # Filter by Availability Group Get-CVSQLDatabase -AAGName 'ProductionAG' | Select-Object databaseName, replicaServer # Get databases by status Get-CVSQLDatabase | Where-Object { $_.status -eq 'Restoring' } # Get all databases across multiple instances $instances = Get-CVSQLInstance foreach ($instance in $instances) { Get-CVSQLDatabase -InstanceId $instance.insId } ``` -------------------------------- ### Get Virtual Machines with Commvault CVPowerShellSDK Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves virtual machines managed by Commvault, allowing filtering by protection status (Protected, Unprotected, All) and specific client names. It also provides details about individual VMs. Dependencies include the CVPowerShellSDK. ```powershell # Get all protected VMs Get-CVVirtualMachine -Status Protected # Get all VMs (protected and unprotected) Get-CVVirtualMachine -Status All # Get VMs for specific client Get-CVVirtualMachine -ClientName 'vCenter01' -Status All # Get VM details $vm = Get-CVVirtualMachine -Status Protected | Where-Object { $_.name -eq 'WebServer01' } $vm | Select-Object name, GUID, vmHost, powerStatus ``` -------------------------------- ### Get Commvault Schedule Policy Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves Commvault schedule policies, allowing filtering by client, subclient, and schedule type. It displays details such as task name, ID, type, and status. Examples show how to retrieve all policies, specific policies, and expand task details. ```powershell # Get all schedule policies Get-CVSchedulePolicy # Get schedule policies for specific subclient Get-CVSchedulePolicy -ClientName 'FileServer01' -SubclientName 'default' # Get specific policy by name $policy = Get-CVSchedulePolicy -Name 'DailyFullBackup' $policy | Select-Object taskName, taskId, taskType, isDisabled # Output: # taskName taskId taskType isDisabled # -------- ------ -------- ---------- # DailyFullBackup 229 Immediate False # Get workflow schedule policies Get-CVSchedulePolicy -ScheduleType Workflow # Expand task details Get-CVSchedulePolicy -ClientName 'SQLServer01' -SubclientName 'ProductionDBs' | Select-Object -ExpandProperty task | Select-Object taskName, isDisabled, @{N='NextRunTime';E={$_.subTasks[0].pattern.startTime}} # Get all disabled policies Get-CVSchedulePolicy | Where-Object { $_.task.isDisabled -eq $true } ``` -------------------------------- ### Disconnect from CommServe Session - PowerShell Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Provides examples for disconnecting from the CommServe server, releasing the REST API session token. Includes a complete session example with connection, operations, and guaranteed disconnection using try-finally blocks. ```powershell # Disconnect from CommServe Disconnect-CVServer # Complete session example try { # Connect Connect-CVServer -Server 'commserve.company.com' -Credential $credential # Perform operations $clients = Get-CVClient $jobs = Get-CVJob # Process data... } finally { # Always disconnect Disconnect-CVServer } # Session management with error handling Connect-CVServer -Server 'commserve.company.com' -Credential $credential try { # Perform backup operations Backup-CVSubclient -ClientName 'FileServer01' -Name 'default' -BackupType Full # Monitor job Start-Sleep -Seconds 30 $job = Get-CVJob -Limit 1 | Select-Object -First 1 Get-CVJobDetail -JobId $job.jobId } catch { Write-Error "Operation failed: $_" } finally { Disconnect-CVServer } ``` -------------------------------- ### List Media Agents and Subclient Media Agents - PowerShell Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves a list of all media agents with their IDs and names. Also demonstrates how to get media agents associated with a specific subclient, including pipeline usage. ```powershell # List all media agents with IDs Get-CVMediaAgent | ForEach-Object { [PSCustomObject]@{Name = $_.mediaAgent.mediaAgentName Id = $_.mediaAgent.mediaAgentId } } | Format-Table # Get media agents for specific subclient Get-CVSubclientMediaAgent -ClientName 'FileServer01' -Name 'default' # Pipeline example Get-CVSubclient -ClientName 'SQLServer01' | Get-CVSubclientMediaAgent ``` -------------------------------- ### Get Commvault Media Agents Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves information about Commvault Media Agents, which are responsible for data transfer operations during backup and restore. Can retrieve all Media Agents or a specific one by name. ```powershell # Get all media agents Get-CVMediaAgent # Get specific media agent by name $ma = Get-CVMediaAgent -Name 'PRODDEDUPE3' $ma | Select-Object mediaAgent # Output: # mediaAgent # ---------- ``` -------------------------------- ### Get Commvault Workflows Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves workflows (automated tasks) from the CommServe. Workflows can be fetched individually by name or ID, or all available workflows can be listed. ```powershell # Get all workflows Get-CVWorkflow # Get specific workflow by name $workflow = Get-CVWorkflow -Name 'DBMaintenance' $workflow | Select-Object workflowName, workflowId, description # Output: # workflowName workflowId description # ------------ ---------- ----------- # DBMaintenance 7 Database maintenance workflow # Get workflow by ID Get-CVWorkflow -Id 7 # List all workflows with deployment info Get-CVWorkflow | Select-Object -ExpandProperty entity | Select-Object workflowName, workflowId | Format-Table ``` -------------------------------- ### Retrieve Commvault Clients (PowerShell) Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves a list of Commvault clients (backup agents) from the CommCell. Supports filtering by name, pagination for large lists, and retrieving all properties for a specific client. Clients represent machines with Commvault agents installed. The output can include client details like clientId, clientName, osName, and lastBackupTime. ```powershell # Get all clients Get-CVClient # Get specific client by name Get-CVClient -Name 'SQLServer01' # Get clients with pagination Get-CVClient -PageSize 50 -PageNumber 1 # Get all properties for a client $client = Get-CVClient -Name 'FileServer01' -AllProperties $client | Select-Object clientId, clientName, osName, @{N='LastBackup';E={$_.lastBackupTime}} # Output: # clientId clientName osName LastBackup # -------- ---------- ------ ---------- # 145 FileServer01 Windows Server 2019 Standard 11/13/2025 02:30:15 # Get multiple clients via pipeline 'SQLServer01','FileServer01','WebServer01' | ForEach-Object { Get-CVClient -Name $_ } # Filter clients by OS type Get-CVClient | Where-Object { $_.osName -like '*Linux*' } ``` -------------------------------- ### Get Storage Policy Copy Details Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves details of a storage policy's copy, including its name, library, media agent, and deduplication status. It uses the Get-CVStoragePolicy cmdlet and selects specific properties for display. ```powershell $policy = Get-CVStoragePolicy -Name 'PrimaryStorage' -AllProperties $policy.copy | Select-Object copyName, library, mediaAgent, deduplication | Format-Table ``` -------------------------------- ### Enable and Disable Commvault Schedule Policy Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Enables or disables Commvault schedule policies to control automated backup execution. Supports identification by name or ID, and can be used in pipeline operations. Examples demonstrate enabling/disabling specific policies and managing policies in bulk for maintenance. ```powershell # Enable policy by name Enable-CVSchedulePolicy -Name 'DailyFullBackup' # Enable policy by ID Enable-CVSchedulePolicy -Id 229 # Disable policy Disable-CVSchedulePolicy -Name 'WeekendBackup' # Pipeline example: Enable all policies for a subclient Get-CVSchedulePolicy -ClientName 'FileServer01' -SubclientName 'default' | Enable-CVSchedulePolicy # Pipeline example: Disable all workflow policies Get-CVSchedulePolicy -ScheduleType Workflow | Disable-CVSchedulePolicy # Maintenance mode: Disable all backup policies $policies = Get-CVSchedulePolicy | Where-Object { $_.task.taskType -eq 'Immediate' } $policies | Disable-CVSchedulePolicy Write-Host "Disabled $($policies.Count) backup policies for maintenance" # Re-enable after maintenance $policies | Enable-CVSchedulePolicy ``` -------------------------------- ### Mount SQL Server Databases using Commvault CVPowerShellSDK Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Creates live mounts of SQL Server database backups for instant access without a full restore. It supports mounting to specific instances, retrieving active mounts, checking mount status, and unmounting databases. Dependencies include the CVPowerShellSDK. ```powershell # Mount database with default mount name Mount-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' ` -MountName 'ProductionDB_Mount' # Mount to specific instance Mount-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' ` -MountName 'ProductionDB_TestMount' ` -DestinationInstance 'TestSQLServer\MSSQLSERVER' # Get active mounts Get-CVSQLClone -ClientName 'SQLServer01' # Check mount status $clones = Get-CVSQLClone -InstanceName 'MSSQLSERVER' $clones | Select-Object cloneId, databaseName, status, createdTime | Format-Table # Unmount database $clone = Get-CVSQLClone -InstanceName 'MSSQLSERVER' | Where-Object { $_.databaseName -eq 'ProductionDB_Mount' } Remove-CVSQLClone -CloneId $clone.cloneId ``` -------------------------------- ### Mount Commvault Virtual Machine Live Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Performs a live mount of a virtual machine backup to an ESX host for instant recovery or testing. Supports specifying the ESX host, custom VM names, resource pools, and mounting from specific backup times. Includes commands for checking active mounts and dismounting. ```powershell # Mount VM to ESX host Mount-CVVirtualMachine -Name 'WebServer01' -ESXHost 'esxi02.company.com' # Mount with custom VM name Mount-CVVirtualMachine -Name 'WebServer01' ` -ESXHost 'esxi02.company.com' ` -VMName 'WebServer01_TestMount' # Mount with resource pool Mount-CVVirtualMachine -Name 'AppServer01' ` -ESXHost 'esxi03.company.com' ` -ResourcePool 'Testing' ` -VMName 'AppServer01_Test' # Output: # Initiated live mount job [12454] for VM [WebServer01]... # Check active live mounts Get-CVVirtualMachineLiveMount -Name 'WebServer01' # Dismount after testing Dismount-CVVirtualMachine -Name 'WebServer01_TestMount' # Mount from specific backup time $backupTime = Get-CVVirtualMachineBackupTime -Name 'WebServer01' Mount-CVVirtualMachine -Name 'WebServer01' -ESXHost 'esxi02.company.com' -VMName 'WebServer01_PITR' ``` -------------------------------- ### Connect to Commvault Server using Credentials (PowerShell) Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Establishes an authenticated REST API session with the CommServe using username and password. This cmdlet must be run before other SDK functions. It supports both interactive credential prompts and pre-constructed credentials. The output includes session details like Server, User, SessionId, CommCellId, and TokenExpiration. ```powershell # Connect with interactive credential prompt $credential = Get-Credential Connect-CVServer -Server 'commserve.company.com' -Credential $credential # Connect with constructed credentials $password = ConvertTo-SecureString 'P@ssw0rd!' -AsPlainText -Force $credential = New-Object System.Management.Automation.PSCredential('domain\admin', $password) Connect-CVServer -Server '10.10.10.100' -Credential $credential # Verify connection by checking session details Get-CVSessionDetail # Output example: # Server : commserve.company.com # User : domain\admin # SessionId : abc123def456 # CommCellId : 2 # TokenExpiration : 11/14/2025 14:30:00 ``` -------------------------------- ### Backup SQL Server Databases using Commvault CVPowerShellSDK Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Initiates backup jobs for SQL Server databases with support for Full, Incremental, and Differential backup types. Backups can be performed by instance and database name, or by IDs. It supports pipeline operations and scheduled backups for multiple databases. Dependencies include the CVPowerShellSDK. ```powershell # Full backup of a database Backup-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' -BackupType Full # Incremental backup Backup-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' -BackupType Incremental # Backup by database ID Backup-CVSQLDatabase -InstanceId 42 -DatabaseId 156 -BackupType Full # Pipeline example: Backup all databases in an instance Get-CVSQLDatabase -InstanceName 'MSSQLSERVER' | ForEach-Object { Backup-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name $_.databaseName -BackupType Incremental } # Scheduled full backup for multiple databases $databases = @('ProductionDB', 'ReportingDB', 'AnalyticsDB') foreach ($db in $databases) { try { Backup-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name $db -BackupType Full Write-Host "Successfully started backup for $db" } catch { Write-Error "Failed to backup $db: $_" } } ``` -------------------------------- ### Restore SQL Server Databases using Commvault CVPowerShellSDK Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Restores SQL Server databases to the same or different instances, supporting overwrite and renaming. It also allows for point-in-time recovery. Dependencies include the CVPowerShellSDK. ```powershell # In-place restore (same instance, same name) Restore-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' # Restore to different instance Restore-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' ` -DestinationInstance 'DevSQLServer\MSSQLSERVER' # Restore with different database name Restore-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' ` -DestinationDatabase 'ProductionDB_Restored' ` -DestinationInstance 'TestSQLServer\MSSQLSERVER' # Restore with overwrite Restore-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' ` -DestinationInstance 'MSSQLSERVER' ` -Overwrite # Point-in-time restore $restoreTime = Get-Date '2025-11-13 14:30:00' Restore-CVSQLDatabase -InstanceName 'MSSQLSERVER' -Name 'ProductionDB' ` -ToTime $restoreTime ` -DestinationDatabase 'ProductionDB_PITR' ``` -------------------------------- ### Backup File System Data Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Initiates a backup job for specified file system paths on a client. Supports both 'Full' and 'Incremental' backup types. Can back up single paths, multiple paths, or directories dynamically. ```powershell # Backup specific path Backup-CVClientFileSystem -ClientName 'FileServer01' -BackupType Full -Path 'C:\ImportantData' # Backup multiple paths $paths = @('C:\Users', 'D:\Shares', 'E:\Projects') Backup-CVClientFileSystem -ClientName 'FileServer01' -BackupType Incremental -Path $paths # Output: # Initiated backup job [12455] for client [FileServer01]... # Incremental backup Backup-CVClientFileSystem -ClientName 'FileServer01' -BackupType Incremental -Path 'C:\Data' # Backup home directory for all users $users = Get-ChildItem 'C:\Users' -Directory | Where-Object { $_.Name -notmatch 'Public|Default' } foreach ($user in $users) { Backup-CVClientFileSystem -ClientName 'FileServer01' -BackupType Incremental -Path $user.FullName } ``` -------------------------------- ### Retrieve and Manage Commvault Subclients (PowerShell) Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves subclient configurations for a specified client, defining data sources and backup policies. Supports retrieving all subclients for a client, specific subclients by name, and all properties. Can be used with pipelines and to update subclient properties like description. ```powershell # Get all subclients for a client Get-CVSubclient -ClientName 'SQLServer01' # Get specific subclient by name Get-CVSubclient -ClientName 'SQLServer01' -Name 'default' # Get subclient with all properties $subclient = Get-CVSubclient -ClientName 'FileServer01' -Name 'UserData' -AllProperties $subclient.content | Select-Object path # Output: # path # ---- # C:\Users\ # D:\Shares\UserData\ # Pipeline example: Get all subclients from multiple clients Get-CVClient | Where-Object { $_.clientName -like 'SQL*' } | ForEach-Object { Get-CVSubclient -ClientName $_.clientName } # Update subclient properties Get-CVSubclient -ClientName 'SQLServer01' -Name 'default' | Set-CVSubclient -Description 'Production SQL databases' ``` -------------------------------- ### Connect to Commvault Server using Access Token (PowerShell) Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Establishes an authenticated REST API session using a pre-generated access token, suitable for automated scripts where embedding credentials is not desired. It requires the server address and the access token. Session verification is performed using Get-CVSessionDetail. ```powershell # Connect using access token $accessToken = 'QSDK abc123def456ghi789jkl012mno345pqr678stu901vwx234yz' Connect-CVServerWithAccessToken -Server 'commserve.company.com' -AccessToken $accessToken # Verify session Get-CVSessionDetail | Select-Object Server, User, SessionId # Output: # Server User SessionId # ------ ---- --------- # commserve.company.com serviceaccount xyz789abc123 ``` -------------------------------- ### Backup-CVSubclient: Initiate Backups for Commvault Subclients Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Initiates a backup job for a specified subclient. Supports various backup types like Full, Incremental, Differential, and Synthetic Full. Can be used with client names, subclient names, or subclient IDs. Also supports pipeline input for backing up multiple subclients. ```powershell # Start full backup Backup-CVSubclient -ClientName 'FileServer01' -Name 'default' -BackupType Full # Output: # Initiated backup job [12345] on subclient [default] for client [FileServer01]... # Start incremental backup Backup-CVSubclient -ClientName 'SQLServer01' -Name 'ProductionDBs' -BackupType Incremental # Pipeline backup: Backup all subclients for a client Get-CVSubclient -ClientName 'FileServer01' | Backup-CVSubclient -BackupType Incremental # Backup specific subclient by ID Backup-CVSubclient -SubclientId 2945 -BackupType Full # Schedule multiple backups $clients = @('AppServer01', 'AppServer02', 'AppServer03') foreach ($client in $clients) { $job = Backup-CVSubclient -ClientName $client -Name 'default' -BackupType Incremental Write-Host "Started job for $client" } ``` -------------------------------- ### Search Protected File System Data Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Browses and searches protected file system data to locate files for restore. Allows searching at the backup set or subclient level. Results can be filtered by size, modification time, or other attributes. ```powershell # Browse filesystem at root Search-CVClientFileSystem -ClientName 'FileServer01' -Path 'C:\' # Search specific folder $results = Search-CVClientFileSystem -ClientName 'FileServer01' -Path 'C:\Data\Reports' $results | Select-Object name, size, modifiedTime | Format-Table # Output: # name size modifiedTime # ---- ---- ------------ # Report_2025.xlsx 1048576 11/13/2025 10:30:00 # Report_2024.xlsx 2097152 12/15/2024 14:45:00 # Find large files $files = Search-CVClientFileSystem -ClientName 'FileServer01' -Path 'D:\Shares' $files | Where-Object { $_.size -gt 100MB } | Sort-Object size -Descending # Search by date $files = Search-CVClientFileSystem -ClientName 'FileServer01' -Path 'C:\Projects' $files | Where-Object { $_.modifiedTime -gt (Get-Date).AddDays(-7) } ``` -------------------------------- ### Count Protected vs Unprotected VMs Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Counts the number of protected and unprotected virtual machines using the Get-CVVirtualMachine cmdlet. It then outputs the counts to the host. ```powershell # Count protected vs unprotected VMs $protected = (Get-CVVirtualMachine -Status Protected).Count $unprotected = (Get-CVVirtualMachine -Status Unprotected).Count Write-Host "Protected: $protected, Unprotected: $unprotected" ``` -------------------------------- ### Get-CVSQLDatabase: Retrieve Protected SQL Server Databases Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves a list of SQL Server databases that are protected by Commvault. Offers extensive filtering options, including instance name, availability group, and database status. Requires specifying client name for specific instances. ```powershell # Get all SQL databases Get-CVSQLDatabase # Get databases for specific instance Get-CVSQLDatabase -InstanceName 'MSSQLSERVER' -ClientName 'SQLServer01' ``` -------------------------------- ### Get-CVJobDetail: Retrieve Detailed Information for Commvault Jobs Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves comprehensive details for a specific Commvault job using its Job ID. Includes phase information, subclient details, storage policy, and job statistics. Useful for analyzing job performance and troubleshooting. ```powershell # Get detailed information for a specific job $jobDetail = Get-CVJobDetail -JobId 12345 $jobDetail | Select-Object jobId, status, jobType, @{N='StartTime';E={$_.jobStartTime}}, @{N='EndTime';E={$_.jobEndTime}} # Output: # jobId status jobType StartTime EndTime # ----- ------ ------- --------- ------- # 12345 Completed Backup 11/13/2025 02:00:00 11/13/2025 02:45:30 # Get job statistics $jobDetail = Get-CVJobDetail -JobId 12345 $stats = $jobDetail.jobDetailInfo.sizeStats [PSCustomObject]@{ TotalBytes = $stats.totalSize SizeOnDisk = $stats.sizeOnDisk Reduction = $stats.compressionPercentage } # Output: # TotalBytes SizeOnDisk Reduction # ---------- ---------- --------- # 524288000000 157286400000 70 # Check if job has errors $jobDetail = Get-CVJobDetail -JobId 12347 if ($jobDetail.jobDetailInfo.failedFiles.count -gt 0) { Write-Host "Job has $($jobDetail.jobDetailInfo.failedFiles.count) failed files" $jobDetail.jobDetailInfo.failedFiles | Select-Object name, errorMessage } ``` -------------------------------- ### Restore File System Data Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Restores files or folders from backup. Supports restoring to the original location ('in-place') or an alternate location ('out-of-place') by specifying a DestinationPath. Can restore single items or multiple items. ```powershell # Restore file to original location Restore-CVClientFileSystem -ClientName 'FileServer01' -Path 'C:\Data\ImportantFile.xlsx' # Restore to alternate location Restore-CVClientFileSystem -ClientName 'FileServer01' ` -Path 'C:\Data\ImportantFile.xlsx' ` -DestinationPath 'C:\Restore\ImportantFile.xlsx' # Restore entire folder Restore-CVClientFileSystem -ClientName 'FileServer01' ` -Path 'C:\Projects\ProjectA' ` -DestinationPath 'C:\Restore\ProjectA' # Output: # Initiated restore job [12456] for client [FileServer01]... # Restore multiple files $files = @('C:\Data\file1.docx', 'C:\Data\file2.pdf', 'C:\Data\file3.xlsx') foreach ($file in $files) { Restore-CVClientFileSystem -ClientName 'FileServer01' -Path $file -DestinationPath "C:\Recovery\$(Split-Path $file -Leaf)" } ``` -------------------------------- ### Suspend-CVJob and Resume-CVJob: Manage Commvault Job States Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Allows pausing (`Suspend-CVJob`) and resuming (`Resume-CVJob`) running Commvault jobs. This is useful for maintenance windows or managing system resources. Both cmdlets support pipeline input. ```powershell # Suspend a running job Suspend-CVJob -JobId 12346 # Resume a suspended job Resume-CVJob -JobId 12346 # Pipeline example: Suspend all backup jobs for maintenance Get-CVJob | Where-Object { $_.jobType -eq 'Backup' -and $_.status -eq 'Running' } | Suspend-CVJob # Resume all suspended jobs after maintenance Get-CVJob | Where-Object { $_.status -eq 'Suspended' } | Resume-CVJob # Maintenance window automation # Suspend jobs $suspendedJobs = Get-CVJob | Where-Object { $_.status -eq 'Running' } $suspendedJobs | Suspend-CVJob Write-Host "Suspended $($suspendedJobs.Count) jobs for maintenance" # Perform maintenance... Start-Sleep -Seconds 3600 # Resume jobs $suspendedJobs | Resume-CVJob Write-Host "Resumed jobs after maintenance" ``` -------------------------------- ### Get-CVJob: Retrieve Commvault Jobs with Filtering Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Retrieves a list of jobs (backup, restore, etc.) from the CommCell. Supports filtering by job status, completion time, and limits. Can be used to monitor active jobs or retrieve historical job data. ```powershell # Get all active jobs Get-CVJob # Get completed jobs from last 24 hours (86400 seconds) Get-CVJob -CompletedJobLookupTime 86400 | Format-Table jobId, status, jobType, percentComplete # Output: # jobId status jobType percentComplete # ----- ------ ------- --------------- # 12345 Completed Backup 100 # 12346 Running Restore 67 # 12347 Failed Backup 100 # Get last 50 jobs Get-CVJob -Limit 50 # Get jobs from last week (604800 seconds) Get-CVJob -CompletedJobLookupTime 604800 | Where-Object { $_.status -eq 'Failed' } # Monitor active jobs $activeJobs = Get-CVJob | Where-Object { $_.status -eq 'Running' } $activeJobs | Select-Object jobId, appTypeName, @{N='Client';E={$_.subclient.clientName}}, percentComplete ``` -------------------------------- ### Check Storage Policy Retention Rules Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Checks the retention rules configured for the first copy of a specified storage policy. It uses the Get-CVStoragePolicy cmdlet and accesses the retentionRules property of the first copy. ```powershell $policy = Get-CVStoragePolicy -Name 'ArchiveStorage' -AllProperties $policy.copy[0].retentionRules ``` -------------------------------- ### Stop-CVJob: Terminate Commvault Jobs Source: https://context7.com/commvault/cvpowershellsdk/llms.txt Terminates a running or suspended Commvault job immediately. The `-Force` parameter can be used to kill jobs without confirmation. Supports pipeline input for stopping multiple jobs. ```powershell # Stop a specific job Stop-CVJob -JobId 12346 # Stop job without confirmation Stop-CVJob -JobId 12346 -Force # Pipeline example: Stop all failed jobs Get-CVJob | Where-Object { $_.status -eq 'Failed' } | Stop-CVJob -Force # Stop multiple jobs $jobsToStop = @(12346, 12347, 12348) foreach ($jobId in $jobsToStop) { Stop-CVJob -JobId $jobId -Force Write-Host "Stopped job $jobId" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.