I recently had a need to get a list of hidden files in a directory tree. PowerShell made it fairly easy to knock out the list in a quick and dirty fashion, by checking if the file Attributes contain the string “Hidden”:
Continue reading “Find hidden files with PowerShell”
Sending mail with PowerShell
[June 27, 2014] Update: I’ve made several updates, including multiple recipients and sending attachments.
If you’ve created a PowerShell script that runs as a scheduled task, you may want to have it send you an e-mail with a log file or other notification about what the script did or didn’t do (i.e. error notification). PowerShell version 2 provides the Send-MailMessage
cmdlet to do this, but in some cases the older System.Net.Mail
.NET namespace is a more desirable approach (System.Net.Mail
also works in PowerShell version 1).
Continue reading “Sending mail with PowerShell”