##--------------------------------------------------------------------
## Name Windows Management Framework 5.1, .NET Framework 4.0 and VSU 4 Automated
## Usage Windows_Management_Framework_4.0_and_NET_Framework.4.0_VSU_4_Automated_v1.0.ps1
## Note Change variables were needed to fit your needs
## Creator Wim Matthyssen
## Date 08/12/17
## Version 1
##-------------------------------------------------------------------
## Requires -RunAsAdministrator
## Variables
$wmfx64Url = 'https://download.microsoft.com/download/6/F/5/6F5FF66C-6775-42B0-86C4-47D41F2DA187/Win7AndW2K8R2-KB3191566-x64.zip'
$dotNet4Url ='https://download.microsoft.com/download/1/B/E/1BE39E79-7E39-46A3-96FF-047F95396215/dotNetFx40_Full_setup.exe'
$vsu4Url ='https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe'
$tempFolder = 'C:\Temp'
$foregroundColor1 = 'Red'
$foregroundColor2 = 'Yellow'
$wmf5MsuZip = 'C:\Temp\Win7AndW2K8R2-KB3191566-x64.zip'
$dotNet4exe = 'C:\Temp\dotNetFx40_Full_setup.exe'
$vsu4exe = 'C:\Temp\vcredist_x64.exe'
## Set the PowerShell execution policy to RemoteSigned
Set-ExecutionPolicy RemoteSigned
## Set date/time variable and write blank lines
$global:currenttime= Set-PSBreakpoint -Variable currenttime -Mode Read -Action { $global:currenttime= Get-Date }
for ($i = 1; $i -lt 4; $i++) {write-host}
Write-Host "Download started" $currenttime -foregroundcolor $foregroundColor1
## Create Temp folder on C: if not exists
If(!(test-path $tempFolder))
{
New-Item -ItemType Directory -Force -Path $tempFolder
Write-Host 'Temp folder created' -foregroundcolor $foregroundColor2
}
## Download and save WMF 5.1 to C:\Temp
function AllJobs-wmf5Msu{
Import-Module BitsTransfer
Start-BitsTransfer -Source $wmfx64Url -Destination $wmf5MsuZip
}
AllJobs-wmf5Msu
## Extract WMF 5.1
$shell = New-Object -ComObject shell.application
$zip = $shell.NameSpace($wmf5MsuZip)
foreach ($item in $zip.items()) {
$shell.Namespace($tempFolder).CopyHere($item)
}
Remove-Item $wmf5MsuZip
Write-Host 'Win7AndW2K8R2-KB3191566-x64.msu and Install-WMF5.1.ps1 available' $currenttime -foregroundcolor $ForegroundColor2
## Download and save .NEt Framework 4.0 to C:\Temp
function AllJobs-dotNet4exe{
Import-Module BitsTransfer
Start-BitsTransfer -Source $dotNet4Url -Destination $dotNet4exe
Write-Host 'Windows6.1-KB2819745-x64-MultiPkg.msu available' $currenttime -foregroundcolor $ForegroundColor2
}
AllJobs-dotNet4exe
## Download and save Visual C++ Redistributable for Visual Studio 2012 Update 4 to C:\Temp
function AllJobs-vcredist{
Import-Module BitsTransfer
Start-BitsTransfer -Source $vsu4Url -Destination $vsu4exe
Write-Host 'vcredist_x64.exe available' $currenttime -foregroundcolor $ForegroundColor2
}
AllJobs-vcredist
## Open C:\Temp folder
ii C:\Temp
## Close PowerShell windows upon completion
stop-process -Id $PID
Write-Host "Close PowerShell window" -foregroundcolor "Red"
##-------------------------------------------------------------------
Recent Comments