Solved

Want to extract all Shares on my domain with computer names.

Posted on 2014-09-05
7
308 Views
Last Modified: 2014-09-12
I have list of computers in txt format. I need to get all shares folder with the shared path e.g

\\serverexchange\tic
0
Comment
Question by:SAIMSKY ADMIN
7 Comments
 
LVL 9

Expert Comment

by:Ashok Dewan
ID: 40305632
check this below link. I hope you will find it helpful.

http://www.softperfect.com/products/networkscanner/

Regards
Ashok Dewan
0
 

Author Comment

by:SAIMSKY ADMIN
ID: 40305634
Thanks Ashok  but i need powershell script if you can help .
thanks
0
 
LVL 16

Expert Comment

by:gurutc
ID: 40305636
this command:
Try this batch file:

setlocal enabledelayedexpansion
FOR /f %%i IN (serverlist.txt) DO call :inside %%i
GOTO :EOF
:inside
echo %1 >> sharelist.txt
net view \\%1 >> sharelist.txt
GOTO :EOF
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40306124
Try this code.. Input the server names in C:\Server.txt.
GC C:\Server.txt | %{
$server = $_.Trim()
Write-host "Working on $server"
	Try{
	Get-WmiObject Win32_share -ComputerName $server -filter "type = 0" -ea Stop | Select __SERVER,Name,Path
	}Catch{
	$_.Exception | Select @{N="__SERVER";E={$server}},@{N="Name";E={$_.Message}},Path
	}
} | Export-Csv C:\Report.csv -nti

Open in new window

1
 
LVL 39

Expert Comment

by:footech
ID: 40306358
If you actually need the UNC path output, you can use the below.
GC C:\Server.txt | %{
   $server = $_.Trim()
   Get-WmiObject Win32_Share -ComputerName $server -filter "type = 0" | Select @{n="UNCPath";e={"\\$server\$($_.Name)"}}
}

Open in new window

1
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 40306492
Incorporated footech's uncpath suggestion...
GC C:\Server.txt | %{
$server = $_.Trim()
Write-host "Working on $server"
	Try{
	Get-WmiObject Win32_share -ComputerName $server -filter "type = 0" -ea Stop | Select __SERVER,Name,Path,@{n="UNCPath";e={"\\$server\$($_.Name)"}}
	}Catch{
	$_.Exception | Select @{N="__SERVER";E={$server}},@{N="Name";E={$_.Message}},Path,UNCPath
	}
} | Export-Csv C:\Report.csv -nti

Open in new window

1
 

Author Closing Comment

by:SAIMSKY ADMIN
ID: 40318766
Thanks mate
0

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now