Remove-SCVMTemplate

Removes a template object from VMM.

Syntax

Remove-SCVMTemplate
      [-VMTemplate] <Template>
      [-Force]
      [-RunAsynchronously]
      [-PROTipID <Guid>]
      [-JobVariable <String>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

The Remove-SCVMTemplate cmdlet removes a template object from the Virtual Machine Manager (VMM) library. Removing a template object does not delete any virtual hard disks associated with the template.

The types of files that can be associated with a template include virtual hard disk files (Windows-based .vhd files, Citrix XenServer-based .vhd files, or VMware-based .vmdk files), virtual floppy disk files (Windows-based .vfd files or VMware-based .flp files), and script files (Windows PowerShell .ps1 script files or answer file scripts, including Sysprep.inf and Unattend.xml files).

This cmdlet returns the object upon success (with the property MarkedForDeletion set to TRUE) or returns an error message upon failure.

Examples

Example 1: Remove a specific template from the library

PS C:\> $Template = Get-SCVMTemplate -VMMServer "VMMServer1.Contoso.com" | where { $_.Name -eq "Template01" }
PS C:\> Remove-SCVMTemplate -VMTemplate $Template

The first command gets the template object named Template01 from the library on VMMServer01 and stores the object in the $Template variable.

The second command removes the template object stored in $Template from the library.

Example 2: Remove all templates from the library

PS C:\> $Templates = Get-SCVMTemplate -VMMServer "VMMServer01.Contoso.com"
PS C:\> $Templates | Remove-SCVMTemplate -Confirm

The first command gets all the template objects from VMMServer01 and stores the objects in the array named $Templates.

The second command passes each template object in $Templates to the Remove-SCVMTemplate cmdlet, which removes each template object from the VMM library. The Confirm parameter prompts you to confirm whether you want to delete each template.

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

-Force

Forces the command to run without asking for user confirmation.

Type:SwitchParameter
Position:Named
Default value:None
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

-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

-VMTemplate

Specifies a VMM template object used to create virtual machines.

Type:Template
Aliases:Template
Position:0
Default value:None
Required:True
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

Outputs

SCVMTemplate

This cmdlet returns an SCVMTemplate object.

Notes

  • Requires a VMM template object, which can be retrieved by using the Get-SCVMTemplate cmdlet.