Scripting an auto-response to a on-screen installation prompt - powershell

I'm attempting to install several manual related software updates via scripting. My dilemma is that there is an onscreen pop-up prompt that says "Update" when I run each of the installers. I want to create a script that automatically answers the "Update" prompt.
I've tried the following in batch:
echo y | "program.exe"
echo update | "program.exe"
I've tried the following in powershell:
start-process "program.exe" -redirectstandardinput "answer file.txt"
(The answer file contains the word Update.)
Both of these methods still result in me receiving the "Update" prompt from each of the installers' GUI.
Any help would be appreciated!

Related

How to see what process is triggered with a PowerShell cmdlet

currently, I am trying to get some silent install commands out of the winget cmdlet in order to deploy win32apps via intune. Most of the time I just run the powershell window without admin & when I use the below command (with adobe for example) it prompts for admin credentials and shows me the process i.e. "do you want to make following changes to your pc blabla AcroRdrDCx642200220191_MUI.exe /sAll /rs /rps /l /re"
Is there a different method to see what kind of process a cmdlet triggers? because some apps don´t need admin for their .exe´s and I can´t look up random silent install commands in the internet, neither use so called "tools" to determine them, because either they are expensive as hell or not reliable.
would be nice if someone can help me out here :)
winget install --exact --silent --accept-package-agreements --accept-source-agreements "randomapp"
If you run winget install <package> --verbose-logs you can open up the log file and see which switches were passed to the installer. The log file location is displayed via winget --info.

error appear when installing IBM Cloud CLI "'iex' is not recognized as an internal or external command..."

I'm trying to install IBM Cloud CLI but there is a problem faced me when I do this.
I added the Path to environment variables but it didn't work too !
This happens because the iex (shorthand for Invoke-Expression) command is a Powershell command, but it is entered to Command prompt. The latter is the old command shell that dates back to the MS-DOS days of the 80's.
One can tell the difference from the fact that the window title bar says Command Prompt, not Powershell. Often - not always! - a Powershell session has blue background and command has black.
To run Powershell commands, start a Powershell session either by typing powershell and pressing enter into a command session, or by opening Windows Start menu and typing powershell (followed by enter).

Is it possible to launch a groovy command within powershell?

I am wondering if it's possible to run a groovy command within the powershell console? Whenever I'm uninstalling or installing my application, I use a bunch of predefined groovy commands to do so on the command line.
ie.) groovy uninstall.groovy -p e:\Software\deploy_script.properties -b batch bundle
I am a bit stuck in terms of how to go about this. I've created a script that launches the cmd.exe window but I am unsure how to code it next to specifically add the lines "groovy uninstall.groovy -p e:\Software\deploy_script.properties -b batch bundle" so it gets displayed on the cmd prompt.
Start-Process -FilePath "C:\Windows\System32\cmd.exe"
Any help would be appreciated.
Thank you

SCCM - Accept a dialog box via command line to uninstall a simple MSI

I'm trying to uninstall a simple MSI via SCCM but when I start the command line, this message appears "Are you sure to uninstall this application ?" and I have the "Yes or No" choice.
I tried with this command line: msiexec /x {D582312F-07B5-434A-8CBB-F6793440CD0C} /qn
But nothing is happening because I think the command line is stuck when the question is asked.
Anybody have had the same problem and have a solution to respond "Yes"?
Thansk a lot in advance,
G. Cotting

Powershell Script doesn't work when starting it by double-clicking

I got some strange behaviour when executing a powershell script.
When I run my script using the ISE it works just fine.
When I open Powershell.exe and run my script it works just fine.
When I open cmd, and start my script using powershell.exe -noexit
./myscript.ps1, myscript works just fine.
When I double-click myscript however, powershell opens for some milliseconds, I see that it shows some error (red font) and the powershell window closes. I'm unable to track down the error causing this problem since the powershell windows closes to fast.
I even tried one single big try-catch block around my hole script, catching any [Exception] and writing it down to a log file. However: the log file is not generated (catch is not called).
How can I track that issue? What could possibly be causing the trouble?
Please note that my execution-policy is set to unrestricted.
Before trying the suggestion invoke this to see your current settings (if you want restore them later):
cmd /c FType Microsoft.PowerShellScript.1
Then invoke this (note that you will change how your scripts are invoked "from explorer" by this):
cmd /c #"
FType Microsoft.PowerShellScript.1=$PSHOME\powershell.exe -NoExit . "'%1'" %*
"#
Then double-click the script, it should not exit, -NoExit does the trick. See your error messages and solve the problems.
But now all your scripts invoked "from explorer" keep their console opened. You may then
remove -NoExit from the above command and run it again or restore your
original settings.
Some details and one good way to invoke scripts in PS v2 is here.
Unfortunately it is broken in PS v3 - submitted issue.
by default, for security reason when you double clic on a .ps1 file the action is : Edit file, not Run file .
to execute your script : right-click on it and choose run with powershell
I also wasn’t able to run a script by double clicking it although running it manually worked without a problem. I have found out that the problem was in the path. When I ran a script from a path that contained spaces, such as:
C:\Users\john doe\Documents\Sample.ps1
The scipt failed to run. Moving the script to:
C:\Scripts\Sample.ps1
Which has no spaces, solved the problem.
This is most likely an issue with your local Execution Policy.
By default, Powershell is configured to NOT run scripts that are unsigned (even local ones). If you've not signed your scripts, then changing your default double-click 'action' in Windows will have no effect - Powershell will open, read the execution policy, check the script's signature, and finding none, will abort with an error.
In Powershell:
Help about_execution_policies
gives you all the gory details, as well as ways to allow unsigned scripts to run (within reason - you'd probably not want to run remote ones, only ones you've saved onto the system).
EDIT: I see at the tail end of your question that you've set Execution Policy to 'unrestricted' which SHOULD allow the script to run. However, this might be useful info for others running into execution policy issues.
If you would catch the error you will most likely see this
The file cannot be loaded. The file is not
digitally signed. The script will not execute on the system. Please
see "Get-Help about_signing" for more details.
Because you are able to run it from the shell you started yourself, and not with the right mouse button click "Run With PowerShell", I bet you have x64 system. Manually you are starting the one version of PowerShell where execution policy is configured, while with the right click the other version of the PowerShell is started.
Try to start both version x64 and x86 version and check for security policies in each
Get-ExecutionPolicy
I was in exactly the same situation as described in the question : my script worked everywhere except when double-clicking.* When I double-clicked a powershell windows would open but then it will close after a second or so. My execution-policy is also set to unrestricted.
I tried the selected answer concerning FType Microsoft.PowerShellScript.1 but it didn't change anything.
The only solution I found was a work around: create a bat file which start the powershell.
Create a file, copy this and modify the path : powershell.exe -File "C:\Users\user\script\myscript.ps1"
Save it as a .bat
Double-click the bat
I also used .ahk to start my powershell with a shorcut and it didn't work when pointing directly to the powershell. I had to point to the .bat