Freigeben über


Remove-SCVMHost

Removes a virtual machine host from VMM.

Syntax

Remove-SCVMHost
      [-VMHost] <Host>
      [-VMMServer <ServerConnection>]
      [-Credential <VMMCredential>]
      [-RemoveHostWithVMs]
      [-RunAsynchronously]
      [-PROTipID <Guid>]
      [-JobVariable <String>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-SCVMHost
      [-VMHost] <Host>
      [-VMMServer <ServerConnection>]
      [-Force]
      [-RunAsynchronously]
      [-PROTipID <Guid>]
      [-JobVariable <String>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

The Remove-SCVMHost cmdlet removes one or more virtual machine hosts from Virtual Machine Manager (VMM). The Remove-SCVMHost cmdlet operates as follows:

  • Host Server Only. If this computer is a Hyper-V host but is not also a library server, the host object is removed from the VMM database, and the VMM agent software is uninstalled from the physical host server.

If the host is a VMware ESX host or a Citrix XenServer host, the host object is removed from the VMM database. VMM does not install an agent on ESX hosts or XenServer hosts.

  • Host And Library Server. If this computer is a Hyper-V host and is also a library server, this command removes only the host functionality but leaves the library server feature in place. That is, the host object is removed from the VMM database, but the VMM agent software is not uninstalled from the physical server. The library server object remains in the database.

If the host is an ESX host, it can function only as a virtual machine host in VMM. It cannot be both a host and a library server.

  • Credentials. If a Hyper-V host is joined to an Active Directory domain, you must provide credentials for an account with appropriate permissions to remove that host computer from VMM.

You do not need to provide Active Directory credentials to remove a perimeter network host, an ESX host, or a XenServer host from VMM.

  • Virtual Machines. When you remove a host, the host is no longer managed by VMM. However, any virtual machines on the host server will not be removed or disassociated from the server. Any running virtual machines are not shut down. Although the virtual machines are no longer managed by VMM, they are not affected in any other way.
  • Forced Removal. You can use the Force parameter with the Remove-SCVMHost cmdlet to remove a virtual machine host from VMM when you do not have appropriate credentials to manage that host or when the VMM server can no longer communicate with that host.

When you specify the Force parameter, VMM does not ask or check for credentials, nor will VMM attempt to connect to the host and uninstall the VMM agent. Hence, using the Force parameter is recommended only when removing stale host records from the VMM database.

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 domain-joined host from VMM

PS C:\> $Credential = Get-Credential
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost01"
PS C:\> Remove-SCVMHost -VMHost $VMHost -Credential $Credential -Confirm

The first command uses the Get-Credential cmdlet to prompt you to supply a user name and password and stores the provided credentials in the $Credential variable. The required credentials for this operation are a domain account with administrator rights to remove a Windows-based host server joined to an Active Directory domain from VMM.

The second command gets the host object named VMHost01 and stores the object in the $VMHost variable.

The third command removes the host object stored in $VMHost. As this command is processed, $Credential provides credentials to Remove-VMHost, and the Confirm parameter prompts you to confirm that you do want to remove this host from VMM.

Example 2: Remove all hosts that are not nodes in a host cluster from VMM

PS C:\> Get-SCVMHost | where {$_.HostCluster -eq $NULL} | where {$_.VirtualizationPlatform -eq "VMwareESX" -or $_.PerimeterNetworkHost -eq 1 -or $_.NonTrustedDomainHost -eq 1} | Remove-SCVMHost -Confirm
PS C:\> $Credential = Get-Credential
PS C:\> Get-VMHost | where {$_.HostCluster -eq $NULL -and $_.VirtualizationPlatform -ne "VMwareESX" -and $_.PerimeterNetworkHost -eq 0 -and $_.NonTrustedDomainHost -eq 0} | Remove-VMHost -Credential $Credential -Confirm

The first command gets all host objects, excludes any hosts that are nodes in a host cluster, selects only those objects that represent VMware ESX hosts, perimeter network hosts, or non-trusted domain hosts, and then removes those objects from VMM if you confirm that you want to remove them. Credentials are not required to remove these hosts.

The second command prompts you to supply a user name and password for an account with permissions to remove domain-joined Windows hosts from VMM and stores your credentials in $Credential.

The last command gets all domain-joined Windows-based host objects that are not part of a host cluster and passes the objects to the Remove-VMHost cmdlet. As this command is processed, $Credential provides your credentials to Remove-VMHost, and the Confirm parameter prompts you to confirm that you do want to remove these hosts from VMM.

Example 3: Remove a specific host that you can no longer access from VMM

PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost03"
PS C:\> Remove-SCVMHost -VMHost $VMHost -Force -Confirm

The first command gets the host object named VMHost03 and stores the object in the $VMHost variable.

The second command switches on the Force parameter to ensure that VMHost03 is removed from the VMM database. Credentials are not needed for this operation. The Confirm parameter prompts you to confirm that you do want to remove this host.

Note: You can use the Force parameter to remove a host from VMM when you do not have the credentials for that host or when the VMM server can no longer communicate with that host.

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

-Credential

Specifies a credential object or, for some cmdlets, a Run As account object that contains the user name and password of an account that has permission to perform this action. Or, in the case of Restart-SCJob, has permission to complete a restarted task.

For more information about the PSCredential object, type Get-Help Get-Credential.

For more information about Run As accounts, type Get-Help New-SCRunAsAccount.

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

-RemoveHostWithVMs

For more information about the PSCredential object, type Get-Help Get-Credential.

For more information about Run As accounts, type Get-Help New-SCRunAsAccount.

Type:SwitchParameter
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

-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: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