This script will disable the Hyper-V Time Synchronization Integration Service, for all VMs in a VLAN you specify. The VLAN would be the “tagged” network within a the Virtual Machines network settings.
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 |
# Disable Time Synchronization service for VMs in VLAN ("Network Tag") write-host -ForegroundColor Yellow "This script will disable the Time Synchronization Service for the VMs within the VLAN you specify." [int]$VLAN_ID = Read-Host "Enter VLAN where VMs reside" $VMS = Get-ClusterNode ForEach($node in $VMS){ # Get the VM Adapters that are in the VLAN. We will use the VMName to continue processing. $EXT_VMS = (Get-VMNetworkAdapterVlan -ComputerName $node | where {$_.AccessVlanID -eq $VLAN_ID} | select -ExpandProperty ParentAdapter) foreach($vm in $EXT_VMS){ # Write the VM name and IP to console $Current_VM = $vm.VMName Write-Output ($Current_VM +"|"+ $vm.IPAddresses) # Attempt to disable Time Synchronization try{ write-host -ForegroundColor Green "Server setting updated." Disable-VMIntegrationService -VMName $Current_VM -Name "Time Synchronization" -ComputerName $node # Requery the Integration Service to get status $output1 = (Get-VMIntegrationService -VMName $Current_VM -ComputerName $node | where {$_.name -eq "Time Synchronization"} | select VMName,Name,Enabled) # Output the current status Write-Output ($output1.Vmname +" | "+ $output1.Name +" | "+ $output1.enabled) write-host `n }Catch{ Write-Host -BackgroundColor Gray -ForegroundColor Black "Could not update time service" } } # End looping of vms } # End looping of nodes |