How can the System databases in SQL Server 2016 be moved using Powershell?

Posted on

Question :

I’m trying to move the system databases using Powershell ie. without using any T-SQL.

  1. Using SMO :
    Install-Module SQL-SMO
    $smo = New-SMO -ServerName localhost
    $smo.databases["TempDB"].PrimaryFilePath= "F:Tempdb"

    Answer :

Leave a Reply

Your email address will not be published. Required fields are marked *