WUSA.exe not working while installing update? - powershell

i am using powershell to install windows update on a machine. I am using below command line to achieve so.
wusa.exe "file_path" \norestart \quiet
The update is not getting installed and throwing an error:
Windows update could not be installed because of error 2147942487 "The parameter is incorrect." (Command line: ""C:\windows\system32\wusa.exe" d:\riteshthakur\abc.msu \quiet \norestart")
AM i doing something wrong here ?

You need to use a forward slash for your parameters in Windows, typically:
wusa.exe "file_path" /norestart /quiet
Additionally, if you're having problems, try using the log parameter to see what's going on:
wusa.exe "file_path" /norestart /quiet /log:C:\wusa.log

Related

msiexec Powershell silent install

I am searching for a Powershell Script which allows me to silent install a msi file.
We have over 25000 PCs so i have to do that with a script.
Unfortunately at the moment a window popping up (Windows Installer) after the execution which shows the parameter of a msi file. Nothing more, no other "error messages" are popping up.
The first thing the Script should do is to check if the PC is a Desktop or Mobile Device.
If its a Desktop device he should write in a file "Desktop Configuration was used".
In the same time the msi installer should start with some parameter.
If its a Laptop the procedure should be nearly the same.
After the installation is successful the user should be signed out.
I need this script to implement 2FA in our company.
The code at the moment looks like this:
IF ( ((Get-ComputerInfo | select -expand CsPCSystemType) -LIKE "Desktop") )
{
Write-Output "Desktop Configuration was used." >> \\XXX\XXX\XXX\XXX\Log\$env:Computername.txt
msiexec.exe /i "%~dp0setup.msi" /passive /norestart /L*v "%~dp0setup.log"
}
ELSE {
Write-Output "Laptop Configuration was used." >> \\XXX.XXX.XX\X\XX\XXX\XXXX\$env:Computername.txt
msiexec.exe /i "%~dp0setup.msi" /passive /norestart /L*v "%~dp0setup.log"
}
Write-Output "Lock Configuration was used." >> \\XXX\XXX\XXX\XXX\Log\$env:Computername.txt
rundll32.exe user32.dll,LockWorkStation
Any help is really appreciated.
The token %~dp0 (which resolves to the directory where the current script resides in) only works in batch scripts.
In PowerShell, replace $~dp0 by $PSScriptRoot. That should solve the problem of msiexec showing up with the available command-line options.
Another problem of your script is that msiexec runs asynchronously, when called directly as a command. So your script will be finished while the installation is still running, which is propably not what you want. This is caused by msiexec.exe being a GUI application. To run GUI applications synchronously, use Start-Process -Wait.
$Arguments = "/i", "`"$PSScriptRoot\setup.msi`"", "/passive", "/norestart", "/L*v", "`"$PSScriptRoot\setup.log`""
$msiProcess = Start-Process msiexec.exe -Wait -ArgumentList $Arguments -PassThru
# Check if installation was successful
# 0 = ERROR_SUCCESS, 3010 = ERROR_SUCCESS_REBOOT_REQUIRED
if( $msiProcess.ExitCode -in 0, 3010 ) {
Write-Host "Installation succeeded with exit code $($msiProcess.ExitCode)"
}
Try passing silent switches (/qn! or /qb!) instead of /passive flag.

Silent Install MS Visio Viewer is working but not the Silent Uninstall using command line

I Tried to do the the silent install of MS Visio Viewer in my Sandbox and it Work
here is the code
visioviewer_4339-1001_x64_en-us.exe /quiet /norestart
and it work via command line.
However, when I tried the silent uninstall in the command line, the code wont work and the MS Visio wont be uninstalled.
Here is the code I Use.
MsiExec.exe /x visioviewer_4339-1001_x64_en-us.exe /qn
I hope someone could help me.
Thank you
I have found this:
MsiExec.exe /x {95160000-0052-0409-0000-0000000FF1CE} /qn
Obvious.
try using this command:
start /wait msiexec.exe /x{95140000-0052-0409-0000-0000000FF1CE} /qn /noreboot
I hope this will help you

How to install MS ODBC driver using PowerShell

