########################################################################
# Dedicated Server Provision Check
# Version .1
# Created by: Mell Rosandich
########################################################################
Param([switch]$showdebug) #shows all the vars at the end of the script - not a true debug
#Define Global vars etc.
#Result Vars
[array]$global:g_ResultString = ""
[array]$global:g_ResultFailLevel = ""
[array]$global:g_ResultFixText = ""
#Information Retrived about the System
$global:g_PSA_DB_SA = $null
$global:g_PSA_DB_Admin = $null
$global:g_ClientLogin = $null
$global:g_ClientDomain = $null
$global:g_ClientFullName = $null
$global:g_ClientPassword = $null
$global:g_NS1Name = $null
$global:g_NS2Name = $null
$global:g_NS1IP = $null
$global:g_NS2IP = $null
$global:g_ServerIP = $null
$global:g_ServerHostName = $null
$global:g_ServerHostIP = $null #Ipv6 address from
$global:g_ServerIPS = @()
#Key Look ups
$global:g_PSA_MS_User = "sa"
$global:g_PSA_My_User = "admin"
#Internal Vars
$global:g_ClientPath = $Env:plesk_bin + '\plesksrvclient.exe'
$global:g_BinPath = $Env:plesk_bin + '\dbclient.exe'
$global:g_MySQLBin = $Env:plesk_dir + '\Databases\MySQL51\bin\mysql.exe'
$global:g_MySQLAdmin = $Env:plesk_dir + '\Databases\MySQL51\bin\mysqladmin.exe'
$global:g_SmarterMailBase = "C:\SmarterMail\Domains\"
$global:g_isGoodProvision = $false
$global:cookie = $null
function BuildErrorList($TestResult,$BadText,$GoodText,$FailLevel ){
# $FailLevel
# 1-10 . 1 Ok, 10 Critcal Stop, 0=seperator for display
if( $FailLevel -eq 0 ){ $TestResult=$null;$BadText="----------------------";$GoodText="----------------------"; }
if( ($TestResult -eq $null) -or ($TestResult -eq $false) ){$global:g_ResultString += $BadText;$global:g_ResultFailLevel+= $FailLevel }else{$global:g_ResultString += $GoodText;$global:g_ResultFailLevel+= 1}
Write-Host "." -NoNewline
}
function ErrorListSeperator{
BuildErrorList "" "" "" 0
}
function BuildFixitList($TextIn){
$global:g_ResultFixText += $TextIn
}
#Lets Get the Admin User and password for MS SQL and MYSQL
function PSA_GetDBADMIN()
{
$oPSALoginDBInfo = Invoke-Expression "& '$global:g_BinPath' --direct-sql --sql='select admin_login, admin_password from databaseservers;'"
foreach ($sSQlReturnItem in $oPSALoginDBInfo)
{
if( $sSQlReturnItem -ne $null){
$sTemp = $sSQlReturnItem.split()
if( $sTemp[0] -eq $global:g_PSA_MS_User){ $global:g_PSA_DB_SA = $sTemp[1].trim();}
if( $sTemp[0] -eq $global:g_PSA_My_User){ $global:g_PSA_DB_Admin = $sTemp[1].trim()}
}
}
$global:g_PSA_DB_SA = getpass-mssql
$global:g_PSA_DB_Admin = getpass-mysql
BuildErrorList $global:g_PSA_DB_SA "Plesk MS SQL ADMIN Bad" "Plesk MS SQL ADMIN OK" 10
BuildErrorList $global:g_PSA_DB_Admin "Plesk MY SQL ADMIN Bad" "Plesk MY SQL ADMIN OK" 10
}
function Get-ClipboardText()
{
$command =
{
add-type -an system.windows.forms
[System.Windows.Forms.Clipboard]::GetText()
}
powershell -sta -noprofile -command $command
}
#Check Plesk user and domain
function CheckPleskDomainAndUser()
{
#For Plesk to work you need 1 account with type admin
$sAdminID = $null
$sPrimaryDomain = $null
$sAdminName = $null
$oPSADomainName = Invoke-Expression "& '$global:g_BinPath' --direct-sql --sql='select cl_id,displayName from domains;'"
foreach ($oTemp in $oPSADomainName)
{
$sTemp = $oTemp.split()
if( $sTemp[0] -ne ""){$sPrimaryDomain = $sTemp[1].trim();$sAdminID = $sTemp[0]}
}
$oPSAAdminAccount = Invoke-Expression "& '$global:g_BinPath' --direct-sql --sql='select id,login,account_id,pname from clients;'"
foreach ($oTemp in $oPSAAdminAccount)
{
$sTemp = $oTemp.split()
if( $sTemp[0] -eq $sAdminID ){$sAdminName = $sTemp[1].trim()}
if( $sTemp[0] -eq $sAdminID ){$global:g_ClientFullName = $sTemp[3].trim()}
if( $sTemp[0] -eq $sAdminID ){$global:g_ClientPassword = $sTemp[2].trim()}
}
$oPleskLogin = Invoke-Expression "& '$global:g_ClientPath' -get -nogui"
$global:g_ClientPassword = Get-ClipboardText
$oHostInnfo = Invoke-Expression "& '$global:g_BinPath' --direct-sql --sql='select param,val from misc where param=''FullHostName'';'"
foreach ($oTemp in $oHostInnfo)
{
$sTemp = $oTemp.split()
if( $sTemp[0] -eq "FullHostName" ){$global:g_ServerHostName = $sTemp[1].trim()}
}
$ping = new-object System.Net.NetworkInformation.Ping
$pingoptions = new-object System.Net.NetworkInformation.PingOptions
if( $global:g_ServerHostName -ne $null ){
$rslt = $ping.send($global:g_ServerHostName)
if ($rslt.status.tostring() –eq "Success") {
$global:g_ServerHostIP = $rslt.Address
}
}
$global:g_ClientLogin = $sAdminName
$global:g_ClientDomain = $sPrimaryDomain
BuildErrorList $sAdminID "Plesk Admin Bad" "Plesk Admin OK" 10
BuildErrorList $sPrimaryDomain "Plesk Primary Domain Bad" "Plesk Primary Domain OK" 10
#Resolution
if( $sAdminID -eq $null){BuildFixitList "Plesk is missing the user account for the customer. Recommend reprovision";}
if( $sPrimaryDomain -eq $null){BuildFixitList "Plesk is missing the default user domain for the customer. Recommend reprovision";}
}
function CheckMSSQLAccess{
if( $global:g_PSA_DB_SA -eq $null ){
return
}
$MLMconnection = $null
$MLMcommand = $null
$MLMresult = $null
$MLMconnection = New-Object System.Data.Odbc.OdbcConnection
$MLMcommand = New-Object System.Data.Odbc.OdbcCommand
$MLMcommand.Connection = $MLMconnection
$MLMconnection.ConnectionString = "Driver={SQL Server};Server=localhost;database=master;UID=$global:g_PSA_MS_User;PWD=$global:g_PSA_DB_SA;"
try{
$MLMconnection.Open()
}
catch{}
if($MLMconnection.State -ne [System.Data.ConnectionState]::Open)
{
BuildErrorList $null "MSSQL connection as SA Password Bad" "MSSQL connection as SA Password OK" 10
BuildFixitList "Plesk component MSSQL has a differnt password then the MS SQL server. Resolution: login to plesk and set password"
}
else
{
BuildErrorList "Good SA PASS" "MSSQL connection as SA Password Bad" "MSSQL connection as SA Password OK" 10
$MLMcommand.CommandType = [System.Data.CommandType]::Text
$MLMcommand.CommandText = "CREATE DATABASE ProvisionTestDB"
try{
$DBCreateResult = $MLMcommand.ExecuteNonQuery()
}
catch{
BuildErrorList $null "MSSQL connection as SA DB Create Bad" "MSSQL connection as SA DB Create OK" 10
BuildFixitList "Plesk component MSSQL has a differnt password then the MS SQL server. Resolution: login to plesk and set password"
}
if( $DBCreateResult -eq "-1" ){
BuildErrorList "Good DB" "MSSQL connection as SA DB Create Bad" "MSSQL connection as SA DB Create OK" 10
}
else
{
BuildErrorList $null "MSSQL connection as SA DB Create Bad" "MSSQL connection as SA DB Create OK" 10
BuildFixitList "SA User in MSSQL has bad permissions. Resolution: open sql manager and give SA DB owner in system db"
}
$MLMcommand.CommandText = "DROP DATABASE ProvisionTestDB"
try{
$DBCreateResult = $MLMcommand.ExecuteNonQuery()
}
catch{
BuildErrorList $null "MSSQL connection as SA DB DROP Bad" "MSSQL connection as SA DB DROP OK" 10
}
if( $DBCreateResult -eq "-1" ){
BuildErrorList "Good Drop" "MSSQL connection as SA DB DROP Bad" "MSSQL connection as SA DB DROP OK" 10
}
}
}
function CheckMYSQLAccess{
if( $global:g_PSA_DB_Admin -eq $null ){
return
}
$oMySQLTest = $null
#we are going to just verify that we can connect with dbclient since it writes back on error
$SQLVersion = '--direct-sql --sql="select version();"'
$oMySQLTest = Invoke-Expression "& '$global:g_BinPath' $SQLVersion --login=admin --port=3306 --password='$global:g_PSA_DB_Admin' --db=mysql"
if( $oMySQLTest -eq "Failed to connect to database: Access denied for user 'admin'@'localhost' (using password: YES)" ){
BuildErrorList $null "MySQL connection as Admin Password Bad" "MySQL connection as Admin Password OK" 10
}
else
{
BuildErrorList "Good Login" "MySQL connection as Admin Password Bad" "MySQL connection as AdminPassword OK" 10
$oMySQLTest = Invoke-Expression "& '$global:g_MySQLAdmin' create ProvisionTestDB -uadmin -p$global:g_PSA_DB_Admin -s"
$oMySQLTest = Invoke-Expression "& '$global:g_MySQLAdmin' drop ProvisionTestDB -uadmin -p$global:g_PSA_DB_Admin -f -s"
if( $oMySQLTest -eq 'Database "ProvisionTestDB" dropped' ){
BuildErrorList "Good Drop" "MySQL connection as Admin DB DROP Bad" "MySQL connection as Admin DB CREATE/DROP OK" 10
}
else
{
BuildErrorList $null "MySQL connection as Admin DB CREATE/DROP Bad" "MySQL connection as Admin DB DROP OK" 10
}
}
}
function SmaterMailDomainCheck{
$TestPath = $global:g_SmarterMailBase + $global:g_ClientDomain + "\domainConfig.xml"
$bValidBin = Test-Path $TestPath
$sTemptest = $null
if( $bValidBin ){$sTemptest="Found COnfig"}
BuildErrorList $sTemptest "SmarterMail config not found BAD" "SmarterMail config found OK" 8
#Check the ports for all services!
foreach ($SmarterMailIP in $global:g_ServerIPS) {
$SMPort25 = TestIConnections $SmarterMailIP 25 3000
BuildErrorList $SMPort25 "SmarterMail SMTP PORT $SmarterMailIP BAD" "SmarterMail SMTP PORT $SmarterMailIP OK" 10
$SMPort26 = TestIConnections $SmarterMailIP 26 3000
BuildErrorList $SMPort25 "SmarterMail SMTP-26 PORT $SmarterMailIP BAD" "SmarterMail SMTP-26 PORT $SmarterMailIP OK" 10
$SMPort110 = TestIConnections $SmarterMailIP 110 3000
BuildErrorList $SMPort110 "SmarterMail POP3 PORT $SmarterMailIP BAD" "SmarterMail POP3 PORT $SmarterMailIP OK" 10
$SMPort143 = TestIConnections $SmarterMailIP 143 3000
BuildErrorList $SMPort143 "SmarterMail IMAP PORT $SmarterMailIP BAD" "SmarterMail IMAP PORT $SmarterMailIP OK" 10
$SMPort9998 = TestIConnections $SmarterMailIP 9998 3000
BuildErrorList $SMPort9998 "SmarterMail Web PORT $SmarterMailIP BAD" "SmarterMail Web PORT $SmarterMailIP OK" 10
if($SMPort25 -eq $false){BuildFixitList "SmarterMail entire Service is off or Smartermail smtp is disable (ip: $SmarterMailIP). Login SM admin/service IP address.verify listening."}
if($SMPort110 -eq $false){BuildFixitList "SmarterMail entire Service is off or Smartermail smtp is disable (ip: $SmarterMailIP). Login SM admin/service IP address.verify listening."}
if($SMPort143 -eq $false){BuildFixitList "SmarterMail entire Service is off or Smartermail smtp is disable (ip: $SmarterMailIP). Login SM admin/service IP address.verify listening."}
if($SMPort9998 -eq $false){BuildFixitList "SmarterMail Web Service is off or IIS has no bindings for pot 9998 (ip: $SmarterMailIP). Login SM admin/service IP address.verify listening."}
}
}
function DNSCheckSettings{
$aNS = @()
$oDNSNS = Invoke-Expression "& '$global:g_BinPath' --direct-sql --sql='select type,val from dns_recs where type=''NS'' limit 2;'"
foreach ($oTemp in $oDNSNS)
{
$sTemp = $oTemp.split()
if( $sTemp[0] -eq "NS"){$aNS += $sTemp[1].trim();}
}
$global:g_NS1Name,$global:g_NS2Name = $aNS
BuildErrorList $global:g_NS1Name "NS-1 BAD" "NS-1 $global:g_NS1Name OK" 10
BuildErrorList $global:g_NS2Name "NS-2 BAD" "NS-2 $global:g_NS2Name OK" 10
$ping = new-object System.Net.NetworkInformation.Ping
if( $global:g_NS1Name -ne $null ){
try{
$rslt = $ping.send($global:g_NS1Name)
if ($rslt.status.tostring() –eq "Success") {
$global:g_NS1IP = $rslt.Address
$global:g_ServerIP = $rslt.Address
BuildErrorList $global:g_NS1Name "NS-1 PING BAD" "NS-1 $global:g_NS1IP PING OK" 5
}else {
BuildErrorList $null "NS-1 PING BAD" "NS-1 PING OK" 5
}
}
catch{
BuildErrorList $global:g_NS1Name "NS-1 PING BAD" "NS-1 $global:g_NS1IP PING OK" 5
}
}
if( $global:g_NS2Name -ne $null ){
try{
$rslt = $ping.send($global:g_NS2Name)
if ($rslt.status.tostring() –eq "Success") {
$global:g_NS2IP = $rslt.Address
BuildErrorList $global:g_NS1Name "NS-2 PING BAD" "NS-2 $global:g_NS2IP PING OK" 5
}else {
BuildErrorList $null "NS-2 PING BAD" "NS-2 PING OK" 5
}
}catch{
BuildErrorList $null "NS-2 PING BAD" "NS-2 PING OK" 5
}
}
$cmdns1 = "nslookup " + $global:g_NS1Name + " localhost"
$cmdns2 = "nslookup " + $global:g_NS2Name + " localhost"
try{
$result1 = Invoke-Expression ($cmdns1)
}catch{
BuildErrorList $null "NS-lookup NS-1 BAD" "NSLOOKUP NS-1 $global:g_NS1IP OK" 10
}
try{
$result2 = Invoke-Expression ($cmdns2)
}catch{
BuildErrorList $null "NS-lookup NS-1 BAD" "NSLOOKUP NS-1 $global:g_NS1IP OK" 10
}
[string]$NewR1 = $result1.SyncRoot[4]
[string]$NewR2 = $result2.SyncRoot[4]
$aNewR1 = $NewR1.split()
$aNewR2 = $NewR2.split()
if( $aNewR1[2] -match "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b" )
{
$global:g_NS1IP = $aNewR1[2]
$global:g_ServerIP =$aNewR1[2]
BuildErrorList $global:g_NS1Name "NS-lookup NS-1 BAD" "NSLOOKUP NS-1 $global:g_NS1IP OK" 10
}
else
{
BuildErrorList $null "NS-lookup NS-1 BAD" "NSLOOKUP NS-1 $global:g_NS1IP OK" 10
}
if( $aNewR2[2] -match "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b" )
{
$global:g_NS2IP = $aNewR2[2]
BuildErrorList $global:g_NS2Name "NS-lookup NS-2 BAD" "NSLOOKUP NS-2 $global:g_NS2IP OK" 10
}
else
{
BuildErrorList $null "NS-lookup NS-2 BAD" "NSLOOKUP NS-2 $global:g_NS2IP OK" 10
}
}
function DNSRecTemplate{
#values to verify:
$ns1 = $null #Name Server
$ns2 = $null #Name Server
$a1 = $null # domain - ip
$a2 = $null # webmail
$a3 = $null #mail
$a4 = $null # mssql
$mx = $null
$cn1 = $null
$cn2 = $null
$mx2 = $null
#lets compare that the template is there and looks right.
$oDNSNS = Invoke-Expression "& '$global:g_BinPath' --direct-sql --sql='select type,host,val from dns_recs_t;'"
foreach ($oTemp in $oDNSNS)
{
$sTemp = $oTemp.split()
if( $sTemp[0] -eq "NS" -and $ns1 -eq $null ){if( $sTemp[1].trim() -eq "<domain>." -and ($global:g_NS1Name -eq $sTemp[2].trim() -or $global:g_NS2Name -eq $sTemp[2].trim()) ){$ns1 = $true} ;}
if( $sTemp[0] -eq "NS" -and $ns2 -eq $null ){if( $sTemp[1].trim() -eq "<domain>." -and ($global:g_NS1Name -eq $sTemp[2].trim() -or $global:g_NS2Name -eq $sTemp[2].trim()) ){$ns2 = $true} ;}
if( $sTemp[0] -eq "A" -and $a1 -eq $null ){if( $sTemp[1].trim() -eq "<domain>." -and $sTemp[2].trim() -eq "<ip>"){ $a1 = $true } }
if( $sTemp[0] -eq "A" -and $a2 -eq $null ){if( $sTemp[1].trim() -eq "webmail.<domain>." -and $sTemp[2].trim() -eq "<ip>"){ $a2 = $true } }
if( $sTemp[0] -eq "A" -and $a3 -eq $null ){if( $sTemp[1].trim() -eq "mail.<domain>." -and $sTemp[2].trim() -eq "<ip>"){ $a3 = $true } }
if( $sTemp[0] -eq "A" -and $a4 -eq $null ){if( $sTemp[1].trim() -eq "mssql.<domain>." -and $sTemp[2].trim() -eq "<ip>"){ $a4 = $true } }
if( $sTemp[0] -eq "MX" -and $mx -eq $null ){if( $sTemp[1].trim() -eq "<domain>." -and $sTemp[2].trim() -eq "mail.<domain>."){ $mx = $true } }
if( $sTemp[0] -eq "TXT" -and $mx2 -eq $null ){
$TempText = $sTemp[2] + " " + $sTemp[3] + " " + $sTemp[4] + " " + $sTemp[5]
if( $sTemp[1].trim() -eq "<domain>." -and $TempText -eq 'v=spf1 a mx ~all'){ $mx2 = $true }
}
if( $sTemp[0] -eq "CNAME" -and $cn1 -eq $null ){if( $sTemp[1].trim() -eq "ftp.<domain>." -and $sTemp[2].trim() -eq "<domain>."){ $cn1 = $true } }
if( $sTemp[0] -eq "CNAME" -and $cn2 -eq $null ){if( $sTemp[1].trim() -eq "www.<domain>." -and $sTemp[2].trim() -eq "<domain>."){ $cn2 = $true } }
#Write-Host $sTemp[0] $sTemp[1] $sTemp[2] $sTemp[3]
}
BuildErrorList $ns1 "DNS Template NS BAD" "DNS Template NS OK" 10
BuildErrorList $ns2 "DNS Template NS BAD" "DNS Template NS OK" 10
BuildErrorList $a1 "DNS Template AName domain BAD" "DNS Template AName domain OK" 10
BuildErrorList $a2 "DNS Template AName webmail BAD" "DNS Template AName webmail OK" 10
BuildErrorList $a3 "DNS Template AName mail BAD" "DNS Template AName mail OK" 10
BuildErrorList $a4 "DNS Template AName mssql BAD" "DNS Template AName mssql OK" 10
BuildErrorList $mx "DNS Template MX BAD" "DNS Template MX OK" 10
BuildErrorList $mx2 "DNS Template TXT BAD" "DNS Template TXT OK" 10
BuildErrorList $cn1 "DNS Template CNAME FTP BAD" "DNS Template CNAME FTP OK" 10
BuildErrorList $cn2 "DNS Template CNAME WWW BAD" "DNS Template CNAME WWW OK" 10
if($ns1 -eq $null -or $ns2 -eq $null -or $a1 -eq $null -or $a2 -eq $null -or $a3 -eq $null -or $a4 -eq $null -or $mx -eq $null -or $cn1 -eq $null -or $cn2 -eq $null )
{
BuildFixitList "Login To Plesk and Correct DNS Template. You will probally need to rebuild the DNS for the Main Domain as well";
}
}
function StartMessage{
Write-Host "-----------------------------------------------------------------";Write-Host " _________ .__ __ .__ ";Write-Host " \_ ___ \| |__ ____ ____ | | _|__| ____ ____ ";Write-Host " / \ \/| | \_/ __ \_/ ___\| |/ / |/ \ / ___\ ";Write-Host " \ \___| Y \ ___/\ \___| <| | | \/ /_/ >";Write-Host " \______ /___| /\___ >\___ >__|_ \__|___| /\___ / ";Write-Host " \/ \/ \/ \/ \/ \//_____/ ";Write-Host "-----------------------------------------------------------------"
}
function OverAllMessage{
$OverAllStatus = 1
foreach( $nItems in $global:g_ResultFailLevel ){
if($nItems -eq 10){$OverAllStatus = 10}
}
if( $OverAllStatus -eq 10 ){
#failed
$global:g_isGoodProvision = $false
Write-Host "------------------------------" -foregroundcolor Red;Write-Host " __________ .__.__ " -foregroundcolor Red;Write-Host " \_ _____/____ |__| | " -foregroundcolor Red;Write-Host " | __) \__ \ | | | " -foregroundcolor Red;Write-Host " | \ / __ \| | |__" -foregroundcolor Red;Write-Host " \___ / (____ /__|____/" -foregroundcolor Red;Write-Host " \/ \/ " -foregroundcolor Red;Write-Host "------------------------------" -foregroundcolor Red
}
else
{
#pass
$global:g_isGoodProvision = $true
Write-Host "---------------------------------------" -foregroundcolor Green;Write-Host " __________ " -foregroundcolor Green;Write-Host " \______ \_____ ______ ______" -foregroundcolor Green;Write-Host " | ___/\__ \ / ___// ___/" -foregroundcolor Green;Write-Host " | | / __ \_\___ \ \___ \ " -foregroundcolor Green;Write-Host " |____| (____ /____ >____ >" -foregroundcolor Green;Write-Host " \/ \/ \/ " -foregroundcolor Green;Write-Host "---------------------------------------" -foregroundcolor Green
}
}
function WelcomeEmailCB{
$welcomeemail = "$global:g_ClientFullName, Welcome to the HostGator family!`n`nYour Primary Domain: $global:g_ServerHostName`nYour Server IP address: $global:g_ServerIP`n`nYour name servers that must be registered are:`nns1.$global:g_ClientDomain - $global:g_NS1IP`nns2.$global:g_ClientDomain - $global:g_NS2IP`n`nPlease visit http://www.hostgator.com/privatenameservers.shtml for more`ninformation on registering private nameservers if you need further help.`n`nRemote Desktop Connection:`n=================`n`nComputer : $global:g_ServerIP`nUsername : serveradmin`nPassword : $global:g_ClientPassword`n`nTo access Remote Desktop Connection Utility on your computer, navigate to`nStart > All Programs > Accessories > Remote Desktop Connection`n`n`nPlesk Admin Control Panel (complete Plesk management):`n============`nPlesk Login URL : https://" + $global:g_ServerIP + ":8443 <https://" + $global:g_ServerIP + ":8443>`nPlesk Username : admin`nPlesk Password : $global:g_ClientPassword`n`n`nPlesk Client Control Panel (only your domain,ftp,etc):`n============`nPlesk Login URL : https://" + $global:g_ServerIP + ":8443 <https://" + $global:g_ServerIP + ":8443>`nPlesk Username : $global:g_ClientLogin `nPlesk Password : $global:g_ClientPassword`n`n`nSmarterMail Administration:`n============`nSmarterMail Login URL : http://" + $global:g_ServerIP + ":9998 <http://" + $global:g_ServerIP + ":9998>`nSmarterMail Username : admin`nSmarterMail Password : $global:g_ClientPassword`n`n`nPlease note: You have 2 logins for Plesk.`nThe admin login will allow you to create clients and adjust settings server wide as well as imitate any client.`nSince you have a domain in Plesk you also have a client login. This is a limited login where you only manage items`nrelating to your domain such as FTP, email address, sub domains, etc. If you wanted to FTP files to your server;`nadmin would not work but your client user and password would work.`n`nHere are some steps we recommend for you and your new Windows Server:`n`nSetup Scheduled Backups: One of the first steps we recommend is to`nconfigure your new server with scheduled backups. If you do not already`nhave a custom backup solution or need assistance in setting up your`nscheduled backups, please let us know, and we will be more than happy to`nassist you in configuring an acceptable backup solution.`n`nView Our Video Tutorials: Learn the basics in how to manage and`nconfigure server applications such as Plesk Control Panel which may save`nyou a phone call or ticket. You can view our over 500+ video tutorials`nat http://www.hostgator.com/tutorials.shtml`n`nVisit Our Support Portal: Need to upgrade your server (e.g. additional`nHard Drive)? Need to manage your billing or contact us via Ticket, Chat,`nor Phone? Check out our HostGator Support Portal at`nhttp://support.hostgator.com/`n`nIf you would like us to move your files over from an existing account,`nplease fill out this form:`nhttps://secure.hostgator.com/resellertransferdedicated.php`n`nIf you have any problems or questions please email us at`
new-alias Out-Clipboard $env:SystemRoot\system32\clip.exe
$welcomeemail | Out-Clipboard
}
function ResolutionsCB{
new-alias Out-Clipboard $env:SystemRoot\system32\clip.exe
$FixitList = $global:g_ResultFixText -join "`n"
$FixitList | Out-Clipboard
}
function TestIConnections([string]$srv,$port=135,$timeout=3000){
$ErrorActionPreference = "SilentlyContinue"
$tcpclient = new-Object system.Net.Sockets.TcpClient
$iar = $tcpclient.BeginConnect($srv,$port,$null,$null)
$wait = $iar.AsyncWaitHandle.WaitOne($timeout,$false)
if(!$wait)
{
# Close the connection and report timeout
$tcpclient.Close()
Return $false
}
else
{
# Close the connection and report the error if there is one
$error.Clear()
$tcpclient.EndConnect($iar) | out-Null
if(!$?){$failed = $true}
$tcpclient.Close()
}
if($failed){return $false}else{return $true}
}
function GetServerGoodIPs{
$TempIpList= Get-WMIObject win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -eq $true } | Foreach-Object { $_.IPAddress } | Foreach-Object { [IPAddress]$_ } | Where-Object { $_.AddressFamily -eq 'Internetwork' } | Foreach-Object { $_.IPAddressToString }
foreach ($ipdr in $TempIpList) {
if( $ipdr.StartsWith("10.") -ne $true -or $ipdr.EndsWith(".0") -eq $true ){
$global:g_ServerIPS += $ipdr
}
}
}
function GetURLData( [string]$InURL,[string]$PostData){
#Since thbis is local host lets remove the security warning for any CERT
$netAssembly = [Reflection.Assembly]::GetAssembly([System.Net.Configuration.SettingsSection])
IF($netAssembly) {
$bindingFlags = [Reflection.BindingFlags] "Static,GetProperty,NonPublic"
$settingsType = $netAssembly.GetType("System.Net.Configuration.SettingsSectionInternal")
$instance = $settingsType.InvokeMember("Section", $bindingFlags, $null, $null, @())
if($instance) {
$bindingFlags = "NonPublic","Instance"
$useUnsafeHeaderParsingField = $settingsType.GetField("useUnsafeHeaderParsing", $bindingFlags)
if($useUnsafeHeaderParsingField) {
$useUnsafeHeaderParsingField.SetValue($instance, $true)
}
}
}
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$wc = new-object system.net.WebClient;
if( $PostData -ne "nopost" ){
#Send login credentials
$wc.Headers.Add("Content-Type","application/x-www-form-urlencoded")
[byte[]]$byteArray = [System.Text.Encoding]::ASCII.GetBytes($PostData)
$wc.Headers.Add( "User-Agent", "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0;)" )
$webpage = $wc.UploadData($InURL,"POST",$byteArray);
$global:cookie = $wc.ResponseHeaders["Set-Cookie"]
$global:cookie = ($global:cookie.Split(',') -match '^\S+=\S+;' -replace ';.*','') -join '; '
}
else
{
$wc.Headers.Add( "User-Agent", "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0;)" )
$wc.Headers.Add("Cookie", $global:cookie)
$webpage = $wc.DownloadData($InURL);
Write-Host "Cookie: "$global:cookie
}
$webpage = [System.Text.Encoding]::ASCII.GetString($webpage)
return $webpage;
}
function ValidatePleskSite{
#http://127.0.0.1:9998/Login.aspx?email=HGSMAdmin&password=Xb2k05wWHh0Zm
$WebURL = "https://localhost:8443/login_up.php3";
$PulledDataAsc = GetURLData $WebURL "login_name=admin&passwd=$global:g_ClientPassword"
#check for redir page
Write-Host $PulledDataAsc
if($PulledDataAsc -contains "top.location='/';" -or 1 -eq 1){
$PulledDataAsc = GetURLData "https://localhost:8443/index.php" "nopost"
}
Write-Host $PulledDataAsc
#The license key is invalid
}
function CheckPleskWeb{
#Since thbis is local host lets remove the security warning for any CERT
$netAssembly = [Reflection.Assembly]::GetAssembly([System.Net.Configuration.SettingsSection])
IF($netAssembly) {
$bindingFlags = [Reflection.BindingFlags] "Static,GetProperty,NonPublic"
$settingsType = $netAssembly.GetType("System.Net.Configuration.SettingsSectionInternal")
$instance = $settingsType.InvokeMember("Section", $bindingFlags, $null, $null, @())
if($instance) {
$bindingFlags = "NonPublic","Instance"
$useUnsafeHeaderParsingField = $settingsType.GetField("useUnsafeHeaderParsing", $bindingFlags)
if($useUnsafeHeaderParsingField) {
$useUnsafeHeaderParsingField.SetValue($instance, $true)
}
}
}
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$wc = new-object system.net.WebClient;
#initial login get session cookie
$wc.Headers.Add("Content-Type","application/x-www-form-urlencoded")
[byte[]]$byteArray = [System.Text.Encoding]::ASCII.GetBytes("login_name=admin&passwd=$global:g_ClientPassword")
$wc.Headers.Add( "User-Agent", "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0;)" )
$webpage = $wc.UploadData("https://localhost:8443/login_up.php3","POST",$byteArray);
$global:cookie = $wc.ResponseHeaders["Set-Cookie"]
$global:cookie = ($global:cookie.Split(',') -match '^\S+=\S+;' -replace ';.*','') -join '; '
$wc.Headers.Add( "User-Agent", "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0;)" )
$wc.Headers.Add("Cookie", $global:cookie)
$webpage = $wc.DownloadData($InURL);
}
function DebuggOutPut{
Write-Host "---------- DEBUG VAR DUMP -----------"
Write-Host "MSSQL - PASS "$global:g_PSA_DB_SA
Write-Host "MySQL PASS "$global:g_PSA_DB_Admin
Write-Host "----------"
Write-Host "Client Loin "$global:g_ClientLogin
Write-Host "Client Domain "$global:g_ClientDomain
Write-Host "Client Name "$global:g_ClientFullName
Write-Host "Client Password "$global:g_ClientPassword
Write-Host "----------"
Write-Host "NS1 NAME "$global:g_NS1Name
Write-Host "NS2 NAME "$global:g_NS2Name
Write-Host "NS1 IP "$global:g_NS1IP
Write-Host "NS2 IP "$global:g_NS2IP
Write-Host "----------"
Write-Host "Server HostName "$global:g_ServerHostName
Write-Host "Server Host IP "$global:g_ServerHostIP
Write-Host "Server Main IP "$global:g_ServerIP
}
function CheckForPleskBin(){
$bValidBin = Test-Path $global:g_BinPath
$sTemptest = $null
if( $bValidBin ){$sTemptest="Found Bin"}
BuildErrorList $bValidBin "Plesk Bin Bad" "Plesk Bin OK" 10
if($bValidBin -eq $false){BuildFixitList "Plesk BIN is missing, recommend running provsion script. If you already ran the provsion. OS reload then reprovision";}
return $bValidBin
}
function CheckForMySQLBins(){
$bValidBin = Test-Path $global:g_MySQLBin
$sTemptest = $null
if( $bValidBin ){$sTemptest="Found Bin"}
BuildErrorList $bValidBin "MySQL Bin Bad" "MySQL Bin OK" 10
if($bValidBin -eq $false){BuildFixitList "MySQL BIN is missing, recommend running provsion script. If you already ran the provsion. OS reload then reprovision";}
return $bValidBin
}
#--------------------------------------------------------------------------------------------
# RUN - TIME!
#--------------------------------------------------------------------------------------------
StartMessage #send start message
Write-Host "Checking." -nonewline
ErrorListSeperator #output seperator
$CheckPleskBinFile = CheckForPleskBin #Check to verify the the plesk bin exsits
$CheckMySQLBin = CheckForMySQLBins
if( ($CheckPleskBinFile -eq $True) -and $CheckMySQLBin -eq $True ){
GetServerGoodIPs #get the good IPs into a global array
PSA_GetDBADMIN #Get Admin and SA password: set global scope
CheckPleskDomainAndUser #Get Domain Name and User for that Domain,user info: set global scope
CheckMSSQLAccess #Login to MS SQL with credential provided by plesk: create DB, verify, drop DB
CheckMYSQLAccess #Login to MY SQL with credential provided by plesk: create DB, verify, drop DB
ErrorListSeperator #output seperator
SmaterMailDomainCheck #Check Smartermail config and other SM items
ErrorListSeperator #output seperator
DNSCheckSettings #Check DNS Name servers and Plesk DNS Information
DNSRecTemplate #Check DNS Template
ErrorListSeperator #output seperator
#ValidatePleskSite #HTTP to URL and make sure we dont get expired license must be the dashboard page
}
#Write Out Report
Write-Host "`n"
Write-Host "Report:" -nonewline
for( $idex=0;$idex -lt $global:g_ResultString.length;$idex++ ){
if( $global:g_ResultFailLevel[$idex] -eq 10 ){
Write-Host $global:g_ResultString[$idex] -foregroundcolor Yellow
}
else
{
Write-Host $global:g_ResultString[$idex]
}
}
#Show Pass Fail Message
OverAllMessage
if($global:g_isGoodProvision -eq $true){
$sRepling = read-host "Would you like to copy the welcome email to your clipboard [y/n]?"
if($sRepling -eq "y" -or $sRepling -eq "Y" ){Write-Host "Welcome email Copied to Clipboard";WelcomeEmailCB}
}
else
{
$sRepling = read-host "Would you like to copy the resolution list clipboard [y/n]?"
if($sRepling -eq "y" -or $sRepling -eq "Y" ){Write-Host "Resolutions Copied to Clipboard";ResolutionsCB}
}
#pass -showdebug to get results of collected data
if( $showdebug ){
DebuggOutPut
}