【发布时间】:2019-02-05 15:52:40
【问题描述】:
我有一个包含每周报告的文件夹。每个报告在名称示例“report-A_2_05_19.pdf”、“report-B_2_05_19.pdf”等中都有创建日期。我想为这些创建变量,但由于每周报告名称的日期都会发生变化我试图这样做:
$rA = "c:\reports\report-A*.pdf"
$rb = "C:\reports\report-B*.pdf
当我这样做并尝试使用通配符打开报告时,它只会打印到屏幕上:
c:\reports\report-A*.pdf
$pw = Get-Content C:\MailPW.txt | ConvertTo-SecureString
$cred = New-Object System.Management.Automation.PSCredential name@domain.com, $pw
Send-MailMessage -To name@domain.com -from name@domain.com -Subject "Attachments" -Body "Attachments." -attachments $rA, $rB -Smtpserver mail.domain.com -UseSsl -credential $cred
【问题讨论】:
-
见How to Ask。 Edit 问题并显示您的 minimal reproducible example 和一些显示问题的示例输出。
-
我对这个问题感到困惑。比如你在哪里使用变量
$rA和$rb -
$pw = 获取内容 C:\MailPW.txt | ConvertTo-SecureString;$cred = 新对象 System.Management.Automation.PSCredential name@domain.com, $pw;发送邮件消息 -至 name@domain.com -来自 name@domain.com -主题“附件” -正文“附件”。 -attachments $rA, $rB -Smtpserver mail.domain.com -UseSsl -credential $cred;
标签: powershell variables wildcard