Remove-SCService

Deletes a VMM service and all associated virtual machines.

Syntax

Remove-SCService [-Service] <Service> [-Confirm] [-JobVariable <String>] [-OnBehalfOfUser <String>]
 [-OnBehalfOfUserRole <UserRole>] [-PROTipID <Guid>] [-RunAsynchronously] [-VMMServer <ServerConnection>]
 [-WhatIf] [<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
Required:False
Position:Named
Default value: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
Required:False
Position:Named
Default value:None
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
Required:False
Position:Named
Default value:None
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
Required:False
Position:Named
Default value:None
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
Required:False
Position:Named
Default value:None
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
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Service

Specifies a VMM service object.

Type:Service
Required:True
Position:0
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-VMMServer

Specifies a VMM server object.

Type:ServerConnection
Required:False
Position:Named
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-WhatIf

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

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