Tuesday, February 14, 2012

Delete Offline OST files from login users account using PowerShell.


Yesterday I was surfing the TECHNET Script repository and see that one user is requested for a script which can delete offline email file {ost} from login users.

This seems simple to me and I wrote a 3line script which can accomplish this task.

1.  $OstPath = $Env:LocalAppData + "\Microsoft" + "\Outlook"
2.  $ost = get-ChildItem $OstPath | where { $_.Extension -eq ".ost"} 
3.  $ost | remove-Item -WhatIf ## remove -whatif to remove the files 

1.    In windows7 and with outlook 2010 installed the OST file are created in “C:\Users\USERNAME\AppData\Local\Microsoft\Outlook” folder. The $Env:LocalAppData windows environment variable contain the path of “C:\Users\aman.dhally\AppData\Local” and we added “\Microsoft” and “\Outlook” to make the complete path to the outlook folder.
2.    Secondly we are getting all files whose extension is equal .OST and saving the result in to the $ost variable
3.    Thirdly we are parsing the output of $ost to remove-Item to remove all files.


Below is the path of my OST files.

14-02-2012 12-08-29 

See the default value of  $Env:LocalAppData data and the output of $OstPath when we added "Microsoft" and "Outlook" in to it.

14-02-2012 12-11-07
$ost = get-ChildItem $OstPath | where { $_.Extension -eq ".ost"}  , and just see the output of $ost you can see that is is showing the name of all OST which we have in out outlook folder.

14-02-2012 12-13-31
$ost | remove-Item -WhatIf
and this will remove the OST files :)
14-02-2012 12-15-16

Simple isn't:)

Note: I tested this script on Windows7 with Outlook 2010 installed.

Aman Dhally


  1. Aman, Would there be a way to do for all users on a computer?

    1. Hi Mac,
      How to want to provide the usernames? because if we got all users profile name and use this with foreach then i think can be done

      $Ost = "C:\users" + "\username" + "\Appdata\Local\Outlook"

  2. ost recovery easily opens, recovers, moves your messages, contacts, notes, meetings, reminders, tasks and all other information. Software has easy to use, intuitive interface even for novices. Application starts under any Windows OS starting with Windows 98.

  3. Aman, This is a great little script to remove the files. However remember that if Outlook's data file settings are not set to "disable offline use" the OST files will be recreated every time the user opens outlook.

  4. This script helped me with an issue about deepfreze ad outlook. the mailbos is deleted daily, do i dont care about ost redownloading. thanks1


  5. parking permmits
    text message to tenants
    Cloud based parking management
    software for condominiums
    New Parking Software for Condominiums and Apartments:
    WEBPARKINGSOFTWARE.COM has a new product on the internet nowadays that can provide maximum satisfaction to all businessmen and vehicle owners who want to find the perfect parking area for their vehicles in a very convenient way especially while in the city. This powerful parking software is something that vehicle owners and businessmen can use in condominiums, apartments and other business establishments that were designed to accommodate several consumers or clients every day. It’s already available in the official website of the online company that has been stated.
    The software can be used by vehicle owners for free for a limited period of time only. It has been reinvented by the company to show to the world the most systematic and effective way of organizing and managing all parking areas that are available in licensed condominiums and apartments all over the country nowadays. People can easily use it with the use of their smart phones. Therefore, it was designed to make the process of providing a vehicle with an excellent parking area in outdoor places more convenient and much easier to accomplish. This product can help businessmen to experience all benefits that an excellent parking management method can provide.
    The new parking software for condominiums and apartments at WEBPARKINGSOFTWARE.COM will be very useful in the daily business operations of all businessmen who want to make sure that the parking areas in their business establishments will be managed perfectly every day even if their time for their additional tasks and relaxation is very limited. The product comes with a set of innovative features that can make parking management more convenient and full of satisfying results for all businessmen every day. This software can also assist a vehicle owner in securing an excellent parking area for a vehicle in one of the most popular condominiums or apartments in the country.
    The product is equipped with an advanced parking management system that’s highly compatible for all types of building sizes that can be found in the different parts of the country nowadays. It provides professional parking permit to all vehicle owners who will never hesitate to use it regularly. In addition to that, this software has an amazing ability to assign parking spaces for tenants. This software possesses everything that can make parking management more enjoyable and free from stressful moments every day. One of the things that people will surely appreciate in the design of this product is its amazing ability to detect ticket violators.
    The new parking software of WEBPARKINGSOFTWARE.COM will always be an excellent choice for all businessmen and vehicle owners who can’t afford to be victimized by the negative effects of stress and misunderstandings while aiming to have a better understanding of the idea of parking management. The product embodies an internet-based cloud model that makes it far better than any other brand of parking software that can be downloaded on the internet nowadays. One of its best advantages is the fact that it’s compatible for all brands of smart phones and modern electronic gadgets. This app has been created to make parking management a paperless procedure that can be accomplished in just few seconds.


  6. Nice blog , thanks for sharing this information with us.

    Web Design Austin

  7. I think that you need to check this info on how to write essay about world educational systems. This could be kinda helpful.

  8. Hello. After reading your article I understand that you are a clever person and maybe you can tell me what should a resume look like . I will appreciate your help.

  9. I tried to analyze the script. It took a few minutes to get what you wanted to write. By the way, check my first composition at the beach.

  10. Hello! Great post with lots of information! Thank you for sharing with us. By the way, if you need help with writing papers I recommend you to apply to this page There you can find a professional help.