Download and Install CCleaner using PowerShell - powershell

I tried this below command line to download and install CCleaner using PowerShell. But I got errors, it was a guess try, and I would appreciate if you could modify to a working command.
powershell.exe -Command "$Path = $env:TEMP; $Installer = 'ccsetup578.exe'; Invoke-WebRequest 'https://www.ccleaner.com/ccleaner/download/standard' -OutFile $Path$Installer; Start-Process -FilePath $Path$Installer -Args '/silent /install' -Verb RunAs -Wait; Remove-Item $Path$Installer"

"https://www.ccleaner.com/ccleaner/download/standard" - .html, not .exe
need
Invoke-WebRequest -Uri "https://download.ccleaner.com/ccsetup578.exe" -OutFile "$env:Temp\ccsetup578.exe"
P.S. Ccleaner - placebo
Use C:\Windows\System32\cleanmgr.exe /LOWDisk

Related

powershell for quicken update

trying to patch quicken with this script i think im missing a silent install command any suggestions would be great
$Path = $env:TEMP; $Installer = "Greenshot-INSTALLER-1.2.10.6-RELEASE.exe"; Invoke-WebRequest "https://assistant.quicken.com/patch/QW27.1.47.11MPatch.EXE" -OutFile $Path$Installer; Start-Process -FilePath $Path$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path$Installer
when I run the script it fails (exceeding the timeout for completion I'm deploying it from PDQ inventory with admin credentials)

Error occurred on PowerShell that downloads and installs Google Chrome on Windows Server 2016

This is actual code I tried. Please find the screenshot of the error here https://i.stack.imgur.com/yMWeQ.png
#echo off
powershell.exe -Command $Path = $env:TEMP; $Installer = "chrome_installer.exe"; Invoke-WebRequest "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $Path$Installer; Start-Process -FilePath $Path$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path$Installer
enter image description here
Posting an answer because the code looks horrible in a comment:
Double quote the entire string after -Command, this is the entire command sent to powershell then single quote the internals (which in the original had double quotes).
powershell.exe -Command "$Path = $env:TEMP; $Installer = 'chrome_installer.exe'; Invoke-WebRequest 'https://dl.google.com/chrome/install/latest/chrome_installer.exe' -OutFile $Path$Installer; Start-Process -FilePath $Path$Installer -Args '/silent /install' -Verb RunAs -Wait; Remove-Item $Path$Installer"

Powershell installing msi

I am using docker with powershell. I want to download and install webdeploy .msi
I am using the following code:
RUN Invoke-WebRequest http://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_x86_en-US.msi -OutFile webdeploy.msi; \
Start-Process msiexec -Wait -ArgumentList /q, /i, -PassThru, webdeploy.msi ; \
Remove-Item -Force webdeploy.msi
When I run:
docker build -t test.
Everything goes fine.
When I then check the folder "Program Files (x86)" inside the container I dont see any folder "IIS".
I also tried:
RUN Invoke-WebRequest http://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_x86_en-US.msi -OutFile webdeploy.msi; \
Start-Process msiexec -Wait -ArgumentList /q, /i, webdeploy.msi ; \
Remove-Item -Force webdeploy.msi
Some help would be appreciated.

using logfile when installing .exe with powershell

When I want to install an .msi file with powershell and want to use logging I use the following code:
RUN Invoke-WebRequest http://download.microsoft.com/download/0/1/D/01DC28EA-638C-4A22-A57B-4CEF97755C6C/WebDeploy_amd64_en-US.msi -OutFile webdeploy.msi; \
Start-Process msiexec -Wait -ArgumentList '/i webdeploy.msi /l*v C:\msilog.txt /q' ; \
Remove-Item -Force webdeploy.msi
I searched on google how to do this for an .exe file but cannot find a solution.
So my question how do I add a log file for the following function in powerhsell:
RUN Invoke-WebRequest -UseBasicParsing
https://download.microsoft.com/download/5/B/C/5BC5DBB3-652D-4DCE-B14A-
475AB85EEF6E/vcredist_x86.exe -OutFile vcredist_x86.exe; \
powershell.exe -Command Start-Process vcredist_x86.exe -ArgumentList '/quiet'
| Wait-Process
RUN Invoke-WebRequest -UseBasicParsing
https://download.microsoft.com/download/9/1/4/914851c6-9141-443b-bdb4-
8bad3a57bea9/vcredist_x64.exe -OutFile vcredist_x86.exe; \
powershell.exe -Command Start-Process vcredist_x86.exe -ArgumentList '/quiet'
| Wait-Process

Powershell script to install Azure Service Fabric SDK, runtime and tools silently

I'm trying to write a script to download an install Azure Service Fabric SDK, runtime and tools into a few servers.
My issue is that the installer provided here is a Web Installer, and does not support silent mode.
I found a guy that solved this issue here. His code:
# Install Service Fabric Runtime
Invoke-WebRequest "http://download.microsoft.com/download/3/2/1/3217654F-6882-4CEA-BD51-49287EDECE9B/MicrosoftServiceFabric.6.0.232.9494.exe" -OutFile "C:\ServiceFabricRuntime.exe" -UseBasicParsing; \
Start-Process "C:\ServiceFabricRuntime.exe" -ArgumentList '/AcceptEULA', '/QUIET' -NoNewWindow -Wait; \
rm "C:\ServiceFabricRuntime.exe"
# Install Service Fabric SDK
Invoke-WebRequest "http://download.microsoft.com/download/3/2/1/3217654F-6882-4CEA-BD51-49287EDECE9B/MicrosoftServiceFabricSDK.2.8.232.msi" -OutFile "C:\ServiceFabricSDK.msi" -UseBasicParsing; \
Start-Process "msiexec" -ArgumentList '/i', 'C:\ServiceFabricSDK.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -Wait; \
rm "C:\ServiceFabricSDK.msi"
As you can see, he's using direct links to the .msi installers (as well as other guys are doing in other threads like these two answers.).
So my questions is, how do i get a direct link to the msi with the latest version of these installers?
And the follow up question would be, is there a universal link that will automatically download the latest version of these tools?
Thanks in advance.
I know this is not exactly what you asked for but you can use Web Platform Installer Command Line to install WebPI products silently. The idea is to download WebPICMD and run installation of Service Fabric SDK from the cmd line. The powershell script can look like this:
Invoke-WebRequest "https://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi" -OutFile "C:\WebPlatformInstaller.msi" -UseBasicParsing;
Start-Process "msiexec" -ArgumentList '/i', 'C:\WebPlatformInstaller.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -Wait;
rm "C:\WebPlatformInstaller.msi"
WebPICMD.exe /Install /Products:MicrosoftAzure-ServiceFabric-CoreSDK /AcceptEULA
Product MicrosoftAzure-ServiceFabric-CoreSDK will install latest version of Service Fabric SDK and Service Fabric Runtime silently.
If you want to install something different from the WebPI run :
WebPICMD.exe /List /ListOption:All
This command will list all of the available products, just grab the id of the product and run install command.
More about WebPICMD here.
To add on the answer above, if WebPlatformCMD gives you Windows' UAC consent window issues, you can use PSEXEC tools to run the installer as system account, avoiding that problem.
Example code:
Invoke-WebRequest "https://go.microsoft.com/fwlink/?LinkId=287166" -OutFile "$env:temp\WebPlatformInstaller_amd64_en-US.msi" -UseBasicParsing
Start-Process "msiexec" -ArgumentList "/i $env:temp\WebPlatformInstaller_amd64_en-US.msi /passive /quiet /norestart /qn" -NoNewWindow -Wait
$psToolsPath = "$env:temp\pstools"
New-Item $psToolsPath -ItemType directory -force -erroraction silentlycontinue
Invoke-WebRequest -Uri https://download.sysinternals.com/files/PSTools.zip -OutFile $psToolsPath\PSTools.zip
Expand-Archive "$psToolsPath\PSTools.zip" $psToolsPath -force
cd $psToolsPath
Start-Process psexec64 -ArgumentList "-s /accepteula WebPICMD.exe /Install /Products:MicrosoftAzure-ServiceFabric-CoreSDK /AcceptEULA"
Small note on SteppingRazor's answer above.
You can ease out the ArgumentList Parameter value like this:
Start-Process "msiexec" -ArgumentList "/i C:\WebPlatformInstaller.msi /passive /quiet /norestart /qn -NoNewWindow -Wait
Instead of
Start-Process "msiexec" -ArgumentList '/i', 'C:\WebPlatformInstaller.msi', '/passive', '/quiet', '/norestart', '/qn' -NoNewWindow -Wait;
Then using variables in the string is also easier.