Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Installing a SQL server on a remote system using Powershell 3

$
0
0

Hello,

I am trying to make a skript which installs the SQL Server (2013 Express) remote on another mashine (Server 2012). The first thought was, to use the Invoke-command:

Invoke-Command  -ComputerName $SRV1 -Credential $cred2  -Script {

    Start-Process -FilePath "c:\install\sql\SQLEXPRADV_x64_DEU.exe"  -ArgumentList " /Q `
     /INDICATEPROGRESS `

     /IACCEPTSQLSERVERLICENSETERMS=1 `

...

     /TCPENABLED=1 `
     }

This starts the EXE on the remote system. But it seems that the EXE cannot launch other processes, so this command stops quite soon.

Is there a trick, to start it another way (and waiting until its finished)?

I got a workarround which has a strange behavior on passwords:

I put everything in one line :

$SQL="c:\install\sql\SQLEXPRADV_x64_DEU.exe /Q /INDICATEPROGRESS /IACCEPTSQLSERVERLICENSETERMS=1 /SQLSYSADMINACCOUNTS=$ad\SQLM ...

and write it to the remote system using the Inwoke-Command and start the script:

Invoke-Command  -ComputerName $SRV1 -Credential $cred2  -Script {

Set-Content -Path d:\sql.ps1 -Encoding Unicode -Value $sql 

Start-Process powershell.exe -ArgumentList "-file d:\sQL.ps1" -Wait

}

The strange thing on this solution is, that if I put any User-Informattion like

   /SQLSVCACCOUNT=sbsrv\SQLSVC `
     /SQLSVCPassword= P@ssw0rd `

in this commandline, it will work only , if I execute the SQL.PS1 directly on the computer (console) or use an interactive session on this mashine. But if I use the invoke-Command the script stops after a while, with the error that Username or Password are not correct.

Without any user parameter the installation will be completed without any errors.

Do you know, why?

 

Many thanks in advance

 

Thorsten


Viewing all articles
Browse latest Browse all 6937

Trending Articles