Link to home
Start Free TrialLog in
Avatar of KAKA JI
KAKA JI

asked on

Size of users home drive

Powershell Script to get Home Drive (Homedir) size for list of users in CSV file with only Samaccountname
Avatar of serialband
serialband
Flag of Ukraine image

Avatar of KAKA JI
KAKA JI

ASKER

Does not seems to work for ma mate

[PS] C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Exchange Server 2010>$Mailboxes = Get-Mailbox -ResultSize 20 foreach ($Mailbox in $Mailboxes) { $Mailbox | Add-Member -MemberType "NoteProperty" -Name "MailboxSizeMB" -Value ((Get-MailboxStatistics $Mailbox).TotalItemSize.Value.ToMb()) } $Mailboxes | Sort-Object MailboxSizeMB -Desc | Select DisplayName, Alias, PrimarySMTPAddress, MailboxSizeMB
in : Unexpected token 'in' in expression or statement.
    + CategoryInfo          : ParserError: (in:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
Try this:

foreach ($user in (Import-Csv .\ADUsers.csv)) {
    $folder = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirectory).HomeDirectory)
    $size = $folder.BaseName.Length
    [array]$results += New-Object -TypeName PSObject -Property @{
        sAMAccountName = $($user.samaccountname)
        HomeDirectory = $folder
        Size = $size
    }
}

$results | Export-Csv "$env:USERPROFILE\Desktop\HomeDirSizes.csv" -NoTypeInformation

Open in new window

Avatar of KAKA JI

ASKER

Hi Jason,

I am getting the following error.

[PS] C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Exchange Server 2010>foreach ($user in (Import-Csv C:\Spam\User.csv)) { $folder = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirectory).HomeDirectory) $size = $folder.BaseName.Length[array]$results += New-Object -TypeName PSObject -Property @{sAMAccountName = $($user.samaccountname)HomeDirectory = $folder Size = $size}}$results | Export-Csv "C:\Spam\HomeDirSizes.csv" -NoTypeInformation
[ : Missing or invalid array index expression.
    + CategoryInfo          : ParserError: ([:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingArrayIndexExpression
Avatar of KAKA JI

ASKER

Hi Jason,

Please see below

PS C:\Windows> foreach ($user in (Import-Csv C:\Spam\User.csv)) {
    $folder = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirectory).HomeDirectory)
    $size = $folder.BaseName.Length
    [array]$results += New-Object -TypeName PSObject -Property @{
        sAMAccountName = $($user.samaccountname)
        HomeDirectory = $folder
        Size = $size
    }
}

$results | Export-Csv "C:\Spam\HomeDirSizes.csv" -NoTypeInformation
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((Get-ADUser $user.samaccountname -Properties HomeDirecto ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
Are you running this script on your Domain Controller or on your workstation?  We can make either work but it would take a few tweaks.
Avatar of KAKA JI

ASKER

On my PC
The first script I provided should work on a Domain Controller after the ActiveDirectory module is imported into PowerShell.  However, if you did want to limit the script to your workstation, try this:

foreach ($user in (Import-Csv .\ADUsers.csv)) {
    $folder = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)").FindOne()).Properties.homedirectory)
    $size = $folder.BaseName.Length
    [array]$results += New-Object -TypeName PSObject -Property @{
        sAMAccountName = $($user.samaccountname)
        HomeDirectory = $folder
        Size = $size
    }
}

$results | Export-Csv "$env:USERPROFILE\Desktop\HomeDirSizes.csv" -NoTypeInformation

Open in new window

Avatar of KAKA JI

ASKER

Hi,

Still not working

PS C:\Windows> foreach ($user in (Import-Csv C:\spam\User.csv)) {
    $folder = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)").FindOne()).Properties.homedirectory)
    $size = $folder.BaseName.Length
    [array]$results += New-Object -TypeName PSObject -Property @{
        sAMAccountName = $($user.samaccountname)
        HomeDirectory = $folder
        Size = $size
    }
}

$results | Export-Csv "$env:USERPROFILE\Desktop\HomeDirSizes.csv" -NoTypeInformation
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At line:2 char:24
+ ...  = Get-Item ((([adsisearcher]"samaccountname=$($user.samaccountname)" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand
 

PS C:\Windows>
Does it have to be powershell?

Unix has du, and Systernals created du for Windows.  It's really much easier to use.
https://docs.microsoft.com/en-us/sysinternals/downloads/du
Does the account you're logged in with have permission to view the contents of each user's home directory?  This works fine on my workstation.
Avatar of KAKA JI

ASKER

Yes I am using my adm account
Avatar of KAKA JI

ASKER

Hi Serialband,

I have try that link but the application does not seem to work. I have also used tree size to get the same info.
https://www.jam-software.com/treesize_free/
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.