Permission Issue - Invoke Command

Welcome Forums General PowerShell Q&A Permission Issue - Invoke Command

This topic contains 4 replies, has 2 voices, and was last updated by

 
Keymaster
3 years, 8 months ago.

  • Author
    Posts
  • #25181

    Participant
    Points: 1
    Rank: Member

    Summary:
    The code below is being run from my machine, targeting a computer 'mbsqlclx001'.
    The code runs without 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 shows the process 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

    Keymaster
    Points: 39
    Team Member
    Rank: Member

    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

    Participant
    Points: 1
    Rank: Member

    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

    Participant
    Points: 1
    Rank: Member

    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

    Keymaster
    Points: 39
    Team Member
    Rank: Member

    Hey there Nick,

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

The topic ‘Permission Issue - Invoke Command’ is closed to new replies.