Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to get this data

Status
Not open for further replies.

tuttut

Technical User
Sep 15, 2010
3
US
I have a script that searches recursively through directories to get file extensions of a certain type. I wanted a way to automate getting all the network shares on a remote file server and go through the directories. This is the part I need help with. This here below will get the shares of a remote server once the remote server has been validated. Not sure if an Array will work here and I have to be the first to admit. I am pretty green at powershell.

$servername = read-host "type the server name here please"
$servername


$getshare = Wmiobject win32_share -computername $servername | where {$_.name -notlike "*$"} | sort-object -property path | ft name -autosize

$getshare


I am trying to incorporate this into this part here below which is working.


"*.txt","*.log", "*.mp3", "*.avi", "*.rar" | foreach {
$( $Files = Get-ChildItem "\\fileshare\share" -Recurse -Filter $_
$Files | %{ "$($_.FullName) - $($_.Length/1Kb)Kb" } >> c:\temp\log.dat
""
"Total Number of Files: $(([Array]$Files).Count)"
"Total Size: $(($Files | Measure-Object -Sum Length).Sum/1Gb)Gb" )
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top