Solved

Modifying Powershell script to get the size of the directory ?

Posted on 2016-09-27
2
68 Views
Last Modified: 2016-09-27
Hi,

Can anyone assist in modifying the below script so that it can also list the directory size ?
by combining this script from: https://technet.microsoft.com/en-us/library/ff730945.aspx

and this one to list Home folder from disabled user accounts.

$subFolderItems = (Get-ChildItem $i.FullName | Measure-Object -property length -sum)
$i.FullName + " -- " + "{0:N2}" -f ($subFolderItems.sum / 1MB) + " MB"

Open in new window


Get-ADUser -SearchBase "OU=Disabled USERS,OU=Main Office,DC=domain,DC=com" -F * -Pr HomeDirectory | ?{$_.HomeDirectory} | Select Name,HomeDirectory | Export-CSV C:\report.csv -nti

Open in new window


Get-ADUser -SearchBase "OU=Disabled USERS,OU=Main Office,DC=domain,DC=com" -F * -Pr HomeDirectory | ?{$_.HomeDirectory -match "^\\\\FileServerHQ\\Users"} | Select Name,HomeDirectory | Export-CSV C:\report.csv -nti

Open in new window


This is a continuation from this thread: https://www.experts-exchange.com/questions/28972587/Modifying-PowerShell-to-list-home-drives-of-disabled-users.html#a41817693

Thanks in advance.
0
Comment
[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
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41817787
Change
Select Name,HomeDirectory

Open in new window

to
Select Name,HomeDirectory,@{N="Size";E={"{0:N2}" -f ((Get-ChildItem $_.HomeDirectory -Recurse | Measure-Object -property length -sum).sum / 1MB) + " MB"}}

Open in new window

2
 
LVL 7

Author Closing Comment

by:Senior IT System Engineer
ID: 41819016
Thanks it works !
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Modify Permissions 19 66
DNS problems and now some PC can't connect to \\servername 14 46
Help to debug powershell script 5 44
add if statement powershell 8 25
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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