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

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"

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)

Download and Install CCleaner using 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

How to pass argument to Start-Process

I'd like to run this command
net start "PTV LOXANE xDataServer 1.4.1.067" using Start-Process in powershell with admin rights.
My problem is how to give the quote to ArgumentList.
I've tried this but it doesn't work
Start-Process net -ArgumentList "stop \"PTV LOXANE xDataServer 1.4.1.067\"" -Verb runas -wait -NoNewWindow -PassThru
I've found how to do it. You must double the quotes:
Start-Process net -ArgumentList "start ""PTV LOXANE xDataServer 1.4.1.067""" -wait -PassThru -Verb runas
Now I've got a second question. How can I run this command when calling powershell ?
This doesn't work:
powershell -Command 'Start-Process net -ArgumentList "start ""PTV LOXANE xDataServer 1.4.1.067""" -wait -PassThru -Verb runas'

Opening multiple powershell scripts same time for user

I am developing a SQL health check using powershell. So it checks the statuses of databases and outputs text to console whether anything needs attention. i have the first ps1 to load the various checks but i need them to start loading the below ps1's in parralel. I need to work this on powershell v2. Do i need to use start-job for each line
Here is my code
$Output = #()
$BackupHistory = #()
$script = $myInvocation.MyCommand.Definition
$scriptPath = Split-Path -parent $script
Start-Process -FilePath powershell.exe -ArgumentList "-noexit","$scriptpath\SQLHealthVLF.ps1 $Env" -Wait -WindowStyle Maximized
Start-Process -FilePath powershell.exe -ArgumentList "-noexit","$scriptpath\SQLHealthBackup.ps1 $Env" -Wait -WindowStyle Maximized
Start-Process -FilePath powershell.exe -ArgumentList "-noexit","$scriptpath\SQLHealthIOAlerts.ps1 $Env" -Wait -WindowStyle Maximized
Start-Process -FilePath powershell.exe -ArgumentList "-noexit","$scriptpath\SQLDisksUsage.ps1 $Env" -Wait -WindowStyle Maximized
What currently happens is one loads, then i need to close it and then the next one loads. This doesn't give the script consistency.

Can't start PowerShell script file with credentials of other user

I have a GUI that has been created with PowerShell Studio and exported as a PS1-file. I'm now trying to launch this GUI by calling it with another user's credentials.
When I run the code it doesn't even give an error message. PowerShell pops-up and closes again in seconds and nothing is launched. Follwoing this thread, I think I followed the correct syntax.
$Script = 'S:\Prod\Script center\GUI Script.ps1'
$Credentials = Get-Credential
$powershellArguments = "-file '$Script'", "-noexit", "-verb runas"
Start-Process powershell -Credential $Credentials -ArgumentList $powershellArguments
These ones doesn't work either:
Start-Process powershell -Credential $Credentials -ArgumentList "-noprofile -command &{Start-Process powershell -verb runas -File 'S:\Prod\Script center\GUI Script.ps1'}"
Start-Process powershell -Credential $Credentials -ArgumentList "-noprofile -command &{Start-Process $script -verb runas}"
And this one is asking me the credentials, although they are already saved in the variable $Credentials. However, the powershell console launched is not launched as the user in the Credentials :(
$cmd = 'powershell.exe'
$arguments = "-NoExit", "-NoProfile", "-WindowStyle Maximized", '-NoLogo', "Credential $Credentials", "File '$script'"
Start-Process $cmd -ArgumentList $arguments -Verb runAs
I'm sure it's not related to the GUI script, because this works perfectly fine:
& 'S:\Prod\Script center\GUI Script.ps1'
Any help is greatly appreciated.
Maybe your error is only on argument single quotes $powershellArguments = "-file '$Script'"; double quotes should be used.
Start-Process -FilePath "powershell" -Credential $cred -ArgumentList #("-file 'cred.ps1'") # doesn't work
Start-Process -FilePath "powershell" -Credential $cred -ArgumentList #("-file ""cred.ps1""") # works