我是新来的PowerShell部署Chrome则丢弃该远程计算机上的文件夹,然后在“安装更新”坐在那里永远无法完成
问题描述:
变量
$ computernames =获取内容“C:\ PSEXEC \ Chrome.txt”
$ computernames = “nMOTC-sb10-9020” $的资源文件= “\ nmotc-AP-SCCM \ nmotc_packages \铬\ googlechromestandaloneenterprise.msi”我是新来的PowerShell部署Chrome则丢弃该远程计算机上的文件夹,然后在“安装更新”坐在那里永远无法完成
本节将安装该软件
的foreach( $ computer in $ computernames)
{
$destinationFolder = "\\$computer\c$\Program Files\Google"
#This section will copy the $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
if (!(Test-Path -path $destinationFolder))
{
Write-Host -ForegroundColor yellow Creating Directory $computer\c$\Program Files\google\application\Chrome
New-Item $destinationFolder -Type Directory
}
Write-Host -ForegroundColor Yellow Copying Update
Copy-Item -Path $sourcefile -Destination $destinationFolder
Write-Host -ForegroundColor Yellow Installing Update
Invoke-Command -ComputerName $computer -ScriptBlock {& cmd /c msiexec.exe -ArgumentList "i C:\Program Files\google\Chrome\googlechromestandaloneenterprise.msi"
}
Write-Host -ForegroundColor Yellow Cleaning Up Installation Files
#Remove-Item $destinationFolder -recurse
}
答
如果你运行你的代码在本地在你的脚本块,你想在它的工作原理安装Chrome浏览器的机器上?我用过:
msiexec.exe /i "C:\Software\Chrome\GoogleChromeStandaloneEnterprise64.msi" /q /norestart
该命令在我在PowerShell本地运行它时看起来像在你的ScriptBlock中工作一样。
答
变量
$ computernames =获取内容 “C:\ PSEXEC \ Chrome.txt”
$ computernames = “XXXX-sb10-3020” $的资源文件=“\ nmotc-AP-SCCM \ xxxx_packages \铬\ googlechromestandaloneenterprise.msi”
本节将安装该软件
的foreach($在$ computernames计算机)
{
$destinationFolder = "\\$computer\c$\Program Files\Chrome"
#This section will copy the $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
if (!(Test-Path -path $destinationFolder))
{
Write-Host -ForegroundColor yellow Creating Directory $computer\c$\Windows\System32\11.0.19
New-Item $destinationFolder -Type Directory
}
Write-Host -ForegroundColor Yellow Copying Update
Copy-Item -Path $sourcefile -Destination $destinationFolder
Write-Host -ForegroundColor Yellow Installing Update
Invoke-Command -ComputerName $computer -ScriptBlock { & cmd /c msiexec.exe /i "C:\Program Files\Chrome\GoogleChromeStandaloneEnterprise.msi"
}
Write-Host -ForegroundColor Yellow Cleaning Up Installation Files
Remove-Item $destinationFolder -recurse
} 我没有得到这个工作很好
感谢杰森,我刚才看到这一点,并给它一个镜头。 – BGoodbred
嗨贾森,我试过你给的线,但它卡在“安装更新”我甚至离开了一天,第二天早上仍然在那里。 – BGoodbred
通过命令行执行该命令字吗? –