Solved

Modifying Powershell script to get the size of the directory ?

Posted on 2016-09-27
2
46 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
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

Join & Write a Comment

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

759 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

17 Experts available now in Live!

Get 1:1 Help Now