The app to match works, but the platform section does not seem to be working
$appToMatch = '*Mimecast*'
function Get-InstalledApps
{
if ([IntPtr]::Size -eq 4) {
$regpath = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
}
else {
$regpath = @(
'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
}
Get-ItemProperty $regpath | .{process{if($_.DisplayName -and $_.UninstallString) { $_ } }} | Select DisplayName, Publisher, InstallDate, DisplayVersion, UninstallString |Sort DisplayName
}
$result = Get-InstalledApps | where {$_.DisplayName -like $appToMatch}
If ($result -eq $null) {
Write-Host "'$appToMatch' NOT installed.";
#Check If x64 or x86
$platform = get-itemproperty HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration -name Platform
If($platform -eq "x86"){
#Office 2016 32-BIT STUFF
#Remove older version
$parameters = "/qn /x {948DCDCD-32BC-44A4-B970-B6E96D5E2CDC}"
$uninstallStatement = [System.Diagnostics.Process]::Start( "msiexec", $parameters )
$uninstallStatement.WaitForExit()
# Install Mimcast 32bit
Start-Process '\\server05\software$\Mimecast\Mimecast for Outlook 7.3.2061.19940 (32 bit)\Mimecast for Outlook 7.3.2061.19940 (32 bit).msi' -ArgumentList "/qn" -Wait
}
elseif($platform -eq "x64"){
#Office 2016 64-BIT STUFF
# Install Mimcast 64bit
Start-Process '\\server05\software$\Mimecast\Mimecast for Outlook 7.3.2061.19940 (64 bit)\Mimecast for Outlook 7.3.2061.19940 (64 bit).msi' -ArgumentList "/qn" -Wait
}
} else {
Write-Host "'$appToMatch' is installed."
exit
}
MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP