我目前正在使用:
$emailFrom = "user@host.com" $emailTo = "destination@host.com" $subject = "subject" $body = "message" $smtpServer = "mail.host.com" $smtp = new-object Net.Mail.SmtpClient($smtpServer) $smtp.Send($emailFrom,$emailTo,$subject,$body)
我知道,通过以下命令,我可以找到我所有硬盘上的可用空间:
Get-WmiObject WIN32_logicaldisk | sort -desc freespace | select -first 3 | format-table -autosize deviceid,devicetype,providername,freespace,size,volumename;
当我尝试这样做:
$body = Get-WmiObject WIN32_logicaldisk | sort -desc freespace | select -first 3 | format-table -autosize deviceid,volumename;
Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData
尝试:
$body = Get-WmiObject WIN32_logicaldisk | sort -desc freespace |选择 – 第一个3 | format-table -autosize deviceid,volumename |出弦
我刚刚在我的电脑上试过它并且它有效.
有关其工作原理的一些背景,请参阅:
JR