1
私はpowershellで電子メールを送信したいと思います。私の資格情報を手作業で入力すれば、スクリプトはうまく動作します。しかし、私はスクリプト内に資格情報のパラメータを与えたい。私のスクリプトは次のようになります。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