2012-05-14 198 views
0

我有類似的問題,我想在Win 7安裝Ciscoemail但它只是didnt幹活已經成功地通過組策略來安裝它在Win XP中使用此腳本PowerShell腳本

md c:\ciscoemail 

if not exist c:\ciscoemail\CiscoEmailSecurity_7-2-0-039.exe copy \\Domain Name\cisco\CiscoEmailSecurity_7-2-0-039.exe c:\ciscoemail /Y 
if not exist c:\ciscoemail\response_file.iss copy \\Domain Name\cisco\response_file.iss c:\ciscoemail /Y 
del c:\ciscoemail\setup.log /f /q 

if not exist C:\PROGRA~2\Cisco\CISCOI~1\CISCOE~1.DLL c:\ciscoemail\CiscoEmailSecurity_7-2-0-039.exe /s /v /qn /f1"c:\ciscoemail\response_file.iss" 

可有人請幫助將代碼轉換爲Powershell代碼。 簡單的步驟是:

  1. 將目錄設置爲本地c盤。

  2. 檢查ciscoemail是否存在於本地c盤上。

  3. 如果它不存在,並將其複製創建文件夾ciscoemail \ CiscoEmailSecurity_7-2-0-039.exe和ciscoemail \ response_file.iss到C盤

  4. .exe文件(安裝文件)

+1

[Stack Overflow是不是代碼翻譯服務(http://meta.stackexchange.com/a/129362/143302) – Filburt

回答

0

基本的翻譯:

# In PowerShell, md is an alias to mkdir which 
# is a function for creating folders 
$folder = md c:\ciscoemail 

# copy is an alias for Copy-Item 
if(-not(Test-Path -Path c:\ciscoemail\CiscoEmailSecurity_7-2-0-039.exe)) 
{ 
    copy -Path \\Domain Name\cisco\CiscoEmailSecurity_7-2-0-039.exe -Destination $folder.FullName 
} 

if(-not(Test-Path -Path c:\ciscoemail\response_file.iss)) 
{ 
    copy -Path \\Domain Name\cisco\response_file.iss -Destination $folder.FullName 
} 

if(Test-Path -Path c:\ciscoemail\setup.log) 
{ 
    # del is an alias to Remove-Item 
    del -Path c:\ciscoemail\setup.log -ErrorAction SilentlyContinue -Force 
}   

if(-not(Test-Path -Path "C:\PROGRA~2\Cisco\CISCOI~1\CISCOE~1.DLL")) 
{ 
    c:\ciscoemail\CiscoEmailSecurity_7-2-0-039.exe /s /v /qn /f1"c:\ciscoemail\response_file.iss" 
} 
+0

大吉文,釷它完美的作品。 –

+0

如果我想用數字證書對其進行簽名,以便每臺Win7計算機都能識別並信任安裝腳本,那該怎麼辦? –

+0

爲您的腳本簽名並將您的客戶端的執行策略設置爲AllSigned。 –