Can someone help me write a PS script to disable the VM logging check box.
To be clear, if I did this manually the option to uncheck is in VM settings -> Options -> Advanced -> General -> Enable Logging.
TIA
You build a look that runs over all the VMs in the folder and you place the code above in the loop.
Something like this
$folderName = <folder-name> Get-Folder $folderName | Get-VM | %{ $vm = Get-VM $_.Name | Get-View $spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.flags = New-Object VMware.Vim.VirtualMachineFlagInfo $spec.flags.enableLogging = $false $vm.ReconfigVM($spec) }
And you can save some CPU cycles and some memory by placing the constant part outside the loop.
Like this
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.flags = New-Object VMware.Vim.VirtualMachineFlagInfo $spec.flags.enableLogging = $false $folderName = "PCs" Get-Folder $folderName | Get-VM | %{ $vm = Get-VM $_.Name | Get-View $vm.ReconfigVM($spec) }
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sure, try this
$vmName = <vm-name> $vm = Get-VM $vmName | Get-View $spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.flags = New-Object VMware.Vim.VirtualMachineFlagInfo $spec.flags.enableLogging = $false $vm.ReconfigVM($spec)
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the quick reply!
If I want to apply this script to all VMs within a folder, what syntax do I need to change?
You build a look that runs over all the VMs in the folder and you place the code above in the loop.
Something like this
$folderName = <folder-name> Get-Folder $folderName | Get-VM | %{ $vm = Get-VM $_.Name | Get-View $spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.flags = New-Object VMware.Vim.VirtualMachineFlagInfo $spec.flags.enableLogging = $false $vm.ReconfigVM($spec) }
And you can save some CPU cycles and some memory by placing the constant part outside the loop.
Like this
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec $spec.flags = New-Object VMware.Vim.VirtualMachineFlagInfo $spec.flags.enableLogging = $false $folderName = "PCs" Get-Folder $folderName | Get-VM | %{ $vm = Get-VM $_.Name | Get-View $vm.ReconfigVM($spec) }
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference