Automate the installation of Hyper-V VMintegration services with PowerShell

Tired of installing VM integration services manually in your Hyper-V environment? Here´s a script to help you with that!

Tip, this hotfix requires reinstallation of all your VMs integration services: Https://support.microsoft.com/en-us/kb/3063283

This script only works on x64 machines!

vmint

Begin Script
========================================================================================================

<#
Powershell Script for updating of Hyper-V Integration Services
2015-11-23 Harri Förberg, Förbergs IT AB
http://itharri.com
http://www.forbergsit.se
Warning, this script could potentially reboot a lot of VM:s in rapid succession. Use wisely, and with caution.
Prequisites: Mount and copy the contents of C:\Windows\System32\vmguest.iso (found on your Hyper-V host), copy the content to a shared folder on the server that will used to execute the script
C:\Temp\IntegrationSvc is used in the script below
— You might need to have you GPO:s adjusted to allow file copy from the server where you execute this script. —
#>

# Fill the latest Integration Services number here
$ICSVer = ”6.3.9600.17831” # This was the latest version 2015-11-23 (Delivered in a Hotfix – https://support.microsoft.com/en-us/kb/3063283)

#Specify your list of all Hyper-V Hosts
$HPVServer = ”HPV01” , ”HPV02” # <– Change to your servers

# Check all Running VM:s on all HPV hosts for ICS versions lower than our preset in line >> 13
$VMNames = Get-VM -ComputerName $HPVServer | ? {$_.IntegrationServicesVersion -lt $ICSVer -and $_.State -eq ”Running”} # This would be a good place to narrow your search parameters

# Check if any VM:s are in need of updating
if
($VMNames -eq $null) {Write-Host ”No VM:s detected with old versions” -ForegroundColor Red}
else
{
Write-Host ”Found VM:s with old Integration Services, starting upgrade process” -ForegroundColor Green

# Install Integration Services on VMs
foreach ($VirtualMachine in $VMNames)
{
$VMName = $VirtualMachine.VMName

# If copy fails here, check firewall rules on your client server.
write-host ”Copying installation files to $VMName
Copy-Item -Path C:\Scripts\IntegrationSvc -Destination ”\\$VMName\C$\temp\IntegrationSvc” -Recurse -Force
write-host ”Installing integration services…”
$scriptblock = {cmd.exe /C ”C:\Temp\IntegrationSvc\support\amd64\setup.exe /quiet /norestart”} # <– ADD or Remove /norestart if you want or dont want to reboot all VM:s after the installation completes!
Invoke-Command -scriptblock $scriptblock -computername $VMName
# Cleanup of copied installation files
write-host ”Cleanup…”
Remove-Item -Path ”\\$VMName\C$\temp\IntegrationSvc” -Recurse -Force
# Display Status
Write-Host $VMName updated” -ForegroundColor Green
}
}
Write-Host ”All done” -ForegroundColor DarkMagenta

========================================================================================================

End Script

About Harri Förberg

Jag och mina kollegor utgår ifrån "Hur svårt kan det va". Och det är en bra attityd om man ska skriva på en blogg. Nyfiket och pragmatiskt kring IT frågor med fokus på Microsoft Infrastruktur. Läs mer om oss på www.forbergsit.se

Posted on november 23, 2015, in Hyper-V, PowerShell, Windows Server 2012 R2 and tagged , , , . Bookmark the permalink. 3 kommentarer.

  1. i made a small but for me significant change to your script:

    and remember to change line 41 so that -Path is $IntegrationsPath …

  2. newest version of Integration Services now is 6.3.9600.18398.
    we have had a mayor issue with this in our environment as the new version is required on our new host. still have not found the update for the hyper visor host.

Kommentera

Fyll i dina uppgifter nedan eller klicka på en ikon för att logga in:

WordPress.com Logo

Du kommenterar med ditt WordPress.com-konto. Logga ut / Ändra )

Twitter-bild

Du kommenterar med ditt Twitter-konto. Logga ut / Ändra )

Facebook-foto

Du kommenterar med ditt Facebook-konto. Logga ut / Ändra )

Google+ photo

Du kommenterar med ditt Google+-konto. Logga ut / Ändra )

Ansluter till %s

%d bloggare gillar detta: