简体   繁体   中英

Multiple Inputs to Powershell script

I am running one script which is asking me multiple inputs like "R" "Y" "IP address". How to make this automate .How can I pass R and after that again R then IP address ? I have tried few example on web but its not working ...

1) PS C:\orchestrator\scripts> ./Install-Orchestrator.ps1 echo "Y`r" | pw
2)./Install-Orchestrator.ps1 |echo R
3).powershell.exe -noexit -file 'Install-Orchestrator.ps1' "R"

Below is the script and options

PS C:\orchestrator\scripts> ./Install-Orchestrator.ps1

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run C:\orchestrator\scripts\Install-Orchestrator.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
---------------------------------

  UiPath Orchestrator v2 Installer

---------------------------------

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run C:\orchestrator\scripts\Test-FrameworkVersion.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
Checking current version of .NET
Current .NET version installed  4.7
You have correct version of .NET: (4.7)

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run C:\orchestrator\scripts\Test-WebDeployVersion.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
Checking current version of Web Deploy
You have correct version of Web Deploy  3.1237.1764

Do you want to test port to database?
[Y] Yes  [N] No  [?] Help (default is "N"): Y
Testing open port to database

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your
computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message. Do you want to run C:\orchestrator\scripts\Test-PortOpen.ps1?
[D] Do not run  [R] Run once  [S] Suspend  [?] Help (default is "D"): R
Enter the host/ip address: 10.10.10.100
Enter the port number to access: 1433

Try this
Create a text file with the inputs like below

some_text_file.txt
R
Y
10.0.0.123

Then run the below command in Powershell

Start-Process -FilePath "./Install-Orchestrator.ps1" -ArgumentList "if there are any" -Wait -RedirectStandardInput "./some_text_file.txt"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM