-
Notifications
You must be signed in to change notification settings - Fork 50
/
EncryptedvMotion.psm1
108 lines (84 loc) · 2.8 KB
/
EncryptedvMotion.psm1
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
function Get-vMotionEncryptionConfig {
<#
.NOTES
===========================================================================
Created by: Brian Graf
Date: October 14, 2016
Organization: VMware
Blog: www.vtagion.com
Twitter: @vBrianGraf
===========================================================================
.SYNOPSIS
for vSphere 6.5 and greater you can now choose how VMs are vMotioned.
The encryption options are: Disabled, Opportunistic, and Required
.DESCRIPTION
Use this function to get the vMotionEncryption settings for each VM.
You must use a VM object for the VM parameter:
(Get-VM) or $VM = Get-VM Exchange*
.EXAMPLE
PS C:\> Get-vMotionEncryptionConfig -VM (Get-VM)
.NOTES
Additional information about the function.
#>
param (
[Parameter(Position = 0,
Mandatory = $true,
ValueFromPipeline = $true)]
[VMware.VimAutomation.ViCore.Impl.V1.VIObjectImpl[]]$VM
)
begin{}
process{
$VM | select Name, @{name="vMotionEncryption";Expression={$_.extensiondata.config.MigrateEncryption}}
}
end{}
}
function Set-vMotionEncryptionConfig {
<#
.NOTES
===========================================================================
Created by: Brian Graf
Date: October 14, 2016
Organization: VMware
Blog: www.vtagion.com
Twitter: @vBrianGraf
===========================================================================
.SYNOPSIS
for vSphere 6.5 and greater you can now choose how VMs are vMotioned.
The encryption options are: Disabled, Opportunistic, and Required
.DESCRIPTION
Use this function to set the vMotionEncryption settings for each VM
in an automated fashion.
The 'Encryption' parameter is set up with Tab-Complete for the available
options.
You must use a VM object for the VM parameter:
(Get-VM) or $VM = Get-VM Exchange*
.EXAMPLE
PS C:\> Set-vMotionEncryptionConfig -VM (Get-VM) -Encryption opportunistic
.NOTES
Additional information about the function.
#>
param (
[Parameter(Position = 0,
Mandatory = $true,
ValueFromPipeline = $true)]
[VMware.VimAutomation.ViCore.Impl.V1.VIObjectImpl[]]$VM,
[ValidateSet("disabled", "opportunistic", "required")]
[String]$Encryption
)
begin{
write-host "Working... Please be patient." -ForegroundColor Cyan
}
process{
foreach ($obj in $VM)
{
$VMView = $obj | get-view
$config = new-object VMware.Vim.VirtualMachineConfigSpec
$config.MigrateEncryption = New-object VMware.Vim.VirtualMachineConfigSpecEncryptedVMotionModes
$config.MigrateEncryption = "$encryption"
$VMView.ReconfigVM($config)
}
}
end{
$VM | select Name, @{name="vMotionEncryption";Expression={$_.extensiondata.config.MigrateEncryption}} }
}