Suppress Confirmation Popup during msi installation - powershell

I am trying to uninstall the older version of the software and install the latest version. I have an uninstall script and an install script that does this. When I run the script as Powershell as Admin, the script executes successfully, but in non Admin mode, it prompts for a popup asking for confirmation,
Since I am trying to automate via pipeline I need to skip or suppress this popup,
msiexec.exe /i "installer.msi" /q
$app = Get-WmiObject -Class Win32_Product -Filter "Name = 'installer'" | Remove-WmiObject
I have tried using /q, /quiet that did not help
Is there any way to suppress such prompt so that it can continue silently?

Related

az : The term 'az' is not recognized as the name of a cmdlet - doesnt work from powershell but works on command prompt windows 10 Ps version 5

I have been testing code on my laptop recently, and this appears to be broken my az cli setup. I now get an error, I have followed the steps detailed on most SO pages which entail running the command
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
AZ cli works on command prompt just not on powershell.
I uninstalled az cli
Restarted laptop
Ran the command above which completed, again it works on command prompt just not on powershell.
Environment.
Windows 10
Ps version
Major Minor Build Revision
5 1 19041 1682
I suspect it is to do with the path profiles as the script I was running the other day was changing the path profile before I had to reboot the laptop.
I also found this instruction on another SO page. ran this to no avail.
Install-Module AzureAD -Force Install-module AzureADPreview -Force Install-Module -Name MSOnline -Force Import-Module Az -Force Install-Module Az -Force
Thanks #mklement0, you definitely pointed me in the right direction.
I ran $env:path and this came up with C:\Program Files\OpenSSL\bin
I can see the problem now, I resolved it by getting the values of my path variable from the GUI Advanced system settings >> Environment variables and copy the values of path.
from a PS console screen set the values for path by running the following.
$env:path = "the values from the path environment variables above"
After running the above, I can run az cli once more.

Delete an .EXE application remotely

when the application is from .msi or .msu it's easy to uninstall them from a remote computer using WMI, but WMI only works on Microsoft based applications (.msi, .msu). I can't find a way to uninstall an exe based app remotely without using invoke, I try to not use it because this will be used by many people and on many computers, it's disabled, I can enable it for me but not for everyone (I'm an intern :D)
this is the code that I have for .exe but it's not remote
cmd.exe /c "$($app.meta.Attributes["UninstallString"]) /S"
while this is a remote msi, msu uninstall line
$Application = Get-WmiObject Win32_Product -ComputerName $ComputerName | Where-Object {$_.Name -eq $Name} #choose the object, this will be the app that we will delete
if ($Application) {
$Application.Uninstall()
any suggestion will be appreciated

I want to run Power Shell script with admin privileges

I want to run this powershell script with admin privileges so it won't give me the error:
Script Output with error
Here is the script:
$processes = "PDStyleAgent", "AdobeIPCBroker", "CCXProcess", "RichVideo64", "CCLibrary", "AdobeNotificationClient", "AdobeUpdateService", "PDHanumanSvr", "PDR"
Foreach ($process in $processes){
try {
$f = Get-Process $process -ErrorAction Stop
$f | kill
Write-Output "$process killed."
}
catch [Microsoft.PowerShell.Commands.ProcessCommandException]{
Write-Output "No instances of $process running."
}
}
Start-Sleep -Seconds 3
I want to run this script so it kill the processes that are giving errors
Some way to run PowerShell with admin privileges:
Search Powershell from the Windows search icon OR click the Windows button from the keyboard --> write Powershell --> You will see the Windows PowerShell --> Right-click on Powershell then click Run as administrator.
Run this command of a PowerShell console: Start-Process powershell -Verb runAs
Run your script from PowerShell like this: PowerShell -f C:\ScriptPath
For more details, you can check this StackOverflow question and answer.
I'm not sure what exactly you are asking about. If you want to start a script as administrator, you need to open PowerShell window "As administrator".
BTW, the script itself can be simplified without losing functionality:
$processes = "PDStyleAgent", "AdobeIPCBroker", "CCXProcess", "RichVideo64", "CCLibrary", "AdobeNotificationClient", "AdobeUpdateService", "PDHanumanSvr", "PDR"
Get-Process -Name $processes -ErrorAction SilentlyContinue | Stop-Process -Verbose
1.Create a shortcut to your Powershell script on your desktop
2.Right-click the shortcut and click Properties
3.Click the Shortcut tab
4.Click Advanced
5.Select Run as Administrator
NOTE: add powershell -f in front of the script path

How to uninstall a application through powershell which is not a Microsoft product

I want to uninstall an application through powershell scripting which is not a Microsoft product
I have tried with the below code but then it says "you cannot call a method on a null valued expression". This was because it couldn't point to that respective software.
$app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "*Software_Name*" }
$app.Uninstall()
And when I tried with Get-RemoteProgram command, it is listing out only the Microsoft softwares.
How to uninstall other softwares?
A possible solution is to find the GUID of the application in the registry in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and uninstall it using MsiExec:
Start-Process -FilePath MsiExec -ArgumentList '/quiet /uninstall {109A5A16-E09E-4B82-A784-D1780F1190D6}' -Wait
The above example uninstalls the Windows Firewall Configuration Provider.

Install remotely with powershell

I want to build a script that will Install remotely HP OM agent. Is there any good way to Install it, without having the install files on the remote computer?
this script will install remotely the HP agents for list of servers. I thought to copy the files from my computer to each server and after that to install it. I'm sure there is a better way to do it.
To install the agent I need to run the command :
cscript "\c:\pathToTheAgentFile" -i -a -minprecheck
Using Invoke-Command with the ScriptBlock parameter should accomplish this task so long as a silent install method is used.
$ComputersList = #("computer","names","here","replace","me")
$PathToShare = "\\path\to\install_replace_me.exe"
$CommonLocalComputerPath = "C:\replace_me.exe"
$SilentInstallArgs = "/example","/replace"
$AdministratorCreds = [System.Management.Automation.PSCredential]::Empty
$ComputersList | ForEach-Object {
Invoke-Command -ComputerName $_ -ScriptBlock { Copy-Item $Using:PathToShare -Destination $Using:CommonLocalComputerPath -Credential $Using:AdministratorCreds;
Start-Process $Using:CommonLocalComputerPath -ArgumentList $Using:SilentInstallArgs -Credential $Using:AdministratorCreds} -Credential $AdministratorCreds
}
The above script will prompt for administrative credentials, authenticate to a remote share that holds the installer from the remote computer, copy the installer to the remote computer, and then start the installer on the remote computer. You will have to verify the installs manually as it will not return any data except in the event of a terminating error. The script will have to be modified to point to the correct locations for your environment.