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
|
# Usage: <vmobject> | .\Configure-VmAdvancedSettings.ps1
# Examples: Get-VM myTestVM | .\Configure-VmAdvancedSettings.ps1
# Get-Cluster myCluster | Get-VM | .\Configure-VmAdvancedSettings.ps1
BEGIN
{
# The settings as an array of arrays. ("key", "value)
$advancedSettings = @( ("isolation.tools.copy.disable", "true"),
("isolation.tools.paste.disable", "true"),
("isolation.tools.setGUIOptions.enable", "false"),
("log.rotateSize", "100000"),
("log.keepOld", "10"),
("isolation.tools.connectable.disable", "true"),
("isolation.device.connectable.disable", "true"),
("isolation.tools.diskWiper.disable", "true"),
("isolation.tools.diskShrink.disable", "true")
)
$keyIndex = 0
$valueIndex = 1
}
PROCESS
{
$vmView = Get-View $_.Id
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
foreach ($setting in $advancedSettings)
{
$vmConfigSpec.extraconfig += New-Object VMware.Vim.optionvalue
$vmConfigSpec.extraconfig[-1].Key = $setting[$keyIndex]
$vmConfigSpec.extraconfig[-1].Value = $setting[$valueIndex]
}
$vmView.ReconfigVM($vmConfigSpec)
}
|