Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Get folder properties from a collection of servers

$
0
0

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)


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>