windows組策略開機腳本 Powershell 安裝Symantec示例

貌似2008server組策略啓動腳本暫不支持powershell腳本,可以通過cmd調用powershll來執行,從而實現複雜的功能。用來替代VBS。


在DC上配置啓動腳本 start.bat
內容如下:

@C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe  -executionpolicy unrestricted \\xxx\xxx.ps1

指向要執行的powershell腳本

示例腳本爲安裝Symantec

<#
Symantec Install
#>
$pl=Get-WmiObject win32_product
#獲取已安裝的軟件
foreach ($i in $pl){
    if ($i.Name -eq "此處是Symantec的名稱" -and $i.Version -eq "此處是對應的版本"){
    #判斷是否安裝的需求的軟件,安裝了就直接結束腳本
    Exit
    }
}
#沒安裝就安裝指定軟件
msiexec /i \\xxxxxxxx\SymantecInstallPacke\Client_x86\Sep.msi /qn
#下面是做日誌記錄
$hn=hostname
$content=$hn + "`tinstalled"
$content|Out-File \\xxxxxxxx\Log\xx.txt

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章