2 Replies Latest reply on Dec 9, 2011 6:34 AM by Bill Robinson

    Installing SQLServer via PowerShell



      I must admit this is probably more of a Windows Sripting question, but it's something todo with the BBSA Agent environment. Hence my post here.


      I have a powershell script I am using to install SQLServer.

      The whole reason for the script was to be able to pass SQLSYSADMINACCOUNTS names which had spaces in them.


      The situation is that when the script is called in a cmd.exe window by hand then it works.

      But when the powershell script is run as an external command as part of a BLPackage the SQLServer setup.exe complains about SVCUser password.

      The agent and the user I run the script by hand is the same. (BBSA Server Automation Principal == my Interactive Login User)


      The command as shown in the bldeploy log is:


      12/06/11 19:22:38.195 INFO     bldeploy - [6][Run Install Script] Executing command: "powershell C:\AO\BBSA\SQL_Server\installSqlServerSingleInstance.ps1 'testInstanceName' 'BMCTESTDOMAIN\svc.sql' 'P@ss...'  'BMCTESTDOMAIN\svc.sql' 'P@ss...' 'P@ss...' 'D:\SQL Server' 'D:\SQL Server'  'L:\SQL Server\MSSQL10_50.testInstance\MSSQL\Logs' 'L:\SQL Server\MSSQL10_50.testInstance\MSSQL\Logs' 'BMCTESTDOMAIN\domain admins,BMCTESTDOMAIN\svc.sql'"


      the script is:



      $adminAccounts = $SQLSYSADMINACCOUNTS.split(",")
      foreach ($account in $adminAccounts)
      $adminAccountsParam="$adminAccountsParam`"$account`" "


      $allArgs = @("/q",



      "$allArgs"  | out-File -filepath "c:\installSqlServerSingleInstaceArgs.txt"
      [Diagnostics.Process]::Start('C:\SQL Files\Setup.exe', "$allArgs")




      The parameters passed to the setup.exe are dumped to a file. Comparing the BBSA triggered dump to the cmd.exe triggered dump shows they are the same. Example:


      powershell C:\AO\BBSA\SQL_Server\installSqlServerSingleInstance.ps1 'testInstanceName' 'BMCTESTDOMAIN\svc.sql' 'P@ssw0rd01'  'BMCTESTDOMAIN\svc.sql' 'P@ssw0rd01' 'P@ssw0rd01' 'D:\SQL Server' 'D:\SQL Server'  'L:\SQL Server\MSSQL10_50.testInstance\MSSQL\Logs' 'L:\SQL Server\MSSQL10_50.testInstance\MSSQL\Logs' 'BMCTESTDOMAIN\domain admins,BMCTESTDOMAIN\svc.sql'



      So I was hoping someone would know the environmental/paramter bashing gotcha I'm falling foul of?

      Otherwise, is there a better way to go about this?





      made it clear the script is run from a BLPAckage.  Added parmeter dump example

        • 1. Installing SQLServer via PowerShell

          This problem is todo with BBSA and the Windows environment, but I am not exactly sure why.


          I managed to get it to work by getting BBSA to write the powershell command to a temp .cmd file instead of running it rfom withing the deploy job (a BLPackage)

          Then AO uses the WindowsCommandLine adapter to call the .cmd file. 


          Trying to invoke the powershell commandremotely using the AO Windows PowerShell adapter failed for a command line truncation issue in the the AO adapter. (some kind of 200 char limit)


          So... what could the environment/BBSA issue be?   Even though BBSA is using Automation Principal to run as a Domain User could Windows GPO/ACL/other issues preveting this ?


          Anyone got any idea ?




          • 2. Installing SQLServer via PowerShell
            Bill Robinson

            do you need to use powershell?  i believe this works just find as custom software or a blpackage.  you may need to run the install using an Automation Principal if you need to run the services as a domain user, but you should be able to do this all w/o powershell.