Running Command in Powershell

We are having issues with SCCM clients, so we are uninstalling them and re-installing them. When I run ccmsetup.exe /uninstall it returns errors sometimes. Running msiexec /x client.msi seems to work better (not sure why). I created a script so to run, but when i have it run the “msiexec /x client.msi” it errors out with the “Start-Process” command.

Start-Process msiexec /x client.msi -workingDirectory "c:\windows\system32\ccmsetup…

so i tried to an Invoke-Expression after reading that powershell has issues sometimes with running cmd commands.

$a = @’
cmd.exe C/ c:\windows\system32\ccmsetup\msiexec /x client.msi

I can get it to run using start process if i just use “msiexec /x” , but it doesn’t full run and errors out without “client.msi” being called.

I appreciate any help

It will probably work if you add quotation marks around the argument string that should be passed to msiexec:

Start-Process msiexec '/x client.msi' -WorkingDirectory 'c:\windows\system32\ccmsetup...'

If you did that without using positional parameters, it would look like this:

Start-Process -FilePath msiexec -ArgumentList '/x client.msi' -WorkingDirectory 'c:\windows\system32\ccmsetup...'

I can’t test this exact command without having something handy to do with Windows Installer at the moment, but this example works fine for me:

Start-Process -FilePath $env:ComSpec -ArgumentList '/k echo Hello, World!' -WorkingDirectory $env:SystemRoot

Worked perfectly. I thought i wrote it out similar to that, but I used double quotes. If i did I wonder if the double quotes was causing an issue. Have to read more on the differences with double quotes and single.

Thank you