0

I have an update script for running the Dell Command Update tool. In short dcu-cli.exe. The thing now is than when i run the same script code on the computer local then everything runs OK but when i run the exact same code in a script with invoke-command(and yes i have full admin rights) than the exitcode is 2 meaning An unknown application error has occurred instead of 0 (everything OK)

It is a very large script so i created a new one to debug this. This is the shorted code:

Invoke-Command -ComputerName "MyComputer" -ScriptBlock {    
    $ExitCode = 0             

    #Declare path and arguments
    $DcuCliPath = 'C:\Program Files (x86)\Dell\CommandUpdate\dcu-cli.exe'                              
    $DellCommand = "/applyUpdates -autoSuspendBitLocker=enable -outputLog=C:\Dell_Update.log"
                
    #Verify Dell Command | Update exists
    If (Test-Path -Path $DcuCliPath) {
        $objWMI = Get-WmiObject Win32_ComputerSystem
        Write-Host ("Dell Model [{0}]" -f $objWMI.Model.Trim())

        $serviceName = "DellClientManagementService"
        Write-Host ("Service [{0}] is currently [{1}]" -f $serviceName, (Get-Service $serviceName).Status)
        If ((Get-Service $serviceName).Status -eq 'Stopped') {    
            Start-Service $serviceName
            Write-Host "Service [$serviceName] started"    
        }

        #Update the system with the latest drivers
        Write-Host "Starting Dell Command | Update tool with arguments [$DellCommand] dcu-cli found at [$DcuCliPath]"
        $ExitCode = (Start-Process -FilePath ($DcuCliPath) -ArgumentList ($DellCommand) -PassThru -Wait).ExitCode
        Write-Host ("Dell Command | Update tool finished with ExitCode: [$ExitCode] current Win32 ExitCode: [$LastExitCode] Check log for more information: C:\Dell_Update.log")
    }
}

When i remove the Invoke-Command -ComputerName "MyComputer" -ScriptBlock { and then copy + run the script local on the PC then the exitcode = 0

What i also noticed than when i run the command via 'Invoke-Command' then there is also no log file created as i passed along in the arguments... So my best guess is something is going wrong with local an remote paths?

So what am i missing? I'm guessing it is something simple but i spend several hours to get this running without any luck...

5
  • I used your exact code except the path for the tool was program files and the log i put in c:\temp. It worked perfectly. It even updated network driver and lost connection, restored connection, and still exited with exitcode 0. Commented Dec 28, 2020 at 15:14
  • What's the error message from dcu-cli? Using start-process makes it harder. It's also going to try to pop up a new window. Commented Dec 28, 2020 at 15:37
  • Thanks for testing. Frustrating it works for you. ;-) I adjusted it also to C:\Temp but no difference. What version of dcu-cli are you running *(except for the x64 part) @js2010 the error message i get is ExitCode 2 meaning there was an application error Commented Dec 28, 2020 at 15:37
  • I mean error message as in text. I would try running it without start-process. Otherwise you can't see the output. Commented Dec 28, 2020 at 15:40
  • Than it opens a new window of the dcu-clie and quickly closes. However i tried running the same script on another PC and that seems to run fine... Wil debug this some more tomorrow. Here is the full error list dell.com/support/manuals/nl-nl/command-update-v3.1/… Commented Dec 28, 2020 at 15:43

2 Answers 2

1

Try running it this way. You should be able to see any output or error messages. I typically add to the path first rather than using & or start-process.

invoke-command mycomputer { 
$env:path += ';C:\Program Files (x86)\Dell\CommandUpdate'; 
dcu-cli /applyUpdates -autoSuspendBitLocker=enable -outputLog=C:\Dell_Update.log }

Using start-process inside invoke-command seems pretty challenging. I can't even see the output of findstr unless I save it to a file. And if I didn't wait the output would be truncated. By default start-process runs in the background and in another window. There's a -nonewwindow option too but it doesn't help with invoke-command.

invoke-command localhost { # elevated
start-process 'findstr' '/i word c:\users\joe\file1' -wait -RedirectStandardOutput c:\users\joe\out } 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your invoke tip. This way you indeed get feedback from the dcu-cli tool which is very helpful. And i also noticed that the exitcode is now also in $LastExitCode. Just a quick question. When this is part of a large script do you have to restore the $env:path to the default when done so other commands in the script will execute OK?
No, the rest of the path is still there.
0

@js2010, thanks for your additional help. Unfortunately this didn't helped either.

So i did some more debugging and it turns out it was a bug in the dcu-cli version running on my test machine, DOH...!!

On the test machine version 3.1.1 was running and on another machine version 4.0 was running and that worked fine via remote Powershell. So i looked for the release notes, which i found here: https://www.dell.com/support/kbdoc/000177325/dell-command-update

And as you can see in version 3.1.3 there was this fix:

A problem was solved where dcu-cli.exe was not executed in an external interactive session of PowerShell.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.