Modifying Script for Advanced Settings

This post was originally published on this site

I found the below script and it’s good, it Modify VM Advanced settings on an multiple VM, capture the VM Advanced setting details before and after VM setting changes for future comparison with the timestamp in .csv format.

 

I need assistance in order to modify the script and just to connect only via vCenter without preparing the ServerList file as the ENV is very huge and it’s changing

 

Add-PSSnapin VMware.VimAutomation.Core

ConnectVIServer Server vcenter.local User username Password Password

$ServerListFile = “ServerList.txt”

$ServerList = Get-Content $ServerListFile

 

Foreach ($vm in $ServerList)

{

    $date=get-Date format “ddMMyy_HHmm”

    GetVM $vm| GetAdvancedSetting | Select Name, Value | Export-CSV $vm“_Before_$date.csv”

 

    NewAdvancedSetting Entity $vm Name vmci0.unrestricted Value FALSE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name RemoteDisplay.maxConnections Value ‘1’ Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name tools.setInfo.sizeLimit Value ‘1048576’ Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name floppyX.present Value FALSE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name serialX.present Value FALSE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name parallelX.present Value FALSE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name ideX:Y.present Value FALSE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name isolation.device.connectable.disable Value TRUE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name isolation.device.edit.disable Value TRUE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name isolation.tools.unity.push.update.disable Value TRUE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name isolation.tools.ghi.autologon.disable Value TRUE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name isolation.bios.bbs.disable Value TRUE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name vmsafe.enable Value FALSE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name isolation.tools.copy.disable Value TRUE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name isolation.tools.paste.disable Value TRUE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name isolation.tools.autoInstall.disable Value TRUE Confirm:$False Force:$True

    NewAdvancedSetting Entity $vm Name tools.guestlib.enableHostInfo Value FALSE Confirm:$False Force:$True

 

    $date=get-Date format “ddMMyy_HHmm”

    GetVM $vm| GetAdvancedSetting | Select Name, Value | Export-CSV $vm“_After_$date.csv”

    StartVM VM $vm

}

New-Item ErrorAction Ignore ItemType directory Path Report

$path=$(get-location).Path+“report”

MoveItem *.csv $path Force

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.