×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Help with script
2

Help with script

Help with script

(OP)

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

RE: Help with script

(OP)
i think i fixed it

CODE --> powershell

$appToMatch = '*Mimecast*'
$DisplayVersion ='7.3.2061.19940'

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 -and $_.DisplayVersion -eq $DisplayVersion }
If ($result -eq $null){
		Write-Host "'$appToMatch' NOT installed run installation.";

		 
		#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
					Write-Host "'$appToMatch' is x86."
					$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
				}else{
				($platform -eq "x64")
					Write-Host "'$appToMatch' is 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'Found EXIT"
		exit
} 

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP

RE: Help with script

(OP)
found an error this line
$platform = get-itemproperty HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration -name Platform
should be
$platform = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration -name Platform).Platform

MCSE NT to 2012, MCITP:EA/SA, MCSA, MCDBA, MCTS, MCP+I, MCP

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close