Not able to invoke SQL 2016 setup.exe file using Invoke-Command in remote host (Azure VM 2019 Datacenter)

MONDALABDULKADIR-7547 25 Reputation points
2024-03-01T18:27:29.66+00:00

Hello Team,

Hope all are doing well!!

I am trying to install SQL 2016 using the below PowerShell script, however, I can see the script can invoke the setup.exe file but on the remote host background process not executing it seems. I waited for 2 hours but no response. Even the script is also not in a failed state. Can someone please help me to achieve this?

Process status attached of the remote host

Powershell Script:-

$vmPassword = "$$$$$$$$"

$vmUserName = "$$$$$$$$"

$ServerIP = "$$$$$$$$$"

$SecurePassword = $vmPassword | ConvertTo-SecureString -AsPlainText -Force

$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList ($vmUserName, $SecurePassword)

#Set trusted host file

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force

#New session

$remoteSession = New-PSSession -computerName $ServerIP -credential $Cred

$script = {

      C:\install\setup.exe

}

Invoke-Command -Session $remoteSession -ScriptBlock $script -ArgumentList ConfigurationFile.ini -Debug

I have tried to achieve the same using Ansible modules but still no luck.

In ansible I have tried with win_command , win_shell , win_package , win_ps..etc

The same issue happened "Process are running" at the background but unable to execute properly

Ansible Script:-


  • hosts: winhost tasks:
    • name: Install SQL 2016 win_command: PowerShell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File "C:\db_installation_command.ps1" become_method: runas become_user: Administrator

db_installation_command.ps1

C:\install\setup.exe '/ConfigurationFile="C:\ConfigurationFile.ini"'

Can someone please help me with this?

PSVersion 5.1.17763.5458

Windows for business Windows Server User experience PowerShell
SQL Server Other
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Greg Low 1,980 Reputation points Microsoft Regional Director
    2024-03-02T01:04:16.9666667+00:00

    The setup will be trying to run in a session that requires local UI. So it will just sit there forever and never achieve anything.

    You need to start with commands that you know will execute without any prompting. Once you get that, you should be able to remotely execute.

    One other thing, at the very least, it normally requires that you agree to the license terms. So make sure you include that option.


  2. MONDALABDULKADIR-7547 25 Reputation points
    2024-03-02T02:39:52.3033333+00:00

    Thank you @Greg Low for quick response.Here I am passing as an argument ConfigurationFile.ini file with all the parameters , which will run without any prompts , I have tested same on local host , SQL server is installed without any prompts.

    0 comments No comments

  3. MONDALABDULKADIR-7547 25 Reputation points
    2024-03-02T03:28:57.07+00:00

    I have attached the ConfigurationFile.ini , you can look into this as well. Which is working in local host without any prompting.

    COnfigurationFile.ini:-

    [OPTIONS]

    ACTION="Install"

    FEATURES=SQL

    INSTANCENAME=TEST

    SQLSVCACCOUNT="NT Authority\System"

    SQLSYSADMINACCOUNTS="*******"

    AGTSVCACCOUNT="NT Authority\System"

    ASCOLLATION= Latin1_General_CI_AS

    SECURITYMODE=SQL

    SAPWD="*******"

    ASSVCSTARTUPTYPE=Automatic

    SQLSVCSTARTUPTYPE=Automatic

    TCPENABLED=1

    SQLTEMPDBDIR="C:\DATA\"

    SQLUSERDBDIR="C:\DATA\"

    SQLUSERDBLOGDIR="C:\DATA\"


  4. ZoeHui-MSFT 41,491 Reputation points
    2024-03-04T02:30:50.6966667+00:00

    Hi @MONDALABDULKADIR-7547,

    Have you check this documentation to see if it is helpful?

    Install SQL Server with PowerShell Desired State Configuration

    Regards,

    Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

  5. Rich Matheisen 47,901 Reputation points
    2024-03-04T03:06:24.4933333+00:00

    Don't you need to pass the parameter name along with the name of config file?

    $vmPassword = "$$$$$$$$"
    $vmUserName = "$$$$$$$$"
    $ServerIP = "$$$$$$$$$"
    $SecurePassword = $vmPassword | ConvertTo-SecureString -AsPlainText -Force
    $Cred = New-Object System.Management.Automation.PSCredential -ArgumentList ($vmUserName, $SecurePassword)
    
    #Set trusted host file
    Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force
    
    #New session
    $remoteSession = New-PSSession -computerName $ServerIP -credential $Cred
    
    $config = "/ConfigurationFile=ConfigutationFile.ini"
    $script = {
          C:\install\setup.exe $Using:config
    }
    Invoke-Command -Session $remoteSession -ScriptBlock $script -Debug
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.