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" )
}
$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" )
}