Remove-SCService

Deletes a VMM service and all associated virtual machines.

Syntax

Remove-SCService
      [-VMMServer <ServerConnection>]
      [-Service] <Service>
      [-RunAsynchronously]
      [-PROTipID <Guid>]
      [-JobVariable <String>]
      [-WhatIf]
      [-Confirm]
      [-OnBehalfOfUser <String>]
      [-OnBehalfOfUserRole <UserRole>]
      [<CommonParameters>]

Description

The Remove-SCService cmdlet deletes a Virtual Machine Manager (VMM) service and all associated virtual machines from the host on which it is deployed. The service must be in a stopped state prior to deleting it. To stop a service, use the Stop-SCService cmdlet.

Examples

Example 1: Remove a specific service deployed on a host

PS C:\> $Service = Get-SCService -VMMServer "VMMServer01.Contoso.com" -Name "Service01"
PS C:\> Stop-SCService -Service $Service
PS C:\> Remove-SCService -Service $Service -Confirm

The first command gets the service object named Service01 on VMMServer01 and stores the object in the $Service variable.

The second command stops the service stored in $Service.

The last command removes the service stored in $Service and deletes the corresponding virtual machine files from the file system. A confirmation prompt is displayed before the service is removed.

Example 2: Remove all services with names that include a specific string

PS C:\> $Services = Get-SCService -VMMServer "VMMServer01.Contoso.com" | where { $_.Name -Match "Service" }
PS C:\> $Services | Stop-SCService
PS C:\> $Services | Remove-SCService -Confirm

The first command gets all service objects that include the string "Service" in their name, and then stores the objects in the $Services variable.

The second command stops all services stored in $Service.

The third command removes all service objects contained in $Services and deletes the corresponding virtual machine files from the file system. A confirmation prompt is displayed before the service is removed.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

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

-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

-OnBehalfOfUser

Specifies a user name. This cmdlet operates on behalf of the user that this parameter specifies.

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

-OnBehalfOfUserRole

Specifies a user role. To obtain a user role, use the Get-SCUserRole cmdlet. This cmdlet operates on behalf of the user role that this parameter specifies.

Type:UserRole
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 VMM service object.

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

-VMMServer

Specifies a VMM server object.

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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

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