Tag Archives: VBScript

PowerShell Messagebox

messageboxRecently I posted an article explaining how to create a popup box in PowerShell using the Wscript.Shell COM object from our VBScript days. That was something I presented at the PowerShell Summit. Another option is a MessageBox, again like we used to use in VBScript. This works very much like the popup except the user has to click a button to dismiss the box. I can’t think of a compelling reason why you would choose one technique over the other if you need the user to click something. But I’ll let you make that call. Here’s the function, New-Messagebox.

Most of the function is a wrapper around this line:

Like the popup function, I wanted to make it easier to create a messagebox without having to remember the names for buttons and icons so I use validation sets with my parameters. This makes it much easier to create a command like this in your script:

In the version I presented at the PowerShell Summit, the function did not write anything to the pipeline unless you used -Passthru. After thinking about it more, I realized the whole reason you are likely to use a MessageBox is to capture an interaction so I flipped the parameter and now it is -NoPassthru. Now, when the user clicks a button, the text value of that button is automatically written to the pipeline. If you include -NoPassthru you’ll get nothing. Here’s an example:

messagebox2

Because the messagebox writes text to the pipeline, it is a little easier to use than the Popup technique where you have to decode an integer value. In any event, you now have some options.

If you find this useful, I hope you’ll let me know.

Friday Fun – Snappy Shortcuts

In one of my recent Prof. PowerShell columns, I wrote about using the Wscript.Shell VBScript object in PowerShell to retrieve special folder paths. Another handy trick is the ability to create shortcut links to either file or web resources. Let me show you how to accomplish this in PowerShell and why you might want to. Continue reading

This Old Script

Iโ€™m very slowly revising my main web site. The upshot for now is that there is no direct link to my old script library. Many of my Mr. Roboto tools can be found on this page. Until I can finish the upgrade project, you can use this link, http://www.jdhitsolutions.com/scripts.htm to take you directly to the old page.  Enjoy.

TechEd 2010 VBScript to PowerShell

Last week I posted my demo slides as well as my demo videos. As promised, I’ve gone through and expanded a bit on my original slide deck.ย  TechEdNA-2010-Hicks-ParadigmShift is a 3MB PDF of my expanded PowerPoint slide deck. If you have any questions about the content or what it takes to get your head from the world of VBScript to Windows PowerShell, please let me know.ย  I hope you find this useful. Enjoy.

Microsoft TechEd NOLA

Print Iโ€™m very excited about Microsoft TechEd next week in New Orleans, LA. Iโ€™ll be presenting Tuesday afternoon at 1:30PM. The official title is โ€œParadigm Shift: Microsoft Visual Basic Scripting Edition to Windows PowerShellโ€. In more practical terms, Iโ€™ll be talking about the necessary mind shift in moving from VBScript to PowerShell. Iโ€™ll talk about what you have to get your head around to successfully make the transition and provide some practical examples to demonstrate how you might make these changes. As with many of my talks, you can expect a lot of demos.

Other than that, Iโ€™ll be in the Windows Server booth (TLC/Red/WSV) throughout the week.

Monday, June 7 10:30 AM – 12:30 PM

Tuesday, June 8 10:30 AM – 12:30 PM, 2:45 PM โ€“ 5:00 PM

Wednesday, June 9 10:30 AM – 3:00 PM

Thursday, June 10 12:15 PM – 3:00 PM

I hope youโ€™ll come by and at least say Hi. Or feel free to pick my brain.  If you have books youโ€™d like signed, Iโ€™m happy to do that as well. Iโ€™ll be pretty active with FourSquare and Twitter if none of these times work for you.

See you next week.

Laissez les bon temps rouler!

My Published Works

I’m trying out a new Live Write plugin for Amazon. Here is a list of books I have currently authored or co-authored. This list will continue to grow as I’m working on a new book now about managing Active Directory with PowerShell.

WSH and VBScript Core: TFM
by Jeffery Hicks

Read more about this book…

Windows PowerShell v1.0: TFM, 2nd Edition
by Don Jones, Jeffery Hicks

Read more about this book…

Advanced VBScript for Microsoft Windows Administrators (Pro Other)
by Don Jones, Jeffery Hicks

Read more about this book…

I hope you’ll check them out.

Technorati Tags: , , , ,


Share this post :

Updated Group Reporter

A few of my recent Mr. Roboto columns have been about group auditing. I first published an HTA that would report on group membership last December. Astute reader Matt V. found a bug with the way nested group memberships were being reported. Or in this case, not being reported. It turns out that if a group was a member of one other group, that membership was not reported. But if the group was nested in 2 or more groups then you’d see all the nested groups. After a little debugging I found my goof. I used ADSI to get a reference to the specified group:

strDN would have a value like CN=Sales,OU=Groups,DC=Mycompany,DC=local. My mistake was in assuming that the MemberOf property would always be a collection so I was using a ForEach construct. But it is only a collection if there is more than one group. So I modified the code:

Because I used the same code in a followup article where I released a command line version of the tool, I had to modify that tool as well. The above code snippet is actually from the WSF version.

Anyway, both versions have now been updated and are available for download from the Mr. Roboto section of my script library. Thank you Matt for keeping me on my toes.

Technorati Tags: , , , ,