Add-SCServicingWindowSubscription

Adds a servicing window to a virtual machine, host, or service.

Syntax

Add-SCServicingWindowSubscription
   [-ServicingWindow] <ServicingWindow>
   -VM <VM>
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]
Add-SCServicingWindowSubscription
   [-ServicingWindow] <ServicingWindow>
   -VMHost <Host>
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]
Add-SCServicingWindowSubscription
   [-ServicingWindow] <ServicingWindow>
   -Service <Service>
   [-RunAsynchronously]
   [-PROTipID <Guid>]
   [-JobVariable <String>]
   [<CommonParameters>]

Description

The Add-SCServicingWindowSubscription cmdlet adds a servicing window to a virtual machine, host, or service. After a servicing window is assigned to an object, users can schedule maintenance work to be done within the servicing window by using a third-party scheduling system.

Examples

Example 1: Subscribe all virtual machines owned by a specific user to a servicing window

PS C:\> $SvcWindow = Get-SCServicingWindow -Name "Backup Staging A"
PS C:\> $VMs = Get-SCVirtualMachine | where {$_.Owner -eq "Contoso\ReneeLo"} 
PS C:\> Add-SCServicingWindowSubscription -ServicingWindow $SvcWindow -VM $VMs

The first command gets the servicing window object named Backup Staging A and stores the object in the $SvcWindow variable.

The second command gets all virtual machine objects, selects only the virtual machines that are owned by Contoso\ReneeLo and then stores those objects in the $VMs variable.

The last command subscribes the virtual machines stored in $VMs to the servicing window stored in $SvcWindow.

Example 2: Subscribe all virtual machines owned by a specific user to a servicing window using the pipeline operator

PS C:\> $SvcWindow = Get-SCServicingWindow -Name "Test Servers Group 3"
PS C:\> Get-SCVirtualMachine | where {$_.Owner -eq "Contoso\NevenSokec"} | Add-SCServicingWindowSubscription -ServicingWindow $SvcWindow

The first command gets the servicing window object named Test Servers Group 3 and stores the object in the $SvcWindow variable.

The second command gets all virtual machine objects, selects only the virtual machines that are owned by Contoso\ReneeLo and then uses the pipeline operator to pass the virtual machines to the Add-SCServicingWindowSubscription cmdlet, which subscribes each virtual machine that is passed to it to the servicing window stored in $SvcWindow.

Parameters

-JobVariable

Specifies that job progress is tracked and stored in the variable named by this parameter.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PROTipID

Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.

Type:Guid
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Service

Specifies a Virtual Machine Manager (VMM) service object.

Type:Service
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ServicingWindow

Specifies a servicing window object.

Type:ServicingWindow
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-VM

Specifies a virtual machine object.

Type:VM
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-VMHost

Specifies a virtual machine host object. VMM supports Hyper-V hosts, VMware ESX hosts, and Citrix XenServer hosts.

For more information about each type of host, see the Add-SCVMHost cmdlet.

Type:Host
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Outputs

ServicingWindowSubscription

This cmdlet returns a ServicingWindowSubscription object.