locked
get-childitem -exclude problem RRS feed

  • Question

  • Hello!

    I have a little problem with my tiny ps script. I would like sum userprofile directory without Local Settings. I tried 2 way, but still i failed.

    $profile_dir = $env:USERPROFILE

    $profile_dir_localsettings = $profile_dir + "\Local Settings"

    1, Get-ChildItem $profile_dir -Exclude "Local Settings" -Force -Recurse | Measure-Object -Property length -sum

    2, Get-ChildItem $profile_dir -Exclude $profile_dir_localsettings -Force -Recurse | Measure-Object -Property length -sum

    What's the problem?


    • Edited by Arczatlan Monday, October 1, 2012 11:12 AM
    Monday, October 1, 2012 11:10 AM

Answers

  • Get-ChildItem $profile_dir -force -recurse | where {$_.fullname -notmatch [regex]::escape($profile_dir_localsettings)} | measure-
    object length -sum

    • Marked as answer by Arczatlan Monday, October 1, 2012 11:21 AM
    Monday, October 1, 2012 11:17 AM

All replies

  • Get-ChildItem $profile_dir -force -recurse | where {$_.fullname -notmatch [regex]::escape($profile_dir_localsettings)} | measure-
    object length -sum

    • Marked as answer by Arczatlan Monday, October 1, 2012 11:21 AM
    Monday, October 1, 2012 11:17 AM
  • thx the fast answer
    Monday, October 1, 2012 11:21 AM