Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Re: find pst files

Reply
 
Old 01-04-2008   #1 (permalink)
Shay Levi


 
 

Re: find pst files


To run PowerShell login scripts, all workstations should have PowerShell
installed. Is that the case in
your environment?

-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> that's interesting, now tell me how would you proceed to setup a ps
> logon script?
>
> --Ilann
>
> "Shay Levi" <no@xxxxxx> wrote in message
> news:8766a944170c98ca1ce1abd67e1a@xxxxxx
>
Quote:

>> This one too:
>> Locate PST Files on Remote Workstations
>> https://blogs.pointbridge.com/Blogs/...osts/Post.aspx
>> ?ID=57
>> -----
>> Shay Levi
>> $cript Fanatic
>> http://scriptolog.blogspot.com
>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
Quote:

>>> you said these values also appear in the registry, would it be
>>> possible to
>>> connect to the remote computer registry? if not, is there a way to
>>> accomplish that?
>>> get-child-item would work but browsing hd content remotely takes a
>>> while,
>>> thank you
>>> --Ilann
>>>
>>> "Shay Levi" <no@xxxxxx> wrote in message
>>> news:8766a944169c38ca1bae2820b98e@xxxxxx
>>>> You can't. it's a client side script.
>>>>
>>>> -----
>>>> Shay Levi
>>>> $cript Fanatic
>>>> http://scriptolog.blogspot.com
>>>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
>>>>> I changed it a little bit:
>>>>>
>>>>> $outlook = new-object -com outlook.application
>>>>> $ns = $outlook.GetNameSpace("MAPI")
>>>>> $ns.folders | foreach {
>>>>> $store = $_.storeid
>>>>> $len=$store.length-2
>>>>> $file=""
>>>>> trap{continue}
>>>>> for($i=0;$i -lt $len ;$i+=2)
>>>>> {
>>>>> $hex = $store.substring($i,2)
>>>>> if($hex -ne "00") {
>>>>> $tmp = [char][convert]::ToInt16($hex,16)
>>>>> $tmp2 = [char]$tmp
>>>>> $file+= $tmp2
>>>>> }
>>>>> }
>>>>> $file.substring($file.IndexOf(':\')-1)
>>>>> }
>>>>> [void][System.Runtime.Interopservices.Marshal]::ReleaseComObject($
>>>>> ou tl ook)
>>>>>
>>>>> now how can I execute this script on remote machines?
>>>>>
>>>>> --Ilann
>>>>>
>>>>> "ilann" <ilann@xxxxxx> wrote in message
>>>>> news:%23eyHlWWTIHA.4768@xxxxxx
>>>>>> does this work for you?
>>>>>>
>>>>>> --Ilann
>>>>>> "Shay Levi" <no@xxxxxx> wrote in message
>>>>>> news:8766a944168b28ca1b859f82374c@xxxxxx
>>>>>>> Here you go
>>>>>>>
>>>>>>> $outlook = new-object -com outlook.application
>>>>>>> $ns = $outlook.GetNameSpace("MAPI")
>>>>>>> $ns.folders | foreach {
>>>>>>> $store = $_.storeid
>>>>>>> $len=$store.length-2
>>>>>>> $file=""
>>>>>>> trap{continue}
>>>>>>> for($i=0;$i -lt $len ;$i+=2)
>>>>>>> {
>>>>>>> $hex = $store.substring($i,2)
>>>>>>> if($hex -ne "00") {
>>>>>>> $file+= [char][convert]::ToInt16($hex,16) } }
>>>>>>> $file.substring($file.IndexOf(':\')-1)
>>>>>>> }
>>>>>>> [void][System.Runtime.Interopservices.Marshal]::ReleaseComObject
>>>>>>> ($
>>>>>>> ou
>>>>>>> tlook)
>>>>>>> -----
>>>>>>> Shay Levi
>>>>>>> $cript Fanatic
>>>>>>> http://scriptolog.blogspot.com
>>>>>>> Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
>>>>>>>> this works perfect, let me know once you have PS version,
>>>>>>>>
>>>>>>>> thanks again
>>>>>>>>
>>>>>>>> --Ilann
>>>>>>>>
>>>>>>>> "Shay Levi" <no@xxxxxx> wrote in message
>>>>>>>> news:8766a9441681b8ca1b71241b4f80@xxxxxx
>>>>>>>>> Try to run this, haven't got the time yet to convert it to
>>>>>>>>> powershell:
>>>>>>>>>
>>>>>>>>> set oshell = createobject("wscript.shell")
>>>>>>>>> profileName="DefaultProfile"
>>>>>>>>> regKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows
>>>>>>>>> NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" &
>>>>>>>>> profileName
>>>>>>>>> mailboxName = oShell.RegRead(regKey)
>>>>>>>>> 'msgbox mailboxName
>>>>>>>>> Set outlook = WScript.CreateObject("Outlook.Application") Set
>>>>>>>>> ns
>>>>>>>>> =
>>>>>>>>> outlook.GetNamespace("MAPI")
>>>>>>>>> ns.Logon mailboxName,,True,True
>>>>>>>>> ' For each folder in the Profile
>>>>>>>>> For Each vStore In ns.Folders
>>>>>>>>> pos = InStr(1,HextoAsc(vStore.storeid),"\")
>>>>>>>>> If pos <> "0" then
>>>>>>>>> pst = Mid (HexToAsc(vStore.storeid),pos -2)
>>>>>>>>> wscript.echo "PSTNAME = " & vStore.name & " PSTPATH = " & pst
>>>>>>>>> Else
>>>>>>>>> End If
>>>>>>>>> Next
>>>>>>>>> Function HexToAsc(vhstr)
>>>>>>>>> Dim vX Dim vNstr Dim vHexstr For vX = 1 To Len(vhstr) Step 2
>>>>>>>>> If Mid(vhstr, vX, 2) = "00" then Else
>>>>>>>>> vnstr = vNstr & Chr("&H" & Mid(vhstr, vx, 2))
>>>>>>>>> End If
>>>>>>>>> Next
>>>>>>>>> HexToAsc = vNstr
>>>>>>>>> End Function
>>>>>>>>> -----
>>>>>>>>> Shay Levi
>>>>>>>>> $cript Fanatic
>>>>>>>>> http://scriptolog.blogspot.com
>>>>>>>>> Hebrew weblog:
>>>>>>>>> http://blogs.microsoft.co.il/blogs/scriptfanatic
>>>>>>>>>> 2003.
>>>>>>>>>>
>>>>>>>>>> any way to decode the binary values?
>>>>>>>>>>
>>>>>>>>>> --Ilann
>>>>>>>>>> "Shay Levi" <no@xxxxxx> wrote in message
>>>>>>>>>> news:8766a944167ee8ca1b68838cb944@xxxxxx
>>>>>>>>>>> What Outlook version? I'd just checked it on another user's
>>>>>>>>>>> Outlook (2007), Works fine, no warnings.
>>>>>>>>>>>
>>>>>>>>>>> On 2003 there's a problem. I'll check it.
>>>>>>>>>>> As for the registry values, they are stored under:
>>>>>>>>>>> HKEY_CURRENT_USER\Software\Microsoft\Windows
>>>>>>>>>>> NT\CurrentVersion\Windows
>>>>>>>>>>> Messaging Subsystem\Profiles\<ProfileName>
>>>>>>>>>>> But they are unreadable, values are in Binary.
>>>>>>>>>>> -----
>>>>>>>>>>> Shay Levi
>>>>>>>>>>> $cript Fanatic
>>>>>>>>>>> http://scriptolog.blogspot.com
>>>>>>>>>>> Hebrew weblog:
>>>>>>>>>>> http://blogs.microsoft.co.il/blogs/scriptfanatic
>>>>>>>>>>>> yes I do, what about registry? do you know if the paths are
>>>>>>>>>>>> stored somewhere in the registry?
>>>>>>>>>>>>
>>>>>>>>>>>> thanks a lot for all your help!
>>>>>>>>>>>>
>>>>>>>>>>>> --Ilann
>>>>>>>>>>>> "Shay Levi" <no@xxxxxx> wrote in message
>>>>>>>>>>>> news:8766a944167e38ca1b658a6f862c@xxxxxx
>>>>>>>>>>>>> Do you have any PST files attached?
>>>>>>>>>>>>> As for the security dialog, I should check it on another
>>>>>>>>>>>>> computer
>>>>>>>>>>>>> since my
>>>>>>>>>>>>> outlook's VbaProject.OTM
>>>>>>>>>>>>> is digitally signed.
>>>>>>>>>>>>> -----
>>>>>>>>>>>>> Shay Levi
>>>>>>>>>>>>> $cript Fanatic
>>>>>>>>>>>>> http://scriptolog.blogspot.com
>>>>>>>>>>>>> Hebrew weblog:
>>>>>>>>>>>>> http://blogs.microsoft.co.il/blogs/scriptfanatic
>>>>>>>>>>>>>> the $ns.stores is a null array in my case, any idea?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --Ilann
>>>>>>>>>>>>>> "Shay Levi" <no@xxxxxx> wrote in message
>>>>>>>>>>>>>> news:8766a944167d08ca1b5f15fb0e16@xxxxxx
>>>>>>>>>>>>>>> BEWARE: this way, the copy will perform from the remote
>>>>>>>>>>>>>>> computer,
>>>>>>>>>>>>>>> through
>>>>>>>>>>>>>>> YOUR computer to the destination.
>>>>>>>>>>>>>>> What if the user reboots in the middle of your
>>>>>>>>>>>>>>> operation?
>>>>>>>>>>>>>>> As I previously suggested, this kind of activity should
>>>>>>>>>>>>>>> be
>>>>>>>>>>>>>>> performed
>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>> the user knowledge, I
>>>>>>>>>>>>>>> bet you don't want to end up with corrupted files.
>>>>>>>>>>>>>>> I did some testings on Outlook. You can get all personal
>>>>>>>>>>>>>>> storage
>>>>>>>>>>>>>>> file
>>>>>>>>>>>>>>> paths for a user (PST,OST) if you run
>>>>>>>>>>>>>>> this code when the user's Outlook is open:
>>>>>>>>>>>>>>> PS > $outlook = new-object -com outlook.application;
>>>>>>>>>>>>>>> PS > $ns = $outlook.getNameSpace("MAPI");
>>>>>>>>>>>>>>> PS > $ns.stores | foreach { if($_.filepath)
>>>>>>>>>>>>>>> {$_.filepath}
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>> C:\Documents and Settings\ShayL\Local
>>>>>>>>>>>>>>> Settings\Application
>>>>>>>>>>>>>>> Data\Microsoft\Outlook\outlook0.ost
>>>>>>>>>>>>>>> D:\Mail\Test1.pst
>>>>>>>>>>>>>>> D:\Mail\Test2.pst
>>>>>>>>>>>>>>> HTH
>>>>>>>>>>>>>>> -----
>>>>>>>>>>>>>>> Shay Levi
>>>>>>>>>>>>>>> $cript Fanatic
>>>>>>>>>>>>>>> http://scriptolog.blogspot.com
>>>>>>>>>>>>>>> Hebrew weblog:
>>>>>>>>>>>>>>> http://blogs.microsoft.co.il/blogs/scriptfanatic
>>>>>>>>>>>>>>>> what if I want to run the script from my computer, can
>>>>>>>>>>>>>>>> I access user's HD remotely? can I run a script against
>>>>>>>>>>>>>>>> another box?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --Ilann
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> "Shay Levi" <no@xxxxxx> wrote in message
>>>>>>>>>>>>>>>> news:8766a94415c0d8ca16f1de2322b0@xxxxxx
>>>>>>>>>>>>>>>>> Dependeing on the PST file size the user might be
>>>>>>>>>>>>>>>>> *never*
>>>>>>>>>>>>>>>>> logged
>>>>>>>>>>>>>>>>> off
>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>> might brutally turn off the computer thinking its
>>>>>>>>>>>>>>>>> hanged.
>>>>>>>>>>>>>>>>> This kind of activity must be known by the user and
>>>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>>>> his
>>>>>>>>>>>>>>>>> permission,
>>>>>>>>>>>>>>>>> unless the computer stays powered on and you are
>>>>>>>>>>>>>>>>> executing
>>>>>>>>>>>>>>>>> the script over night. Even so, if the user left
>>>>>>>>>>>>>>>>> Outlook
>>>>>>>>>>>>>>>>> open
>>>>>>>>>>>>>>>>> you'll
>>>>>>>>>>>>>>>>> have
>>>>>>>>>>>>>>>>> to kill the process to free the PST file(s).
>>>>>>>>>>>>>>>>> How many users do you have?
>>>>>>>>>>>>>>>>> Consider notifying the users by mail that such
>>>>>>>>>>>>>>>>> activity
>>>>>>>>>>>>>>>>> is
>>>>>>>>>>>>>>>>> going
>>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>> happend (few days before), you can write a script to
>>>>>>>>>>>>>>>>> launch
>>>>>>>>>>>>>>>>> a GUI windows with a warning that the process is about
>>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>> begin
>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>> ask
>>>>>>>>>>>>>>>>> the user to close outlook.
>>>>>>>>>>>>>>>>> -----
>>>>>>>>>>>>>>>>> Shay Levi
>>>>>>>>>>>>>>>>> $cript Fanatic
>>>>>>>>>>>>>>>>> http://scriptolog.blogspot.com
>>>>>>>>>>>>>>>>> Hebrew weblog:
>>>>>>>>>>>>>>>>> http://blogs.microsoft.co.il/blogs/scriptfanatic
>>>>>>>>>>>>>>>>>> I tried and it fails, then I guess the only solution
>>>>>>>>>>>>>>>>>> is a log off script.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> please help
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> --Ilann
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> "Shay Levi" <no@xxxxxx> wrote in message
>>>>>>>>>>>>>>>>>> news:8766a94415b9e8ca16db65deb3de@xxxxxx
>>>>>>>>>>>>>>>>>> ..
>>>>>>>>>>>>>>>>>>> I think the copy will fail. the best way to know for
>>>>>>>>>>>>>>>>>>> sure is to create a PST on your local computer,
>>>>>>>>>>>>>>>>>>> attach it to your outlook while it's open, copy some
>>>>>>>>>>>>>>>>>>> messages to it and then try to copy it.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> -----
>>>>>>>>>>>>>>>>>>> Shay Levi
>>>>>>>>>>>>>>>>>>> $cript Fanatic
>>>>>>>>>>>>>>>>>>> http://scriptolog.blogspot.com
>>>>>>>>>>>>>>>>>>> Hebrew weblog:
>>>>>>>>>>>>>>>>>>> http://blogs.microsoft.co.il/blogs/scriptfanatic
>>>>>>>>>>>>>>>>>>>> thank you Shay,
>>>>>>>>>>>>>>>>>>>> thanks for the advice.
>>>>>>>>>>>>>>>>>>>> what if the file is in use by outlook? is there a
>>>>>>>>>>>>>>>>>>>> way
>>>>>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>>>>> force
>>>>>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>>>> copy?
>>>>>>>>>>>>>>>>>>>> --Ilann
>>>>>>>>>>>>>>>>>>>> "Shay Levi" <no@xxxxxx> wrote in message
>>>>>>>>>>>>>>>>>>>> news:8766a94415b688ca16d4f167d96e@xxxxxx
>>>>>>>>>>>>>>>>>>>> m.
>>>>>>>>>>>>>>>>>>>> ..
>>>>>>>>>>>>>>>>>>>>> Hi Ilann,
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> If I were you I would create a folder for each
>>>>>>>>>>>>>>>>>>>>> user on the destination folder to avoid
>>>>>>>>>>>>>>>>>>>>> overwriting PST files of other users that share
>>>>>>>>>>>>>>>>>>>>> the same name, as in archive.pst.
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Make sure the user running the script has write
>>>>>>>>>>>>>>>>>>>>> permmision on the destination folder. Also make
>>>>>>>>>>>>>>>>>>>>> sure the files are not in use by outlook. Another
>>>>>>>>>>>>>>>>>>>>> issue is if the move operation wasn't successful,
>>>>>>>>>>>>>>>>>>>>> the PST file can get corrupted. I think it is
>>>>>>>>>>>>>>>>>>>>> better to copy the file first and if no error
>>>>>>>>>>>>>>>>>>>>> occured delete the local one.
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Note, consider searching for OST files if you're
>>>>>>>>>>>>>>>>>>>>> users use Outlook in Cache Exchange Mode.
>>>>>>>>>>>>>>>>>>>>> $user = $env:username
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> get-childitem c:\ *.pst -rec | foreach { # the
>>>>>>>>>>>>>>>>>>>>> -force
>>>>>>>>>>>>>>>>>>>>> creates
>>>>>>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>>>>> user
>>>>>>>>>>>>>>>>>>>>> destination folder on the fly if it doesn't exist
>>>>>>>>>>>>>>>>>>>>> # remove -whatif on production
>>>>>>>>>>>>>>>>>>>>> copy-item $_ -destination \\server\folder\$user
>>>>>>>>>>>>>>>>>>>>> -force
>>>>>>>>>>>>>>>>>>>>> -whatif
>>>>>>>>>>>>>>>>>>>>> #
>>>>>>>>>>>>>>>>>>>>> if
>>>>>>>>>>>>>>>>>>>>> no
>>>>>>>>>>>>>>>>>>>>> error occured
>>>>>>>>>>>>>>>>>>>>> if($?) { # consider not removing the files for few
>>>>>>>>>>>>>>>>>>>>> days
>>>>>>>>>>>>>>>>>>>>> just
>>>>>>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>>>>>> make
>>>>>>>>>>>>>>>>>>>>> sure nothing went wrong.
>>>>>>>>>>>>>>>>>>>>> # you can always run the script again and delete
>>>>>>>>>>>>>>>>>>>>> the
>>>>>>>>>>>>>>>>>>>>> files.
>>>>>>>>>>>>>>>>>>>>> remove-item $_ -force -whatif } else { write host
>>>>>>>>>>>>>>>>>>>>> "error
>>>>>>>>>>>>>>>>>>>>> file
>>>>>>>>>>>>>>>>>>>>> copy:
>>>>>>>>>>>>>>>>>>>>> $($_.fullname)"
>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>>>>>>> -----
>>>>>>>>>>>>>>>>>>>>> Shay Levi
>>>>>>>>>>>>>>>>>>>>> $cript Fanatic
>>>>>>>>>>>>>>>>>>>>> http://scriptolog.blogspot.com
>>>>>>>>>>>>>>>>>>>>> Hebrew weblog:
>>>>>>>>>>>>>>>>>>>>> http://blogs.microsoft.co.il/blogs/scriptfanatic
>>>>>>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> I need to find pst files on all desktops and move
>>>>>>>>>>>>>>>>>>>>>> those files on a fileserver. how could I do that
>>>>>>>>>>>>>>>>>>>>>> via a script?
>>>>>>>>>>>>>>>>>>>>>> --Ilann
>>>>>>>>>>>>>>>>>>>>>>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Cannot find files? Vista file management
cant find the jpeg files in my temp internet files Vista file management
where are the files? i need to find them Vista mail
Re: find pst files PowerShell
Search for files and folders doesn't find system files Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46