More on my recent PowerShell project. I recon I have taken on the challenge to handle this entire request using Posh. It started out just moving folders based on the folder name that included the date in format MMDDYY. Next was having to stop services before moving the folders. After that came a request to email the number of folders that are being moved.
This gave me two challenges. One was getting the count of the folders and second was how to email using Posh. I started my search on getting the folder count, for one that was trouble enough because everything was related to getting file count. After a few searches I found the Where {$_.PSIsContainer} syntax which helped greatly.
I found the ability to send email very simple using “Send-MailMessage” all you need is the syntax to include.
What ended up working for me was the following code.
. $item = (Get-ChildItem “\\myserver\directory1\directory2\” | Where {$_.PSIsContainer})