0

Its and windows machine and trying to install Sql Server(unattended) using powershell



Write-Host "`nStarting the install of SQL Server" -ForegroundColor Green
    
[string]$userName = 'domain\username'
    
[string]$userPassword = 'xyz'
     
[securestring]$secStringPassword = ConvertTo-SecureString $userPassword -AsPlainText -Force
     
[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($userName, $secStringPassword)
   
Start-Process -Filepath "$driveLetter\setup.exe" -ArgumentList "/ConfigurationFile=`"$temp_file_location`"" -Credential $credObject -NoNewWindow -Wait -RedirectStandardOutput $standardOutputFile -RedirectStandardError $errorOutputFile 


ERROR:

PS C:\Windows\system32> C:\Users\manish\Desktop\custommain.ps1
domain
eu-west-1
fetching the password from parameter stores
Cleaning the outputfile error
finding and replacing the domains and secrets
writting the content of ini into temp file C:\xyz-softwares\ms-sql-server\scripts\batch-files\temp_ConfigurationFile.ini
Mounting SQL Server Image
Getting Disk drive of the mounted image
Starting the install of SQL Server
Start-Process : This command cannot be run due to the error: The user name or password is incorrect.
At C:\xyz-softwares\ms-sql-server\scripts\powershell\ms-sqlserver-installation.ps1:65 char:2
+     Start-Process -Filepath "$driveLetter\setup.exe" -ArgumentList "/ ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
SQL Installation Failed Installation with exit code
SQL Installation Failed Installation with exit code
At C:\xyz-softwares\ms-sql-server\scripts\powershell\ms-sqlserver-installation.ps1:72 char:9
+         throw $error_message
+         ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (SQL Installatio... with exit code:String) [], RuntimeException
    + FullyQualifiedErrorId : SQL Installation Failed Installation with exit code
PS C:\Windows\system32>

I have tried with powershell with domain credentials. Although i have exe file and windows machine is connected with domain

Tried to start process command with domain credetials.

jdweng
  • 33,250
  • 2
  • 15
  • 20
  • 1
    I really wouldn't recommend installing such a big piece of software in the user data. You should build a custom AMI. – Paolo Dec 12 '22 at 09:57
  • You seem to install _Microsoft SQL Server_, not _MySQL_. Why not use ready-made AMI from the AWS Marketplace instead? – vonPryz Dec 12 '22 at 11:28
  • Connect to Server using SQL Server Management Studio. Check if login window show Window Credential of SQL Credential. Most likely it is Windows credential and user name and password will not work. You need to change connection string to Integrated Security = True. Also check if you can do a query in database to make sure you have authorization. The server may have more than one database and you may not be using the default database. – jdweng Dec 12 '22 at 17:07
  • thanks, @Paolo, for suggesting good ideas. However, I am a newbie on PowerShell. trying to figure out where I went wrong. too much different from Linux. – Manish Mangyani Dec 12 '22 at 18:01
  • @jdweng here while installing my windows machine is already connected with the domain. and the iso/.exe is mounted as a drive. and the error shows access is denied and with credentials the above one. Thanks though...:) – Manish Mangyani Dec 12 '22 at 18:06
  • You must get working with SSMS before you try with code. The debug messages are much better using SSMS. It doesn't matter if it is on the domain. It matters if you can log in with SSMS and if the server/database allows the login. Useing SSMS you will verify the login. Also make sure the server\instance on the SSMS matches the connection string. Don't fight me. I've been doing this for a long time. Once you get into SSMS you ca check the log files while will give the reason your powershell login failed. But first you must get SSMS working. – jdweng Dec 12 '22 at 18:44

0 Answers0