简体   繁体   中英

How to pass a input to powershell script within a CA NIMSOFT powerhell script?

I am using CA NIMSOFT tool to deploy PowerShell scripts to others computer which have agents installed on them. Now what I am doing is I am running below script of NIMSOFT for logging to another computer and deploying a script.

NIMSOFT script

    param($TARGET="sw02111", $ProfileName="CustoPowerShell", $SCRIPT="powershell.exe -ExecutionPolicy Bypass -File 'C:\Users\Desktop\Desktop\b.ps1'")


$HubRobotListPath = "C:\Users\User1\Desktop\hubrobots.txt"
$UserName = "administrator"
$Password = "Password@123"
$Domain = "DomainA"
$HubOne ="sw02111"

Now I have a script b.ps1 which has to take input by Read-Host so how can I pass input to this NIMSOFT script that will be passed to b.ps1 .

b.ps1 script

$servicename = Read-Host -Prompt 'Input the Service Name'
Start-Service $serviceName -ErrorAction Stop

I want to pass a value from NIMSOFT script to b.ps1.

add into start PowerShell script this row :

Param( [string] $Param1)

and modify PowerShell code like this :

$servicename = $Param1
Start-Service $serviceName -ErrorAction Stop

into you nimsoft script modify like this :

param($TARGET="sw02111", $ProfileName="CustoPowerShell", $SCRIPT="powershell.exe -ExecutionPolicy Bypass -File 'C:\Users\H588753\Desktop\b.ps1' 'value of service you want'")

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