简体   繁体   English

如何将输入传递到CA NIMSOFT powerhell脚本中的powershell脚本?

[英]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. 我正在使用CA NIMSOFT工具将PowerShell脚本部署到其他已安装代理的计算机上。 Now what I am doing is I am running below script of NIMSOFT for logging to another computer and deploying a script. 现在我正在做的是我正在NIMSOFT的脚本下运行以登录到另一台计算机并部署脚本。

NIMSOFT script NIMSOFT脚本

    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,该脚本必须由Read-Host接受输入,因此如何将输入传递给此NIMSOFT脚本,该脚本将传递给b.ps1。

b.ps1 script b.ps1脚本

$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. 我想将NIMSOFT脚本中的值传递给b.ps1。

add into start PowerShell script this row : 将以下行添加到启动PowerShell脚本中:

Param( [string] $Param1)

and modify PowerShell code like this : 并修改PowerShell代码,如下所示:

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

into you nimsoft script modify like this : 进入您的nimsoft脚本,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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