Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для sunnykey

Пользователь


Сообщения: 124
Благодарности: 47

Профиль | Отправить PM | Цитировать


Код: Выделить весь код
#Powershell script.
#Don't forget unlock script executing by 
#using command "Set-ExecutionPolicy RemoteSigned" or "Set-ExecutionPolicy Unrestricted"
#Save this file with ".ps1" extension

function SendMailToUser($To,$FileMask) {
    $From="otpravitel@mail1.mail2.ru"
    $Subject="INFO"
    $Body="This is test message"
    $Password="password"
    $SecPassword=New-Object -TypeName System.Security.SecureString
    $Password.ToCharArray() | foreach {$SecPassword.AppendChar($_)}
    $Credintial=New-Object -TypeName System.Management.Automation.PSCredential `
        -ArgumentList $From,$SecPassword
    $smtpServer="smtp.mail1.mail2.ru"
    Get-ChildItem "C:\otpravka\*" -Include $FileMask -Recurse | `
        Where-Object {$_.Attributes -ne [System.IO.FileAttributes]::Directory} | `
        foreach {$_.FullName} | `
        Send-MailMessage -From $From -To $To -Subject $Subject `
        -Body $Body -Credential $Credintial -SmtpServer $smtpServer
}

SendMailToUser -To "poluchatel1@mail1.mail2.ru" -FileMask "*.014"
SendMailToUser -To "poluchatel2@mail1.mail2.ru" -FileMask "*.015"

-------
cmd умри, powershell живи=)
Powershel 4.0 microsoft.com/ru-ru/download/details.aspx?id=40855

Это сообщение посчитали полезным следующие участники:

Отправлено: 15:13, 05-07-2013 | #2