Install Example
Uses Using Enums for the logging
function Install-Redistributables {
$products = Get-CimInstance win32_product
# Visual C++ 2010 Redistributable
if (($products | Where-Object { $_.name -like "Microsoft Visual C++ 2010*" })) {
Add-LogEntry -Type Info -Message "Microsoft Visual C++ 2010 already installed"
}
else {
Add-LogEntry -Debug -Message "Installing Microsoft Visual C++ 2010"
$working_dir = $PWD [System.NET.WebClient]::new().DownloadFile("https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe", "$($LTSvc)\vcredist_2010_x64.exe")
Set-Location $LTSvc
.\vcredist_2010_x64.exe /extract:vc2010 /q /norestart
Start-Sleep -Seconds 1.5
Set-Location $LTSvc\vc2010
.\Setup.exe /q | Wait-Process
Set-Location $working_dir
Add-LogEntry -Type Info -Message "Visual C++ 2010 has been installed"
}
# Visual C++ 2022 Redistributable
if (($products | Where-Object { $_.name -like "Microsoft Visual C++ 2022*" })) {
Add-LogEntry -Type Info -Message "Microsoft Visual C++ 2022 already installed"
}
else {
Add-LogEntry -Type Debug -Message "Installing Visual C++ 2022"
$working_dir = $PWD [System.NET.WebClient]::new().DownloadFile("https://aka.ms/vs/17/release/vc_redist.x64.exe", "$($LTSvc)\vc_redist.x64.exe")
Set-Location $LTSvc
.\vc_redist.x64.exe /q /norestart | Wait-Process
Set-Location $working_dir
Add-LogEntry -Type Info -Message "Microsoft Visual C++ 2022 has been installed"
}
}