Join-SCVirtualMachine

Re-associates an orphaned virtual machine to its service or virtual machine role.

Syntax

Join-SCVirtualMachine
    [-VM] <VM>
    -ComputerTier <ComputerTier>
    [-RunAsynchronously]
    [-PROTipID <Guid>]
    [-JobVariable <String>]
    [-OnBehalfOfUser <String>]
    [-OnBehalfOfUserRole <UserRole>]
    [<CommonParameters>]
Join-SCVirtualMachine
    [-VM] <VM>
    -VMRole <CloudVmRole>
    [-RunAsynchronously]
    [-PROTipID <Guid>]
    [-JobVariable <String>]
    [-OnBehalfOfUser <String>]
    [-OnBehalfOfUserRole <UserRole>]
    [<CommonParameters>]

Description

The Join-SCVirtualMachine cmdlet re-associates an orphaned virtual machine to its service or virtual machine role.

When a host or cluster is removed from Virtual Machine Manager (VMM), any virtual machines belonging to a service or a virtual machine role deployed on the host remain functional. However, on adding the host or cluster back to VMM, the virtual machines become orphaned in the sense that they no longer have any association with their service or virtual machine role.

You can use this cmdlet to restore the association between a virtual machine and its service or virtual machine role. The Join-SCVirtualMachine cmdlet runs a re-associate task on VMM that performs a set of validations that help confirm the compatibility of the virtual machine with the service template.

When the cmdlet validates the compatibility of the virtual machine with the computer tier template, database-only operations are performed, and no adjustments are made to the virtual machine. It is assumed that the virtual machine is running and that all of the guest applications and services running on it are intact.

The computer tier to which you want to join the virtual machine must be running below its maximum instance count. The upgrade domain for the join operation is similar to a scale-out.

For best results, use this cmdlet with a virtual machine that was originally part of a service or virtual machine role deployment and was not modified.

Examples

Example 1: Join an orphaned virtual machine to a service tier

PS C:\> $VM = Get-SCVirtualMachine -Name "PS-Web-001" 
PS C:\> $CT = Get-SCComputerTier -Name "MyService-WebTier" 
PS C:\> Join-SCVirtualMachine -VM $VM -ComputerTier $CT

The first command gets the virtual machine named PS-Web-001, and then stores it in the $VM variable.

The second command gets the computer tier named MyService-WebTier, and then stores it in the $CT variable.

The last command joins the virtual machine in $VM to the computer tier in $CT.

Example 2: Join an orphaned virtual machine to a virtual machine role

PS C:\> $VM = Get-SCVirtualMachine -Name "PS-Web-001" 
PS C:\> $VmRole = Get-CloudResource -Name "ContosoShop" 
PS C:\> Join-SCVirtualMachine -VM $VM -VMRole $VmRole

The first command gets the virtual machine named PS-Web-001, and then stores it in the $VM variable.

The second command gets the cloud resource named ContosoShop, and then stores it in the $VmRole variable.

The last command joins the virtual machine in $VM to the role in $VMRole.

Parameters

-ComputerTier

Specifies a ComputerTier object.

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

-JobVariable

Specifies a variable in which job progress is tracked and stored.

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

-VM

Specifies a VM object.

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

-VMRole

Specifies a CloudVMRole object.

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