I've written a script that downloads the MS ODBC driver, installs it, then checks the new driver .dll exists. However, I'm stuck on the "installs it" part.
The best version of the install command I have right now is: Start-Process -Filepath "msiexec.exe" -ArgumentList "/i msodbcsql.msi", "/qb", "IACCEPTMSODBCSQLLICENSETERMS=YES"
When I run this on its own (to troubleshoot it), however, the installer launches and immediately displays the error:
The required IACCEPTMSODBCSQLLICENSETERMS=YES command-line parameter is missing.
If I run Start-Process -Filepath msiexec -ArgumentList /i, "msodbcsql.msi" the regular GUI installer starts up which presumably means the "/qb", "IACCEPTMSODBCSQLLICENSETERMS=YES" part of the command is the problem.
I'm having no luck with this in spite of adapting every example I can find on the web. I'd be grateful for help!
The problem: I wasn't running PowerShell in Administrator mode 😖

Powershell - run .MSI installation with arguments but Windows Installer pops up and nothing happens

I am using Powershell 7 to install .MSI application with some arguments (same installation with same arguments passed well when using for example Ansible tool).
Every time I try to run script I am getting Windows Installer pop up window which someone mentioned ( someone wrote "This pop up is the msiexec help pop up. It’s telling you it doesn’t like your command line"). I tried several different orders but always getting this failure.
I saw there was similar issue but it was completely different issue with Accepting License Terms, I do not have issue with that.
My arguments are:
$webDeployInstallerFilePath = "C:\fa_components\PRIME\SUN TEST 2020.1 (x64).msi"
$switch2 = #(
"i `"$webDeployInstallerFilePath`""
"/quiet"
"passive"
"/l* C:\tmp_installation\logs\Prime_log.txt"
"INSTALLDIR=C:\"
"FRONTINIDIR=C:\ProgramData\Front\64bit\ini\"
"FRONTINILOG=C:\ProgramData\Front\64bit\log\"
"PRIME=C:\TEST Arena\"
"ProgramMenuFolder=C:\ProgramData\"
"COMMONAPPDATA_FRONTDIR=C:\ProgramData\Front\"
"COMMONAPPDATA_FRONT64BITDIR=C:\ProgramData\Front\64bit\"
"CommonAppDataFolder=C:\ProgramData\"
)
Program requires some of it needed argumets.
I try to execute it with:
Start-Process msiexec.exe -ArgumentList $switch2 -Wait
I try to run my .ps1 script but as I mentioned I am getting only picture with windows installer and nothing happens (you can see that on following link)
windows installer picture
Thanks in advance!
Yes, a few problems.
"i" should be "/i" (note the forward slash)
"passive" should be "/passive" (note the forward slash)
Because it has a space in the path, "PRIME=C:\TEST Arena\" should be "PRIME="C:\TEST Arena\""
Examples here: https://www.alkanesolutions.co.uk/2018/07/18/install-and-uninstall-msi-using-powershell/
$switch2 = #(
"/i `"$webDeployInstallerFilePath`""
"/quiet"
"/passive"
"/l* C:\tmp_installation\logs\Prime_log.txt"
"INSTALLDIR=C:\"
"FRONTINIDIR=C:\ProgramData\Front\64bit\ini\"
"FRONTINILOG=C:\ProgramData\Front\64bit\log\"
"PRIME=`"C:\TEST Arena\`""
"ProgramMenuFolder=C:\ProgramData\"
"COMMONAPPDATA_FRONTDIR=C:\ProgramData\Front\"
"COMMONAPPDATA_FRONT64BITDIR=C:\ProgramData\Front\64bit\"
"CommonAppDataFolder=C:\ProgramData\"
)

powershell silent install for ruby devkit tdm

Am trying to extract Ruby Devkit Tdm package using below command,
Start-Process "C:\DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe" -ArgumentList "-o'C:\Ruby-DevKit' -y" -PassThru -Wait
but its having 7-zip unknown error. I found in Google for NSIS script which has to perform this and below is the query,
ExecWait '"$TEMP\${devkit_installer}" x -o"${devkit_path}" -y /silent /noreboot /nocancel /noicons' $1
Is there any similar way to perform silent unzip this using powershell?
The problem is the single quotes around the folder path in your ArgumentList, Start-Process isn't passing them as you would expect. You only need them if you have a space in your path so you can just remove them in this case:
Start-Process C:\DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe -ArgumentList "-oC:\Ruby-DevKit -y" -PassThru -Wait
If you just used the call operator to run the command it works fine with single quotes, but the installer itself does not wait to finish so the script continues whilst the install is still in process.
& C:\DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe -o'C:\Ruby-DevKit' -y
So there's two ways around your issue depending on if you want the script to wait for the install or not.