Get Folder Sizes from 2 locations and add the total

Welcome Forums General PowerShell Q&A Get Folder Sizes from 2 locations and add the total

Viewing 3 reply threads
  • Author
    Posts
    • #253820
      Participant
      Topics: 2
      Replies: 2
      Points: 14
      Rank: Member

      I run a month end billing process requiring me to look at  folder A on drive d:  and folder A on drive e:  – I have to do a properties on each to get each size and then add them together for a total data size for customer A.  Then I repeat this for customer B, C D  ect.

      Is there a way to do this using PS that would make the process easier.. ??

    • #253859
      Senior Moderator
      Topics: 10
      Replies: 168
      Points: 899
      Helping Hand
      Rank: Major Contributor

      Yes, you will need to map the drives with New-PSDrive and then you will be able to gather data on them with PowerShell. With a little loop logic and some arithmetic you should be able to do this reliably on as many different systems as you need to.

    • #253865
      Participant
      Topics: 2
      Replies: 2
      Points: 14
      Rank: Member

      ANSWER:

      • This reply was modified 3 weeks, 3 days ago by kvprasoon. Reason: code formating
    • #254096
      Participant
      Topics: 0
      Replies: 1
      Points: 5
      Rank: Member

      Hello.

      I am new to the forum but not new to powershell.  I see so many admins try and ‘out-think’ what powershell needs to do.  What Bruce Payette envisioned when he led the team at MS and developed PS, he envisioned a modular, expandable scripting environment.

      When getting info about folder sizes, one does not need 36 lines of code.  This is a one-liner.  The only trick is understanding the extensibility of powershell.  All you have to do is go to the powershell gallery and install PSScripttools by Jeff Hicks.  Simple.  You then will have an easy way to make this a one-liner.

      Here is an example of how easy getting folder size info is.  Run the following on your my documents folder AFTER installing PSScriptTools by Jeff Hicks:

      get-childitem . -Directory | Get-FolderSizeInfo | ft -View mb

      PowerShell is supposed to make our lives easier- not a throwback to complex VB scripting…

      gb

Viewing 3 reply threads
  • You must be logged in to reply to this topic.