{"id":52623,"date":"2009-08-25T03:01:00","date_gmt":"2009-08-25T03:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2009\/08\/25\/hey-scripting-guy-can-you-translate-this-vbscript-to-windows-powershell\/"},"modified":"2009-08-25T03:01:00","modified_gmt":"2009-08-25T03:01:00","slug":"hey-scripting-guy-can-you-translate-this-vbscript-to-windows-powershell","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-can-you-translate-this-vbscript-to-windows-powershell\/","title":{"rendered":"Hey, Scripting Guy! Can You Translate This VBScript to Windows PowerShell?"},"content":{"rendered":"<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\"><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"><\/p>\n<p class=\"MsoNormal\">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&#8217;s profile. It is in VBScript. Can you translate it to Windows PowerShell for me?<\/p>\n<\/p>\n<p class=\"MsoNormal\">&#8212; AW<\/p>\n<p class=\"MsoNormal\">\n<p><span><img decoding=\"async\" class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><\/span><\/p>\n<\/p>\n<p class=\"MsoNormal\">Hello AW, <\/p>\n<p class=\"MsoNormal\">Microsoft Scripting Guy Ed Wilson here. It is early morning. I am listing to <a href=\"http:\/\/en.wikipedia.org\/wiki\/Luciano_Pavarotti\"><font face=\"Segoe\">Luciano Pavarotti<\/font><\/a> on my Zune as he sings Lunge da Lei from <a href=\"http:\/\/en.wikipedia.org\/wiki\/La_traviata\"><font face=\"Segoe\">Verdi&#8217;s La Traviata<\/font><\/a>, and I&rsquo;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. <\/p>\n<p class=\"MsoNormal\">I love our new Script Gallery&mdash;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! <\/p>\n<p class=\"MsoNormal\">AW, you found the <a href=\"http:\/\/bit.ly\/ZSK3q\"><font face=\"Segoe\">List Items in the User Profile Folder<\/font><\/a>, which is seen here. <\/p>\n<p class=\"CodeBlockScreenedHead\"><strong>ListItemsInTheUserProfileFolder.vbs<\/p>\n<p><\/strong><\/p>\n<p class=\"CodeBlockScreened\"><span><font><font face=\"Lucida Sans Typewriter\">Const USER_PROFILE = &amp;H28&amp;<\/p>\n<p>Set objShell = CreateObject(&#8220;Shell.Application&#8221;)<br>Set objFolder = objShell.NameSpace(USER_PROFILE)<br>Set objFolderItem = objFolder.Self<br>Wscript.Echo objFolderItem.Path<\/p>\n<p>Set colItems = objFolder.Items<br>For Each objItem in colItems<br><span>&nbsp;&nbsp;&nbsp; <\/span>Wscript.Echo objItem.Name<br>Next<\/p>\n<p><\/font><\/font><\/span><\/p>\n<p class=\"MsoNormal\">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 <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb774096(VS.85).aspx\"><font face=\"Segoe\">MSDN<\/font><\/a>. <\/p>\n<p class=\"TableNum-Title\"><strong>Table 1&emsp;Shell special folder values<\/p>\n<p><\/strong><\/p>\n<table class=\"MsoTableGrid\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableHead\"><strong>Special Folder name<\/p>\n<p><\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableHead\"><b>Hexadecimal value<\/p>\n<p><\/b><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">ALTSTARTUP <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x1d<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">APPDATA <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x1a<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">BITBUCKET <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0xa<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">COMMONALTSTARTUP <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x1e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">COMMONAPPDATA <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x23<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">COMMONDESKTOPDIR <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x19<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">COMMONFAVORITES <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x1f<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">COMMONPROGRAMS <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x17<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">COMMONSTARTMENU <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x16<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">COMMONSTARTUP <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x18<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">CONTROLS <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x3<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">COOKIES <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x21<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">DESKTOP <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x0<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">DESKTOPDIRECTORY <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x10<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">DRIVES <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x11<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">FAVORITES <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x6<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">FONTS <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x14<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">HISTORY <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x22<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">INTERNETCACHE <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x20<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">LOCALAPPDATA <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x1c<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">MYPICTURES <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x27<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">NETHOOD <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x13<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">NETWORK <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x12<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">PERSONAL <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x5<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">PRINTERS <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x4<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"342\">\n<p class=\"TableText\">PRINTHOOD <\/p>\n<\/td>\n<td valign=\"top\" width=\"258\">\n<p class=\"TableText\">0x1b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; 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&#8217;s profile. It is in VBScript. Can you translate it to Windows PowerShell for me? &#8212; AW Hello AW, Microsoft Scripting Guy [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[16,3,4,707,5,155,45],"class_list":["post-52623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-desktop-management","tag-scripting-guy","tag-scripting-techniques","tag-shell-application","tag-vbscript","tag-vbscript-migration","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>&nbsp; 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&#8217;s profile. It is in VBScript. Can you translate it to Windows PowerShell for me? &#8212; AW Hello AW, Microsoft Scripting Guy [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/52623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=52623"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/52623\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=52623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=52623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=52623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}