PowerShell 批量执行所有主机通过脚本安装软件

Posted CIAS

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PowerShell 批量执行所有主机通过脚本安装软件相关的知识,希望对你有一定的参考价值。

 

创建批量执行所有主机通过脚本安装软件自动化脚本

  • $local_path="D:\\PowerShell\\Powershell-Windows_Admin_Center-install\\" #本地脚本存放目录
  • $Destination="d:\\" #本地拷贝的脚本到目标主机的目录
  • Invoke-Command -filepath D:\\Powershell-Windows_Admin_Center-install\\powershell-install-Windows-Admin-Center.ps1 -ComputerName $server -Credential $cred #此处是直接执行本地代码生效到目标主机,此处我注释了,需要此案例的可以启用注释掉下方invoke-expression段
  • invoke-expression -command D:\\Powershell-Windows_Admin_Center-install\\powershell-install-Windows-Admin-Center.ps1 #此处执行的是拷贝到目标主机上的脚本,替换成你自己的脚本名称
  • $user="administrator" #用户,必须是管理员
    $password=ConvertTo-SecureString "YOU_password" -AsPlainText -Force #用户密码
    $cred=New-Object System.Management.Automation.PSCredential($user,$password)
    $pchost=\'192.168.19.10&#

以上是关于PowerShell 批量执行所有主机通过脚本安装软件的主要内容,如果未能解决你的问题,请参考以下文章

PowerShell 批量部署VMware-tools到所有Windows主机

PowerShell 批量部署VMware-tools到所有Windows主机

PowerShell 批量部署VMware-tools到所有Windows主机

PowerShell 批量部署windows_exporter到所有Windows主机

PowerShell 批量部署windows_exporter到所有Windows主机

PowerShell 批量创建用户用户组到所有Windows系统