?
Solved

Powershell Network Share Info

Posted on 2013-06-05
3
Medium Priority
?
286 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

801 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