Migrate VMs from VSS to VDS, Change PSP for ESXi Host to RoundRobin, Change Default PSP and SATP – Using Powercli – VirtuallyThatGuy

Migrate VMs From VSS to VDS 

 

One​​ liner

 

#### one Vm at a time

get-vm​​ ​​ |​​ get-networkadapter​​ |where​​ {$_.networkname​​ -eq​​ “OldPortGroup”}​​ |​​ set-networkadapter​​ -networkname​​ “NewPortGroup”​​ -Confirm:$false

 

### migrating from ESXi host

$esx​​ =​​ "hostname"

$vsname​​ =​​ "old_vswitch"

$vdsname​​ =​​ "new_vdswitch"

$oldpg​​ =​​ "old_portgroup"

$newpg​​ =​​ "new portgroup"

# get the VMs

$vdPortGroup​​ =​​ Get-VDPortGroup​​ -VDSwitch​​ (​​ Get-VDSwitch​​ -Name​​ $vdsname)​​ -Name​​ $newpg​​ ;

## get all VMs in this host and migrate the network to VDS

Get-vm​​ -Location​​ $esx​​ |​​ Get-NetworkAdapter​​ |​​ where​​ {​​ $_.NetworkName​​ -eq​​ $oldpg​​ }​​ |​​ Set-NetworkAdapter​​ -PortGroup​​ $vdPortGroup​​ -RunAsync​​ ;

 

Change PSP for ESXi Host to RoundRobin

 

Get-VMHost “esxihostname” | Get-ScsiLun -CanonicalName “naa.600*” | Set-ScsiLun -MultipathPolicy “roundrobin”

 

Try naa.600 depending on storage iscsi or fc 

 

 

Change Default PSP for SATP (Path  Selection Policy and Storage Array Type Policy)

 

# Change the Default PSP for a SATP

# PowerCLI Session must be connected to vCenter Server using Connect-VIServer

Connect-Viserver​​ UK3P-vc01.lab.local,​​ ntcp-vc01.lab.local

# Define the default PSP to set VMW_PSP_MRU, VMW_PSP_RR, VMW_PSP_FIXED

$defaultpsp​​ =​​ "VMW_PSP_RR"

# Define the SATP to Set Default PSP to $defaultpsp

# This will depend on the SATP used associated with the connected array

# For example the SATP for an EMC VNXe is VMW_SATP_DEFAULT_AA

$satp​​ =​​ "VMW_SATP_DEFAULT_AA"

$esxHosts​​ =​​ Get-VMHost

foreach​​ ($esx​​ in​​ $esxHosts) {

Write-Host​​ "Setting Default PSP to​​ $defaultpsp​​ for SATP​​ $satp​​ on​​ $esx"​​ -ForegroundColor​​ green

$esxcli​​ =​​ Get-EsxCli​​ -VMHost​​ $esx

$esxcli.storage.nmp.satp.set($null,$defaultpsp,$satp)

}

Write-Host​​ "Done!"​​ -ForegroundColor​​ green

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#Migrate VMs From VSS to VDS
# One liner
#### one Vm at a time
get-vm | get-networkadapter |where {$_.networkname -eq “OldPortGroup”} | set-networkadapter -networkname “NewPortGroup” -Confirm:$false
### migrating from ESXi host
$esx = "hostname"
$vsname = "old_vswitch"
$vdsname = "new_vdswitch"
$oldpg = "old_portgroup"
$newpg = "new portgroup"
# get the VMs
$vdPortGroup = Get-VDPortGroup -VDSwitch ( Get-VDSwitch -Name $vdsname) -Name $newpg ;
## get all VMs in this host and migrate the network to VDS
Get-vm -Location $esx | Get-NetworkAdapter | where { $_.NetworkName -eq $oldpg } | Set-NetworkAdapter -PortGroup $vdPortGroup -RunAsync ;
 
# Change PSP for ESXi Host to RoundRobin
 
Get-VMHost “esxihostname” | Get-ScsiLun -CanonicalName “naa.500*” | Set-ScsiLun -MultipathPolicy “roundrobin”
 
#Try naa.600 depending on storage iscsi or fc
 
Change Default PSP for SATP (Path  Selection Policy and Storage Array Type Policy)
 
# Change the Default PSP for a SATP
# PowerCLI Session must be connected to vCenter Server using Connect-VIServer
Connect-Viserver UK3P-vc01.lab.local, ntcp-vc01.lab.local
# Define the default PSP to set VMW_PSP_MRU, VMW_PSP_RR, VMW_PSP_FIXED
$defaultpsp = "VMW_PSP_RR"
# Define the SATP to Set Default PSP to $defaultpsp
# This will depend on the SATP used associated with the connected array
# For example the SATP for an EMC VNXe is VMW_SATP_DEFAULT_AA
$satp = "VMW_SATP_DEFAULT_AA"
$esxHosts = Get-VMHost
foreach ($esx in $esxHosts) {
Write-Host "Setting Default PSP to $defaultpsp for SATP $satp on $esx" -ForegroundColor green
$esxcli = Get-EsxCli -VMHost $esx
$esxcli.storage.nmp.satp.set($null,$defaultpsp,$satp)
}
Write-Host "Done!" -ForegroundColor green

You May Also Like

About the Author: VirtuallyThatGuy

Leave a Reply

Your email address will not be published. Required fields are marked *