檢視次數:

使用 Active Directory 群組策略管理主控台部署代理程式安裝程式的範例 PowerShell 腳本。

如有需要,請更改程式碼中的變數以符合您環境,例如 $logpathlocal$uncPath$localPath
該腳本需要使用 System 來執行,以避免使用高權限帳戶的安全問題。
$logpathlocal="C:\temp\V1ES\Logs" #Specify a path users have enough permission to write to.
Start-Transcript -Path $logpathlocal -Append
$service = Get-Service -Name tmlisten,ntrtscan,amsp,ds_agent -ErrorAction SilentlyContinue
if ($service -eq $null) {
    $uncPath = "\\TrendMicro_Demo_VS\V1ES_client\V1ES" #Specify the UNC location of the unzipped agent installation files
    $localPath = "C:\temp\" #The location to copy the installation files to on the target endpoint 
    $installerFileName = "EndpointBasecamp.exe"

    Copy-Item -Path $uncPath -Destination $localPath -Recurse -Force
    while ((Get-ChildItem $localPath).Count -lt (Get-ChildItem $uncPath).Count) {
        Start-Sleep -Seconds 1
    }
    Write-host "File copy completed, start to install progress" 
    $localInstallerPath = Join-Path $localPath $installerFileName
    Start-Process -Wait -FilePath $localInstallerPath -ArgumentList '/s /v/qn' -PassThru
} else {
    Write-host "The services already existed, skip the installation." 
}
Stop-Transcript