I have been trying to just get what would look like he contents of a directory when using the simple “dir” command, but have had no luck. The below is close, but is not showing my how many files are in the directory. I tried to figure out how to use the Measure-Object cmdlet, but only wound up breaking the ability to Send the mail message. Can someone assist me with getting a directory and its contents emailed to me which includes the number of files? Sorry … I tried to get the below code into a code box, but not sure what I was doing wrong. It came out all in one long line.
net use L: \system1-NA-01\RTC\Production
$body = Get-ChildItem -Path L:\ | Out-String
Send-MailMessage -From email@example.com -Subject “Cleanup Results” `
-To firstname.lastname@example.org -Body $body `
net use L: /d