This PowerShell one-liner will list all the shares of the specified computer, and
for each share will list all its files:
foreach($Share in Get-WmiObject Win32_Share -ComputerName 'COMPUTER') {Get-ChildItem "\\$($Share.__SERVER)\$($Share.Name)"}
You may all invoke it from a Command Prompt (cmd) or batch (.bat
) as:
powershell "foreach($Share in Get-WmiObject Win32_Share -ComputerName 'COMPUTER') {Get-ChildItem "\\$($Share.__SERVER)\$($Share.Name)"}" >\path\outfile.txt
EDIT
For querying a non-Windows server, the problem is that the above
requires an RPC server which is not available.
You might try using WMIC instead. Enter in the PowerShell command prompt
the following two lines for one such Linux server:
$allshares = (net view \\SERVER) | % { if($_.IndexOf(' Disk ') -gt 0){ $_.Split(' ')[0] }}
foreach ($Share in $allshares) {Get-ChildItem "\\SERVER\\$Share"}
net view
and result parsing