Launch installer with Powershell, permissions problem


  • I'm launching an installer on a remote machine using powershell with a remote runspace:

    some code hidden but you get the jist...

    I create my PSCredential in C#:

    PSCredential pwd = new PSCredential(cred.UserName,PowerShellEngine.GenerateSecurePassword(cred.Password));
    ConnectionInfo = new WSManConnectionInfo(
    false, cred.HostName, 5985, "/wsman","",pwd);
    ConnectionInfo.AuthenticationMechanism = AuthenticationMechanism.Default;

    Create the runspace, and execute the script

                //Load the script
                string script = System.IO.File.ReadAllText(scriptFileName);

                using (Runspace runspace = CreateRunSpace())
                    Pipeline pipeline = runspace.CreatePipeline();

                    if (parameters != null)
                        foreach (KeyValuePair<string, string> parm in parameters)
                            pipeline.Commands[0].Parameters.Add(parm.Key, parm.Value);

    Script.... (the part that matters)

    $installStatement = [System.Diagnostics.Process]::Start( $App, $Switches )
    "Process Exit Code: $LastExitCode"

    The process start fine.. end up with:

    MSI (s) (3C:18) [21:06:18:923]: Product: xxxx -- Error 1920.Service xxxx failed to start.  Verify that you have sufficient privileges to start system services.

    I've verified the process runs as the local administrator which works fine from the command prompt is using PSExec.  I assume this must have to do with WSMAN permissions or security wrapped around the runspace itself ?

    Is there a policy or something that needs to be set to allow a powershell runspace to be able to start services in an installer?

    Thanks, Gavin

    Thursday, September 30, 2010 4:38 AM

All replies

  • Appears WinRM runs under the NETWORK SERVICE account which probably doesn't have permission to start/stop windows services...

    I can't change Windows Remote Management to run as Local System because other services (HTTP, RPCSS) are dependent on it and are apparently running under the same process)

    Is there a way to grant NETWORK Service the ability to start/stop services ?

    Thursday, September 30, 2010 7:58 PM