Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

problem with a script

$
0
0

hey all,

I am having a problem with a powershell script that runs as a logon script in AD

it seems that sometimes it runs, and some times it doesnt, and i am at wits end with it.

its job, is to remove older versions of Logmein, and install the newest version.

I am checking based on the registry GuID, and if it is installed, and installed before a specific date, then remove the software and registry keys, and install the new copy.

i am very new to powershell, so i am open to anything

$service = "logmein"

#see if service is running, but program folder is missing, sign of incomplete install
if ((($service.Status) -eq "Running") -and (Test-Path -LiteralPath 'C:\Program Files (x86)\LogMeIn') -eq "false")
{
Stop-Service LMIGuardianSvc
Stop-Service LogMeIn
Stop-Service LMIMaint

Copy-Item \\srv-hayfile\Transport\logmein\LogMeInfull.msi c:\temp

Start-Process -wait -FilePath "c:\Windows\system32\msiexec.exe" -ArgumentList "/i c:\temp\logmeinfull.msi /quiet"

cd 'C:\Program Files (x86)\LogMeIn\x64'
.\logmein.exe restart

}

#Test if current Version is installed
if ((Test-Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{53E10F4E-B361-45D7-8DBD-A6BF073236F0}" ) -eq "true")

{
$logmeinreg = Get-ItemProperty 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{53E10F4E-B361-45D7-8DBD-A6BF073236F0}'



if ($logmeinreg.InstallDate -lt "20131203")
{
Stop-Service LMIGuardianSvc
Stop-Service LogMeIn
Stop-Service LMIMaint


cd 'C:\Program Files (x86)\LogMeIn\x64'
.\logmein.exe uninstall
cd 'c:\Program Files (x86)'


Remove-Item 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{53E10F4E-B361-45D7-8DBD-A6BF073236F0}' -Recurse
Remove-Item 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\E4F01E35163B7D54D8DB6AFB7023630F' -Recurse
Remove-Item 'HKLM:\SOFTWARE\LogMeIn' -Recurse
Remove-Item 'HKLM:\SOFTWARE\LogMeIn, Inc.' -Recurse


cd 'C:\Program Files (x86)\LogMeIn\x64'
.\logmein.exe uninstall
cd 'c:\Program Files (x86)'

Remove-Item 'c:\Program Files (x86)\logmein' -Recurse

Copy-Item \\srv-hayfile\Transport\logmein\LogMeInfull.msi c:\temp

Start-Process -wait -FilePath "c:\Windows\system32\msiexec.exe" -ArgumentList "/i c:\temp\logmeinfull.msi /quiet"

cd 'C:\Program Files (x86)\LogMeIn\x64'
.\logmein.exe restart

}

}
#Delete older version
elseif ((Test-Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{D3AE96EE-2876-4B3F-847C-D3A4AD689E43}" ) -eq "true")
{
Stop-Service LMIGuardianSvc
Stop-Service LogMeIn
Stop-Service LMIMaint


Remove-Item 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{D3AE96EE-2876-4B3F-847C-D3A4AD689E43}' -Recurse
Remove-Item 'HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Products\EE69EA3D6782F3B448C73D4ADA86E934' -Recurse
Remove-Item 'HKLM:\SOFTWARE\LogMeIn' -Recurse
Remove-Item 'HKLM:\SOFTWARE\LogMeIn, Inc.' -Recurse



cd 'C:\Program Files (x86)\LogMeIn\x64'
.\logmein.exe uninstall
cd 'c:\Program Files (x86)'

#delete Program files
Remove-Item 'c:\Program Files (x86)\logmein' -Recurse
#copy new program installer to temp dir
Copy-Item \\srv-hayfile\Transport\logmein\LogMeInfull.msi c:\temp
#run installer
Start-Process -wait -FilePath "c:\Windows\system32\msiexec.exe" -ArgumentList "/i c:\temp\logmeinfull.msi /quiet"
#restart service
cd 'C:\Program Files (x86)\LogMeIn\x64'
.\logmein.exe restart



}
if (((Test-Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{53E10F4E-B361-45D7-8DBD-A6BF073236F0}" ) -eq $False) -and (Test-Path -LiteralPath 'C:\Program Files (x86)\LogMeIn') -eq $true)
{

Stop-Service LMIGuardianSvc

Remove-Item 'HKLM:\software\logmein' -Recurse
Remove-Item 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\E4F01E35163B7D54D8DB6AFB7023630F' -Recurse
Remove-Item 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\EE69EA3D6782F3B448C73D4ADA86E934' -Recurse
Remove-Item 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\A48FA7BCF7B1B6C4A885BEC7ED842CA3' -Recurse
Remove-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders' -Name 'C:\Program Files (x86)\LogMeIn\'
Remove-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders' -Name 'C:\Program Files (x86)\LogMeIn\x64\'
Remove-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\Folders' -Name 'C:\Program Files (x86)\LogMeIn\x86\'

cd 'C:\Program Files (x86)\LogMeIn\x64'
.\logmein.exe uninstall
cd 'c:\Program Files (x86)'

Remove-Item 'c:\Program Files (x86)\logmein' -Recurse -force

Copy-Item \\srv-hayfile\Transport\logmein\LogMeInfull.msi c:\temp

Start-Process -wait -FilePath "c:\Windows\system32\msiexec.exe" -ArgumentList "/i c:\temp\logmeinfull.msi /quiet"

cd 'C:\Program Files (x86)\LogMeIn\x64'
.\logmein.exe restart

}


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>