Hi,
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.
Here is the script : http://gallery.technet.microsoft.com/scriptcenter/Delete-OST-from-User-App-22df1c88
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.
See the default value of $Env:LocalAppData data and the output of $OstPath when we added "Microsoft" and "Outlook" in to it.
$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.
$ost | remove-Item -WhatIf
and this will remove the OST files :)
Download the script from here : http://gallery.technet.microsoft.com/scriptcenter/Delete-OST-from-User-App-22df1c88
Simple isn't:)
Note: I tested this script on Windows7 with Outlook 2010 installed.
Thanks
Aman Dhally
Aman, Would there be a way to do for all users on a computer?
ReplyDeleteHi Mac,
DeleteHow 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"
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.
ReplyDeleteAman, 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.
ReplyDelete