File: //var/opt/nydus/ops/customer_local_ops/control_panel/powershell/plesk_server_prep.ps1
#Check to see if plesk install currently running
$process = Get-WmiObject -query "select * from win32_process where " + `
"name like 'plesk-installer%' or name like 'parallels_installer_Microsoft_%'"
if($process){
$process | %{$_.Terminate()}
}
#Remove any old installs
Get-WmiObject -query "select * from win32_product where name like '%Plesk%'" | %{$_.uninstall()}
#Download Installer
powershell.exe Invoke-WebRequest https://hfs-public.secureserver.net/-/Windows/plesk-installer.exe `
-UseBasicParsing -OutFile C:\Windows\Temp\plesk-installer.exe
#Attempt clean install.
try{
C:\Windows\Temp\plesk-installer.exe --select-product-id=panel --select-release-latest `
--skip-components-check --ignore-key-errors --no-space-check --installation-type=typical
}catch{
#Verify Mysql startup
Get-Service | ?{$_.name -eq 'Mysql56' -and $_.Status -ne 'Running'} | Start-Service
"Mysql56" | %{
$service=gwmi win32_service -filter "name='$_' and not State='Running'"
if($service){
$service.ChangeStartMode("Automatic")
$service.startservice()
}
}
#Attempt to fix install
C:\Windows\Temp\plesk-installer.exe --select-product-id=panel --select-release-latest `
--skip-components-check --ignore-key-errors --no-space-check --upgrade-installed-components
}
Start-sleep -seconds 60
$verifyInstallLog = select-string -path C:\ParallelsInstaller\autoinstaller3.log -Pattern "The changes were applied successfully." -CaseSensitive
if((test-path C:\ParallelsInstaller\ai_action_time.xml) -and $verifyInstallLog){
"Plesk Successfully Installed"
exit 0
}
"ERROR - Plesk DID NOT INSTALL PROPERLY"
exit 1