locked
How to clear unused OST's RRS feed

Answers

  • $_.LastWriteTime

    The dot goes after the underscore.  The variable is "$_".

    help about_pipelines


    \_(ツ)_/

    • Marked as answer by S.Hirani Monday, July 8, 2019 9:13 AM
    Monday, July 8, 2019 9:12 AM
  • You should be using -and inside the curly brackets:

    $ost = get-ChildItem $OstPath | where { $_.Extension -eq ".ost" -and $_.LastWriteTime -lt (Get-Date).AddDays(-5)}

    Also "$._LastWriteTime" this seems to be a typo. 
    • Edited by DumbleD0re Monday, July 8, 2019 9:13 AM
    • Marked as answer by S.Hirani Monday, July 8, 2019 9:13 AM
    Monday, July 8, 2019 9:12 AM

All replies

  • $_.LastWriteTime

    The dot goes after the underscore.  The variable is "$_".

    help about_pipelines


    \_(ツ)_/

    • Marked as answer by S.Hirani Monday, July 8, 2019 9:13 AM
    Monday, July 8, 2019 9:12 AM
  • You should be using -and inside the curly brackets:

    $ost = get-ChildItem $OstPath | where { $_.Extension -eq ".ost" -and $_.LastWriteTime -lt (Get-Date).AddDays(-5)}

    Also "$._LastWriteTime" this seems to be a typo. 
    • Edited by DumbleD0re Monday, July 8, 2019 9:13 AM
    • Marked as answer by S.Hirani Monday, July 8, 2019 9:13 AM
    Monday, July 8, 2019 9:12 AM
  • Thank you both. Got it working now.
    Monday, July 8, 2019 9:14 AM
  • The correct way to write this in PowerShell is like this:

    $ostPath = $Env:LocalAppData + '\Microsoft\Outlook\*.ost'
    Get-ChildItem $ostPath | 
        Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-5)} |
        Remove-Item

    There are a half dozen technical reasons why.

    Also beware that anyone who has been on a vacation will have their OST removed.  Are you sure you want to do this?


    \_(ツ)_/


    • Edited by jrv Monday, July 8, 2019 9:19 AM
    Monday, July 8, 2019 9:17 AM
  • Hi,

    That is the requirement from my IT manager.

    The 5 day stipulation is what he has asked. 

    Thanks again.

    Monday, July 8, 2019 10:02 AM
  • You better warn him of the issue. 


    \_(ツ)_/

    Monday, July 8, 2019 10:04 AM