次の方法で共有


Remove-SCVMHost

Remove-SCVMHost

Removes a virtual machine host from VMM.

Syntax

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

Parameter Set: ForceRemoval
Remove-SCVMHost [-VMHost] <Host> -Force [-JobVariable <String> ] [-PROTipID <Guid]> ] [-RunAsynchronously] [-VMMServer <ServerConnection> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed 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 are 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. VMM does not attempt to connect to the host and uninstall the VMM agent. Hence, using the Force parameter is recommended only when cleaning up 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.

Parameters

-Credential<VMMCredential>

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.

For more information about the PSCredential object, type Get-Help Get-Credential. For more information about Run As accounts, type Get-Help New-SCRunAsAccount.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Force

Forces the operation to complete.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobVariable<String>

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PROTipID<Guid]>

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

Aliases

none

Required?

false

Position?

named

Default Value

none

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.

Aliases

none

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VMHost<Host>

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, type Get-Help Add-SCVMHost -detailed.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-VMMServer<ServerConnection>

Specifies a VMM server object.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

Example 1: Remove a specific domain-joined host from VMM

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. For more information, type Get-Help Get-Credential. 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 then 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.

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

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

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, then 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 fromVMM.

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

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

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

The second command specifies 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.

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.

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

Add-SCVMHost

Disable-SCVMHost

Enable-SCVMHost

Get-SCVMHost

Move-SCVMHost

New-SCVMHost

Read-SCVMHost

Register-SCVMHost

Repair-SCVMHost

Restart-SCVMHost

Set-SCVMHost

Start-SCVMHost

Stop-SCVMHost