add 1 property and 1 function for vMotionEncryption
This commit is contained in:
@@ -69,7 +69,7 @@ New-VIProperty -Name KMSserver -ObjectType VirtualMachine -Value {
|
|||||||
if ($VM.Encrypted) {
|
if ($VM.Encrypted) {
|
||||||
$VM.EncryptionKeyId.ProviderId.Id
|
$VM.EncryptionKeyId.ProviderId.Id
|
||||||
}
|
}
|
||||||
} -BasedOnExtensionProperty 'Config.KeyId' -Force | Out-Null
|
} -BasedOnExtensionProperty 'Config.KeyId' -Force | Out-Null
|
||||||
|
|
||||||
New-VIProperty -Name Encrypted -ObjectType HardDisk -Value {
|
New-VIProperty -Name Encrypted -ObjectType HardDisk -Value {
|
||||||
Param ($hardDisk)
|
Param ($hardDisk)
|
||||||
@@ -238,7 +238,7 @@ Function Set-vMotionEncryptionConfig {
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
This cmdlet sets the vMotionEncryption property of a VM.
|
This cmdlet sets the vMotionEncryption property of a VM.
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Use this function to set the vMotionEncryption settings for a VM.
|
Use this function to set the vMotionEncryption settings for a VM.
|
||||||
The 'Encryption' parameter is set up with Tab-Complete for the available
|
The 'Encryption' parameter is set up with Tab-Complete for the available
|
||||||
@@ -248,17 +248,17 @@ Function Set-vMotionEncryptionConfig {
|
|||||||
Specifies the VM you want to set the vMotionEncryption property.
|
Specifies the VM you want to set the vMotionEncryption property.
|
||||||
|
|
||||||
.PARAMETER Encryption
|
.PARAMETER Encryption
|
||||||
Specifies the value you want to set to the vMotionEncryption property.
|
Specifies the value you want to set to the vMotionEncryption property.
|
||||||
The Encryption options are: Disabled, Opportunistic, and Required.
|
The Encryption options are: disabled, opportunistic, and required.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-VM | Set-vMotionEncryptionConfig -Encryption opportunistic
|
PS C:\> Get-VM | Set-vMotionEncryptionConfig -Encryption opportunistic
|
||||||
|
|
||||||
Sets the vMotionEncryption of all the VMs
|
Sets the vMotionEncryption of all the VMs
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Author : Carrie Yang
|
Author : Brian Graf, Carrie Yang.
|
||||||
Author email : yangm@vmware.com
|
Author email : grafb@vmware.com, yangm@vmware.com
|
||||||
Version : 1.0
|
Version : 1.0
|
||||||
|
|
||||||
==========Tested Against Environment==========
|
==========Tested Against Environment==========
|
||||||
@@ -274,28 +274,31 @@ Function Set-vMotionEncryptionConfig {
|
|||||||
[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]
|
[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]
|
||||||
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine]$VM,
|
[VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine]$VM,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$True]
|
||||||
[ValidateSet("disabled", "opportunistic", "required")]
|
[ValidateSet("disabled", "opportunistic", "required")]
|
||||||
[String]$Encryption
|
[String]$Encryption
|
||||||
)
|
)
|
||||||
|
|
||||||
process{
|
process{
|
||||||
# Confirm the connected VIServer is vCenter Server
|
if ($VM.vMotionEncryption -eq $Encryption) {
|
||||||
ConfirmIsVCenter
|
Write-Warning "The encrypted vMotion state is already $Encrypted, no need to change it."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if ($VM.Encrypted -and $VM.vMotionEncryption -ne $Encryption) {
|
if ($VM.Encrypted) {
|
||||||
Write-Error "Cannot change encrypted vMotion state for an encrypted VM."
|
Write-Error "Cannot change encrypted vMotion state for an encrypted VM."
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
$VMView = $VM | get-view
|
$VMView = $VM | get-view
|
||||||
$config = new-object VMware.Vim.VirtualMachineConfigSpec
|
$Config = New-Object VMware.Vim.VirtualMachineConfigSpec
|
||||||
$config.MigrateEncryption = New-object VMware.Vim.VirtualMachineConfigSpecEncryptedVMotionModes
|
$Config.MigrateEncryption = New-Object VMware.Vim.VirtualMachineConfigSpecEncryptedVMotionModes
|
||||||
$config.MigrateEncryption = "$encryption"
|
$Config.MigrateEncryption = $Encryption
|
||||||
|
|
||||||
$VMView.ReconfigVM($config)
|
$VMView.ReconfigVM($config)
|
||||||
|
|
||||||
$VM.ExtensionData.UpdateViewData()
|
$VM.ExtensionData.UpdateViewData()
|
||||||
$VM.vMotionEncryption
|
$VM.vMotionEncryption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1156,7 +1159,7 @@ Function Get-VMEncryptionInfo {
|
|||||||
.NOTES
|
.NOTES
|
||||||
If $HardDisk is specified, then only the encryption information of the disks specified in $HardDisk is obtained.
|
If $HardDisk is specified, then only the encryption information of the disks specified in $HardDisk is obtained.
|
||||||
Otherwise, all disks' encryption information of the specified VM is returned.
|
Otherwise, all disks' encryption information of the specified VM is returned.
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Author : Carrie Yang.
|
Author : Carrie Yang.
|
||||||
Author email : yangm@vmware.com
|
Author email : yangm@vmware.com
|
||||||
@@ -1255,7 +1258,7 @@ Function Get-EntityByCryptoKey {
|
|||||||
.NOTES
|
.NOTES
|
||||||
At least one of the KeyId and KMSClusterId parameters is required.
|
At least one of the KeyId and KMSClusterId parameters is required.
|
||||||
If the SearchVMHosts, SearchVMs and SearchDisks all not specified, the cmdlet return $null.
|
If the SearchVMHosts, SearchVMs and SearchDisks all not specified, the cmdlet return $null.
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Author : Baoyin Qiao.
|
Author : Baoyin Qiao.
|
||||||
Author email : bqiao@vmware.com
|
Author email : bqiao@vmware.com
|
||||||
@@ -1876,7 +1879,7 @@ Function Set-DefaultKMSCluster {
|
|||||||
C:\PS>Set-DefaultKMSCluster -KMSClusterId 'ClusterIdString'
|
C:\PS>Set-DefaultKMSCluster -KMSClusterId 'ClusterIdString'
|
||||||
|
|
||||||
Sets the KMS cluster whose cluster ID is 'ClusterIdString' as the default KMS cluster.
|
Sets the KMS cluster whose cluster ID is 'ClusterIdString' as the default KMS cluster.
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Author : Baoyin Qiao.
|
Author : Baoyin Qiao.
|
||||||
Author email : bqiao@vmware.com
|
Author email : bqiao@vmware.com
|
||||||
|
|||||||
Reference in New Issue
Block a user