Hey, Scripting Guy! Can You Translate This VBScript to Windows PowerShell?
Hey Scripting Guy! I am wondering about something. I was looking on the Script Center Script Gallery, and I came across a pretty cool script that lists items that are in the user’s profile. It is in VBScript. Can you translate it to Windows PowerShell for me?
Microsoft Scripting Guy Ed Wilson here. It is early morning. I am listing to Luciano Pavarotti on my Zune as he sings Lunge da Lei from Verdi’s La Traviata, and I’m sipping a cup of English Breakfast tea from my little blue tea pot the Scripting Wife bought me. The tea has a stick of real cinnamon in it, and I am munching on a freshly baked peach scone (peaches are in season in Charlotte, North Carolina, in the United States). Needless to say, I am in a good mood. Life is good. And I bought a new Microsoft keyboard the other day at the company store in Charlotte, so I am all set to answer your question.
I love our new Script Gallery—the search feature is cool, and the ability to filter scripts based upon the categories and scripting languages is sweet. The fact that you can directly upload scripts and not have to e-mail scripts to us and then wait for us to get around to publishing them is obviously another huge benefit. The rating, ranking, and discussion will turn out to be a big bonus as well. In short, as we used to say in Southern California, it rocks dude!
AW, you found the List Items in the User Profile Folder, which is seen here.
Const USER_PROFILE = &H28&
Set objShell = CreateObject(“Shell.Application”)
Set objFolder = objShell.NameSpace(USER_PROFILE)
Set objFolderItem = objFolder.Self
Set colItems = objFolder.Items
For Each objItem in colItems
The ListItemsInTheUserProfileFolder.vbs script begins by creating a constant, USER_PROFILE, and assigning hexadecimal 28 to it. A listing of shell folder constants is seen in Table 1; they are also documented on MSDN.
Table 1 Shell special folder values
Special Folder name