简体   繁体   中英

Powershell script

I have a similar problem,i want to install Ciscoemail on Win 7 but it simply didnt work.I have successfully installed it on Win XP via Group Policy with this script

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"

Can someone please assist with turning the code to Powershell code. The simple steps are :

  1. Make directory to Local c drive.

  2. check if the ciscoemail exists on the local c drive.

  3. create folder if it does not exist and copy ciscoemail\\CiscoEmailSecurity_7-2-0-039.exe and ciscoemail\\response_file.iss to c drive

  4. .exe (installation file)

The basic translation:

# 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"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM