Im new to powershell and need a little help. I have a script put together that does what I need it to do on a single server but I want it to query the folder properties of a collection of servers and include the servername in csv file. This is what I have so far:
$path = "c:\EVOfflineVault" $CsvFilePath = "C:\Windows\temp\EVOfflineFoldersReport.csv" Get-ChildItem $path | Where-Object {$_.PSIsContainer} | % { $size = (Get-ChildItem $_.FullName -recurse -force | Measure-Object -property length -sum -ErrorAction SilentlyContinue).sum $obj = New-Object PSObject Add-Member -inp $obj NoteProperty Name $_.Name Add-Member -inp $obj NoteProperty Path $_.FullName Add-Member -inp $obj NoteProperty Size $size $obj } | Sort-Object Size -Descending | Select-Object Name, @{N="Size(KB)";E={"{0:N2}" -f ($_.Size / 1KB)} },Path | Export-CSV -Path $CsvFilePath -NoTypeInformation $file = $CsvFilePath $att = new-object Net.Mail.Attachment("$file") $msg = new-object Net.Mail.MailMessage $smtp = new-object Net.Mail.SmtpClient("mail.email.com",25) $msg.From = "email@blah.com" $msg.To.Add("email@blah.com") $msg.Subject = "EVOfflineCache Citrix Report" $msg.Body = "See Attached" $msg.Attachments.Add($att) $smtp.Send($msg)