Solved

Powershell Network Share Info

Posted on 2013-06-05
3
267 Views
Last Modified: 2013-11-05
Hello,

I have a list of network shares that I need to gather info on, I need at least 2 out of 3 of the fields below:

                Capacity Allocated
                Capacity Used
                Capacity Free

I can do the looping through the file with the list of shares etc no problem, just completely unsure how i would gather share info by just the share name i.e \\myserver\share

Any help would be appreciated on that part :)

M
0
Comment
Question by:mikeyd234
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 22

Expert Comment

by:Haresh Nikumbh
ID: 39222633
0
 
LVL 3

Author Comment

by:mikeyd234
ID: 39222814
Thanks takecoffe, but that article describes connecting to a server/computer then listing all it's shares, all I have are share names, need to be able to connect via a share name and get it's details.

I was thinking maybe a temp drive map then gather properties on it but seems like a long way around..?
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39222871
That's a good script there, but can be improved to allow to query more than one server, and allow for some optimizations.
$PC = "server1", "server2"

$Volumes = Get-WMIObject Win32_Volume -ComputerName $PC -ea SilentlyContinue | sort -Descending __Server, {$_.Name.Length}

Get-WMIObject Win32_Share -ComputerName $PC -Filter "Type = 0" | foreach {
  $Share = $_
  $Result = "" | Select Server, Share, Path, Volume, Used, Free, Total
  $Result.Server = $Share.__SERVER
  $Result.Share  = $Share.Name
  $Result.Path   = $Share.Path
  $ShareVolume="" | Select Name 
  Foreach ($Volume in $Volumes | where { $_.__SERVER -eq $Share.__Server } ) 
  { 
    If ( ($Result.Path.Length -ge $Volume.Name.Length) -and ($Volume.Name.Length -gt $ShareVolume.Name.Length) )
    { 
      If ($Result.Path.Substring(0,$Volume.Name.Length) -eq $Volume.Name) { $ShareVolume = $Volume; break } 
    } 
  }
  $Result.Volume = $ShareVolume.Name; 
  [int] $Result.Total  = $ShareVolume.Capacity /1024/1024
  [int] $Result.Free   = $ShareVolume.FreeSpace/1024/1024
  [int] $Result.Used   = ($ShareVolume.Capacity - $ShareVolume.FreeSpace) /1024/1024
  $Result
} | sort Server, Share | ft

Open in new window

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
A procedure for exporting installed hotfix details of remote computers using powershell
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

738 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