public/cbb/Stop-MBSBackupPlan.ps1
function Stop-MBSBackupPlan { <# .SYNOPSIS Stop running backup plans. .DESCRIPTION The Stop-MBSBackupPlan cmdlet stop a backup plan with specified ID or Name. .EXAMPLE PS C:\> Stop-MBSBackupPlan -Name "Backup VMware" Stop running backup plan by name. .EXAMPLE PS C:\> Stop-MBSBackupPlan -ID ed2e0d37-5ec2-49e1-a381-d2246b3108ec Stop running backup plan by the plan ID. .EXAMPLE PS C:\> Get-MBSBackupPlan -StorageType Local -PlanType VMware | Stop-MBSBackupPlan Stop running VMware backup plans with local backup storages type. .EXAMPLE PS C:\> Get-MBSBackupPlan -StorageType All -PlanType VMware | Stop-MBSBackupPlan Stop running VMware backup plans with all backup storages type. .INPUTS System.String[] System.String .OUTPUTS System.String[] .NOTES Author: Alex Volkov .LINK https://kb.msp360.com/managed-backup-service/powershell-module/cmdlets/stop-mbsbackupplan #> [CmdletBinding()] param ( [Parameter(ValueFromPipelineByPropertyName)] [string] $ID, # [Parameter(ValueFromPipelineByPropertyName)] [string] $Name, # [Parameter(Mandatory=$False, HelpMessage="Master password. Should be specified if configuration is protected by master password. Use -MasterPassword (ConvertTo-SecureString -string ""Your_Password"" -AsPlainText -Force)")] [SecureString] $MasterPassword ) begin { $CBB = Get-MBSAgent } process { if (Get-MBSAgent -ErrorAction SilentlyContinue) { if ($ID){ $Arguments += "plan -s $ID" }else{ $Arguments += "plan -s ""$Name""" } if ($MasterPassword){$Arguments += " -mp """+([System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($MasterPassword)))+""""} Write-Verbose -Message "Arguments: $Arguments" Start-Process -FilePath $CBB.CBBCLIPath -ArgumentList $Arguments -NoNewWindow -Wait Start-Process -FilePath $CBB.CBBCLIPath -ArgumentList $Arguments -NoNewWindow -Wait } } end { } } |