Using the powershell app deployment toolkit I am trying to write a script to push a Windows update (MSU).
This is what I have, but it does not seem to work?
Execute-Process -Path 'Windows6.1-KB3033929-x64.msu' -Parameters "/quiet"
Msu-files are installed using wusa.exe. Try:
$PathToMsu="$PSScriprRoot\somefile.msu" Execute-Process -Path 'wusa.exe' -Parameters "`"$PathToMsu`" /quiet /norestart"
You might also consider using Install-MSUpdates from the toolkit which does this for you for every file in a directory.
Related
I am trying to create an intunewin file to update dell command update on all computers (via MS endpoint manager).
Dell CU will not install itself, if the older version of the app is present on the pc. Or rather it will install, but it won't run.
Solution - To create a powershell script, that first uninstalls the older versions of dell CU, and only then installs the newest one.
The code:
Remove-Item -Path "C:\Program Files\Dell\CommandUpdate" -Recurse -Force -EA SilentlyContinue -Verbose
Remove-Item -Path "C:\Program Files (x86)\Dell\CommandUpdate" -Recurse -Force -EA SilentlyContinue -Verbose
./Dell-Command-Update-Windows-Universal-Application_601KT_WIN_4.5.0_A00_01.EXE
This works just fine, when run like this on my computer. Actually I run the cmd script:
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File .\script.ps1
Where script.ps1 is the first script above.
So I have 3 files in the folder - the ps1 script, the cmd command, and the EXE file itself. From these 3 I create the intunewin file.
When pushed via intune, the app does not install itself. I can see 'downloading' notification, but never receive installation notification, neither successful nor failed one.
Can this be related to intune settings itself? The detection method and install command are most likely correct and were working before, when I was just using the exe file for intunewin creation.
I have to change this, because Dell CU won't install itself if the older version is there - as mentioned in the first sentence.
I assume this might be related to the powershell code. Maybe intune does not understand
./Dell-Command-Update-Windows-Universal-Application_601KT_WIN_4.5.0_A00_01.EXE
anymore, when it is given intunewin file instead?
If that's the case, how can I modify my script to 'make sense in intune'?
Thank you in advance for all the advices
I need help with powershell script I need create script for deployment for many workstations which I push to the machines via deployment tool. I need uninstall app AzInfoProtection.exe the problem is that the path for this SW is different for each computer. So I don´t know I need find path by the executable file and after this create the command to uninstall it.
app name: AzInfoProtection.exe
Path somewhere: C:\ProgramData\Package
Cache**\
I found this but I don´t know how can I get from the output the path
Get-ChildItem -Path "C:\ProgramData\Package Cache" -Filter AzInfoProtection.exe -Recurse -ErrorAction SilentlyContinue -Force
So I need script that will uninstall this SW on many computer and the command for uninstalltion should be:
"C:\ProgramData\Package Cache{ca644579-3d97-4c24-8bf0-a4ccd297b6a6}\AzInfoProtection.exe" /uninstall /quiet
this part is fro each computer different {ca644579-3d97-4c24-8bf0-a4ccd297b6a6} so I need script which find it.
I will be glad if you help me,
thanks
I am trying to create a SCCM package for installing/uninstalling VS Code on Windows. I am able to install without any problems, but I cannot get it to uninstall.
Here is what I have tried:
For reference, VSCodeSetup-x64-1.28.0.exe is the executable I used for installing vs code.
From Powershell:
Start-Process -FilePath .\VSCodeSetup-x64-1.28.0.exe -ArgumentList "/uninstall" -Wait -PassThru (This just executes the installer with no options to uninstall)
Start-Process -FilePath "C:\Program Files\Microso
ft VS Code\Code.exe" -ArgumentList "/uninstall" -Wait -PassThru (This just opens VS Code)
I looked at the following site for command line options, but no mention of uninstall.
http://jrsoftware.org/ishelp/index.php?topic=setupcmdline
Looking at the uninstall string in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ (For me it was {F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1 but this could be version dependent) it seems like there is a REG_SZ QuietUninstallString which in my case pointed to:
"C:\Program Files\Microsoft VS Code\unins000.exe" /SILENT
So you could either if those are all default instalations just hard code that path (relative to where you installed it so possibly program files (x86) or some other path) or read the string before uninstall in some script and use it directly (might also be affected by WoW64 I only did a quick test on a 32bit system)
I am still learning PowerShell and the Windows run line seems to make it even harder
Question: How can I do this directly from the run line (if possible an admin powershell) but I can deal with clicking yes after the the download... it just slows down the process
wget 'https://MYSERVER/MYFILE.MSI' -O PROGRAM.msi; start PROGRAM.msi /qn
This works great when powershell is already open as admin, also works when powershell is open as normal user, but I have to wait for the program to be downloaded to click yes instead of clicking yes to the admin powershell and let the rest autoinstall.
I tried
Powershell -Command 'wget...
but not working
Point of note: wget in PoSH is an alias
Get-Alias -Name wget
CommandType Name
Alias wget -> Invoke-WebRequest
... and with the way you are doing this, you are using wget.exe, not the above.
So, you can use wget.exe, but you have to specify the full UNC to wget.exe if it is not in your system path. That .exe is a must.
Or you need to remove the aliases
Remove-Item Alias:WGet
To download files from the web, look at the Invoke-WebRequest examples
Get-Help -Name 'Invoke-WebRequest' -Examples
Or write your own function using .Net, someting like the below and put it in your PoSH user profile
Function New-ToolDownloadInstall ($url)
{
# Set the webclient
$webclient = New-Object System.Net.WebClient
# Extract the filename from the URL and Download
$filename = [System.IO.Path]::GetFileName($url)
$file = "$env:USERPROFILE\Downloads\$filename"
$webclient.DownloadFile($url,$file)
# Remove the web ADS
Unblock-File -Path $file
# Install the file
Start-Process $file -NoNewWindow -wait
}
# Use the function
New-ToolDownloadInstall -url 'https://download.microsoft.com/download/5/0/1/5017D39B-8E29-48C8-91A8-8D0E4968E6D4/en/msoidcli_64.msi'
Here is another example
Download files from websites programatically via powershell
https://gallery.technet.microsoft.com/scriptcenter/files-from-websites-4a181ff3
Also, some DOS level command have to be called this way, if you are in the PowerSHell_ISE.exe.
Start-Process "$PSHOME\powershell.exe" -ArgumentList "-NoExit","-Command &{ wget.exe 'https://MYSERVER/MYFILE.MSI' -O PROGRAM.msi; start PROGRAM.msi /qn }"
See more details here:
https://blogs.technet.microsoft.com/josebda/2012/03/03/using-windows-powershell-to-run-old-command-line-tools-and-their-weirdest-parameters
We package our software to MSI files (using Wix).
We use VSTS for Builds and Releases.
Is there a standard way to deploy MSI file as part of the Release?
Yes, I can run msiexec /i ... as PowerShell or batch script. But we would need a few other things, for example checking exit code, uploading install log file back to VSTS Release or analysing error message, etc.
This all sounds like quite common thing people would like to do, but there is no such standard VSTS step \ extension for this.
I ended up packaging VSTS extension for this:
https://marketplace.visualstudio.com/items?itemName=ivanboyko.vsts-deploy-MSI
Source code is open-sourced:
https://github.com/IvanBoyko/vsts-install-MSI.git
You can specify log file in msiexec command to install MSI file, then check the detail log content (whether contains errors) by using PowerShell, if there are errors in the log, you can log error or warning by using ##vso[task.logissue].
Regarding upload log file, you can use ##vso[build.uploadlog]local file path to upload installer log file.
More information about logging commands, you can refer to this article: Logging Commands.
Simple code to install MSI and wait for the installer to finish:
$filePath='[msi file path]'
$DataStamp = get-date -Format yyyyMMddTHHmmss
$logFile = 'c:\{0}-{1}.log' -f 'nodejsInstall',$DataStamp
$MSIArguments = #(
"/i"
('"{0}"' -f $filePath)
"/qn"
"/norestart"
"/L*v"
$logFile
)
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow