1
我想用powershell發郵件。如果我在manualy中鍵入我的憑證,該腳本正常工作。但我想在腳本中提供憑據參數。我的腳本是這樣的:用powershell發郵件
$From = "[email protected]"
$To = "[email protected]"
$Cc = "[email protected]"
$Attachment = "C:\Users\test\test\test.ini"
$Subject = "Email Subject"
$Body = "Insert body text here"
$SMTPServer = "smtp.mail.yahoo.com"
$SMTPPort = "587"
Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject `
-Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl `
-Credential (
$MyClearTextUsername=’[email protected]’
$MyClearTextPassword=’test123’
$SecurePassword=Convertto-SecureString –String $MyClearTextPassword –AsPlainText –force
$MyCredentials=New-object System.Management.Automation.PSCredential $MyClearTextPassword,$SecurePassword) -Attachments $Attachment
非常感謝! – Tibi
沒問題,如果答案對您有幫助,請將其標記爲答案;)@Tibi – 4c74356b41
標記!直到現在,我都不會讓我。你回答得太快了:D – Tibi