2015-09-11 134 views
0

我想构建一个将远程安装HP OM代理的脚本。有没有什么好的方法来安装它,而不需要在远程计算机上安装文件? 此脚本将远程安装惠普代理服务器列表。我想从我的电脑复制文件到每个服务器,然后安装它。我相信有更好的方法来做到这一点。 要安装我需要运行该命令的代理: CSCRIPT“\ C:\ pathToTheAgentFile” -i -a -minprecheck使用powershell远程安装

+0

你能告诉我们在远程计算机上有什么PowerShell版本可用吗? – Persistent13

+0

它在2-3之间,在我的电脑上它是4.是否有任何差异? –

+0

是的,可用的cmdlet和其他会影响脚本创建的功能。 – Persistent13

回答

0

使用调用命令与脚本块参数这么久应该完成这项任务作为静默安装方法用来。

$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 
} 

以上脚本将提示输入管理凭据,验证到持有从远程计算机安装一个远程共享,安装程序复制到远程计算机,然后启动远程计算机上安装程序。您必须手动验证安装,因为除非发生终止错误,否则不会返回任何数据。必须修改脚本以指向您的环境的正确位置。

+0

要安装代理程序,我需要运行以下命令:cscript path -i -a -minprechek,我应该在哪里放置脚本? –

+0

你能告诉要放在$ SilentInstallArgs中吗? 我如何把我的用户放在$ AdministratorCreds中? $ PathToShare和$ CommonLocalComputerPath之间有什么区别? 我的脚本中找不到任何您称为$ ComputersList的地方 –

+0

您将放置在$ SilentInstallArgs中的内容取决于HP OM代理安装时需要的参数,我不知道它们。从计算机运行脚本时,系统会自动提示输入凭据,凭据必须是在服务器上具有安装访问权限的凭据。 $ PathToShare是服务器可以访问的HP OP代理安装程序的位置。 $ CommonLocalComputerPath是服务器从共享位置放置HP OM安装程序副本的位置。 $ ComputerList是一个错字,我已经修复了这个错误。 – Persistent13