Quantcast
Viewing all articles
Browse latest Browse all 21975

Should be something simple - Just not showing one property

I wrote a script to query AD and then work out the filesize of their homedirectory path in AD. 

It's currently not showing the users SamAccountName as requested.  It does however calculate the folder size value correctly.  I assume it's because I am using $_ rahter than $_Something.SamAccountName.  Does anyone know what value I should be using?

Get-ADUser -Filter * -Properties HomeDirectory | Where { $_.HomeDirectory -ne $null } | 
ForEach-Object {
Get-ChildItem ($_.HomeDirectory) -Recurse -ErrorAction SilentlyContinue | Measure-Object -property length -sum -ErrorAction SilentlyContinue | Select-Object @{N='UserName';E={$_.SamAccountName}}, @{N='Size (MB)';E={"{0:N2}" -f ($_.Sum / 1MB)}}
}

Many thanks.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>