Restore SSAS database using Windows PowerShell and SQL Server 2014 AMO

Hi Experts,

I am unable to restore the SSAS Cube 2014 database within the stipulated time (60 sec) and also the dialog box is not closed after the restoration is complete , not working as expected in SQL 2014 (using Power Shell)

Here is the link , I have used for the restoration of SSAS Cube 2008 , but the same is not working for SSAS 2014.

http://www.databasejournal.com/features/mssql/article.php/3799636/How-to-Restore-an-SSAS-database-using-Windows-PowerShell-and-SQL-Server-2008-AMO.htm


Thanks,

SRK
n_srikanth4Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Deepak ChauhanSQL Server DBACommented:
Use this.

Save the below code as .PS1 (powerhshell file)

[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$servername=New-Object Microsoft.AnalysisServices.Server
$servername.connect("lap039")
$servername.restore("D:\SHAREd\Vendor2008_05262015.abf","Vendor2008",$true)

But change the sever name and backup info in the file before execute.
Change server name hare >> $servername.connect("lap039")
Change Backup file and datbase name here
$servername.restore("D:\SHAREd\Vendor2008_05262015.abf","Vendor2008",$true)

Call the .PS1 file using powerhsell

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
n_srikanth4Author Commented:
Thanks Deepak for quick reply, but how can I exit out of the power shell dialog window and ensure that the restoration is completed. Is there any timeout property set in power shell ?
Deepak ChauhanSQL Server DBACommented:
Hi SRK, Sorry for the delay response, in this case you can use this code. Save this code as .PS1 and call the script with error output redirection

let says .PS1 file location and name is D:\Shared\SSAS_Restore_Script.PS1

now command is: D:\Shared\SSAS_Restore_Script.PS1 2>&1 > D:\Shared\SSAS.txt

but how can I exit out of the power shell dialog window

stop-process -Id $PID   --- For exit the window.

Write-output "Restore process started" >D:\Shared\Restore_Log.txt
[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
$servername=New-Object Microsoft.AnalysisServices.Server
$servername.connect("lap037")
$servername.restore("D:\SHAREd\Vendor2008_05262015.abf","Vendor2008",$true)
Type D:\Shared\SSAS.txt >>D:\Shared\Restore_Log.txt
Write-output "Restore process Completed" >>D:\Shared\Restore_Log.txt
stop-process -Id $PID

Open in new window



Please change the output file location and database name and file name accordingly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.