我是Powershell部署Chrome的新手,它会在远程计算机上删除一个文件夹,然后坐在"Installing update"中并且永远不会完成



>变量

$computernames = 获取内容 "C:\psexec\Chrome.txt">

$computernames = "NMOTC-sb10-9020"$sourcefile = "motc-ap-sccmmotc_packages\Chrome\googlechromestandaloneenterprise.msi">

本节将安装软件

福里奇 ($computer$computernames(

{

$destinationFolder = "\$computerc$Program FilesGoogle"
#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 $computerc$Program FilesgoogleapplicationChrome
    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 FilesgoogleChromegooglechromestandaloneenterprise.msi"  
} 
Write-Host -ForegroundColor Yellow Cleaning Up Installation Files
#Remove-Item $destinationFolder -recurse 

}

如果您在要安装 Chrome 的计算机上本地运行 ScriptBlock 中的代码,它是否有效? 我使用过:

msiexec.exe /i "C:SoftwareChromeGoogleChromeStandaloneEnterprise64.msi" /q /norestart

该命令在PowerShell中本地运行时对我有用,似乎也应该在您的ScriptBlock中工作。

变量

$computernames = 获取内容 "C:\psexec\Chrome.txt">

$computernames = "xxxx-sb10-3020"$sourcefile = "motc-ap-sccm\xxxx_packages\Chrome\googlechromestandaloneenterprise.msi">

本节将安装软件

福里奇 ($computer$computernames(

{

$destinationFolder = "\$computerc$Program FilesChrome"
#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 $computerc$WindowsSystem3211.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 FilesChromeGoogleChromeStandaloneEnterprise.msi"  
} 
Write-Host -ForegroundColor Yellow Cleaning Up Installation Files
Remove-Item $destinationFolder -recurse 
  

}我确实让它工作得很好

相关内容

最新更新