Monday, November 21, 2011

Access Plesk Database

Below are the ways to access different types of Plesk database

MS SQL: 


The database can be accessed using the following CLI command:

C:\Program Files\Microsoft SQL Server\80\Tools\Binn\osql –E

Or you can use the Microsoft SQL Server Management Studio Express


MySQL

Run the following command in 'command prompt'

cd %plesk_dir%\MySQL\bin

mysql -P8306 -uadmin -p psa



MS ACCESS DB (JET)

Use any utility that can used with MS ACCESS (.mdb) files


The Plesk database file is located in %plesk_dir%\admin\db\psa.mdb


Thanks :)

Find Database type used by Plesk

Here is the way to find which type of database is used by Plesk to store its information:

Run Registry editor by typing 'regedit' in the Run prompt

Find the below key:

HKEY_LOCAL_MACHINE\SOFTWARE\PLESK\PSA Config\Config


For X64 OS


HKEY_LOCAL_MACHINE\SOFTWARE\wow6432node\PLESK\PSA Config\Config

Under this, find the value

"PLESK_DATABASE_PROVIDER_NAME"

It could be any of the below 3 types:

- Jet  (MS ACCESS)
- MySQL
- MSSQL




Friday, November 11, 2011

Update Hardware Changes in Plesk 10.x Health Monitor

Sometimes, when you add new hardware to your server, those changes may not get reflected on the Plesk panel. Here is a method to manually update it.

Windows

Go to Command Prompt and enter these:
cd %plesk_bin%
php.exe -d auto_prepend_file="" "%plesk_dir%\admin\plib\scripts\setup-health-monitor.php"

Unix

# /usr/local/psa/bin/sw-engine-pleskrun /usr/local/psa/admin/plib/scripts/setup-health-monitor.php 


:) 

Saturday, November 5, 2011

Retrieve SQL Server 2008 Product Key

Open Power Shell and Paste the foll: script:

-------------------------------------------------
function Get-SQLserverKey {
    ## function to retrieve the license key of a SQL 2008 Server.
     param ($targets = ".")
    $hklm = 2147483650
    $regPath = "SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\Setup"
    $regValue1 = "DigitalProductId"
    $regValue2 = "PatchLevel"
    $regValue3 = "Edition"
    Foreach ($target in $targets) {
        $productKey = $null
        $win32os = $null
        $wmi = [WMIClass]"\\$target\root\default:stdRegProv"
        $data = $wmi.GetBinaryValue($hklm,$regPath,$regValue1)
        [string]$SQLver = $wmi.GetstringValue($hklm,$regPath,$regValue2).svalue
        [string]$SQLedition = $wmi.GetstringValue($hklm,$regPath,$regValue3).svalue
        $binArray = ($data.uValue)[52..66]
        $charsArray = "B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9"
        ## decrypt base24 encoded binary data
        For ($i = 24; $i -ge 0; $i--) {
            $k = 0
            For ($j = 14; $j -ge 0; $j--) {
                $k = $k * 256 -bxor $binArray[$j]
                $binArray[$j] = [math]::truncate($k / 24)
                $k = $k % 24
         }
            $productKey = $charsArray[$k] + $productKey
            If (($i % 5 -eq 0) -and ($i -ne 0)) {
                $productKey = "-" + $productKey
            }
        }
        $win32os = Get-WmiObject Win32_OperatingSystem -computer $target
        $obj = New-Object Object
        $obj | Add-Member Noteproperty Computer -value $target
        $obj | Add-Member Noteproperty OSCaption -value $win32os.Caption
        $obj | Add-Member Noteproperty OSArch -value $win32os.OSArchitecture
        $obj | Add-Member Noteproperty SQLver -value $SQLver
        $obj | Add-Member Noteproperty SQLedition -value $SQLedition
        $obj | Add-Member Noteproperty ProductKey -value $productkey
        $obj
    }
}

---------------------------------------

Now enter the below command

Get-SQLserverKey

Press Enter (may be twice)... Details will be shown in the Power Shell Window itself.. It worked for me :)