Permission Issue - Invoke Command

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Will Anderson Will Anderson 2 years, 2 months ago.

  • Author
    Posts
  • #25181
    Profile photo of ##Nick
    ##Nick
    Participant

    Summary:
    The code below is being run from my machine, targeting a computer 'mbsqlclx001'.
    The code runs [b]without[/b] producing an error.
    I can even see the process start on the remote machines task manager.

    Issue:
    The PowerShell script runs all the way through however:
    Once it runs the Start-Process it then pauses approx 5 seconds before exiting to the prompt.
    The task manager on the target machine [b]shows the process[/b] but it too disappears after 5 seconds.

    Thoughts:
    Security? Permissions? UAC?

    Code (Image below also):

    #Create a variable
    $sqlversion = '2012-dev-x64'
    #Create a persistent session
    $session = New-PSSession -ComputerName mbsqlclx001
    #Use Invoke-Command to launch setup.exe
    Invoke-Command -Session $session {      
    if (Test-Path -path 'hklm:\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQLServer\CurrentVersion\') 
        {
            Write-Host "`n SQL Server is already installed, exiting script." -BackgroundColor "Yellow" -ForegroundColor "Black"
        }
    Else
        {
            Start-Process "c:\_installs\$using:sqlversion\setup.exe" -ArgumentList "/ConfigurationFile=c:\_installs\$using:sqlversion\configurationfile.ini" -Wait
        }
        }
    
  • #25186
    Profile photo of Will Anderson
    Will Anderson
    Keymaster

    I don't think the process stopping is attributable to the script. The script sounds like it's doing what it should be if the process is starting, but something else could be terminating it. Are you getting any errors in the event logs? What happens if you attempt to start the service manually? You could also throw a verbose parameter in there to see what it says.

  • #25202
    Profile photo of ##Nick
    ##Nick
    Participant

    Will,

    Thank you for responding.
    When I start the setup.exe directly UAC pops up.
    It is the UAC window I'm afraid is cancelling the process.
    I will check the event logs.

    Any suggestions on handling the UAC?

  • #25208
    Profile photo of ##Nick
    ##Nick
    Participant

    SOLVED
    Just to document my findings, I was able to determine the reason installation was failing.
    I ran the installation on the target machine directly using Windows command prompt.
    While my PowerShell script wasn't producing errors, the errors were visible in the Windows command prompt.
    My argument list (used with my setup.exe) pointed to a configurationfile that had an incompatible set of switches used which caused the cancelled installation.

    Thank you Will for pointing me in the right direction, very often its the direction received that helps find the solution.

  • #25209
    Profile photo of Will Anderson
    Will Anderson
    Keymaster

    Hey there Nick,

    I'm glad you were able to root out the problem! I'm always glad to give a nudge when needed. 🙂

You must be logged in to reply to this topic.