I have to install below Visual C++ software via powershell.
VC_redist_2015-2022×64
VC_redist_2015-2022×86
I have to first check whether the Visual C++ x64 & x86 installed on my server. If its installed already code have to skip the installation part or else it have to install the Visual C++ x64 & x84. I have a powershell code which is not working properly. I am trying to short via name. But my code is not working.
Could someone please help me to fix it
I am looking forward to hearing from you.
$MSRedistributable = Get-WmiObject -Query "Select * from Win32_Product where name = 'Microsoft Visual C++'"
$MSRedistributableInstaller = "C:Software"
Write-host "`nStaring Installation of Microsoft Visual C++ 2015-2022"
if (!($MSRedistributable.name))
{
Write-host "Installing Microsoft Visual C++."
Start-Process -Filepath "$($MSRedistributableInstaller)VC_redist_2015-2022x64" -Argumentlist "/Q" -wait
Start-Process -Filepath "$($MSRedistributableInstaller)VC_redist_2015-2022x86" -Argumentlist "/Q" -wait
write-host "Microsoft Visual C++ installed successfully."
}
else
{
write-host "$($MSRedistributable.name) appears to be installed already. Skipping."
}