Solved

Modifying Powershell script to get the size of the directory ?

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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 this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

770 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