Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

search files from multiple servers from get-childitem

$
0
0

Hi

Now I am getting computer name as per requirement. But only issue is that this script giving me output only for one
computer name even i have multiple computer name in my CSV file.

 

Import-Csv "D:\test\serverlist.csv" | Foreach {
$server = $_.servername
$Drives = "c:\","D:\"
$size = 10KB
$extensions = @("*.jpg", "*.jpeg", "*.mpeg", "*.asx", "*.wm", "*.wmx", "*.wav", "*.mp3", "*.m3u", "*.aac", "*.wm", "*.aac", "*.wmv", "*.asf", "*.m2ts", "*.m2t", "*.mov", "*.qt", "*.avi", "*.wtv", "*.dvr-ms", "*.mp4", "*.mov", "*.m4v", "*.mpeg", "*.mpg", "*.mpe", "*.m1v", "*.mp2", "*.mpv2", "*.mod", "*.vob", "*.m1v", "*.avi", "*.jpg", "*.jpeg", "*.hdp", "*.wdp", "*.tif", "*.tiff", "*.raw", "*.gif", "*.bmp", "*.png")
$file = Get-ChildItem -Path $Drives -Include $extensions -Recurse -ErrorAction SilentlyContinue  -Force | 
where-Object {$_.length -gt $size} | 
Select-Object @{Name="computername";Expression{$server}},Name,CreationTime,@{Name="SizeInMB";Expression{$_.Length / 1MB}},LastAccessTime,LastWriteTime,extension,@{Name= "FilePath";Expression={$_.FullName}} | 
Export-CSV findfiles.csv -notypeinformation
}

how can I get output for each server which are in input CSV file


Viewing all articles
Browse latest Browse all 6937

Trending Articles