Learn about Windows PowerShell
Note: We are no longer accepting entries for this event. See the due dates page for a list of all event due dates.
About This Event
Date of Event
May 7, 2010
May 14, 2010
Your boss has given you a script written by a colleague that does not work. The script is supposed to display a dialog box that lists the current logged-on user as shown in the image below.
Unfortunately, the script does not work, and it does not generate any errors. The VBScript version of the script, and the Windows PowerShell version of the script are shown here.
On Error Resume Next
Set wmi = GetObject("winmgmts:")
colitems = wmi.Execquery("Select user from Win32_computersystem")
For Each item In colitem
$errorActionPreference = "silentlycontinue"
$wmi = Get-WmiObject -Class Win32_computerSystem -Property name
$wshShell = New-Object -ComObject wscript.shell
When your script runs properly, the following dialog box should be displayed.
2010 Scripting Games Links
2010 Scripting Games home page
Submit your scripts on PoshCode.org
2010 Scripting Games Forum
Support our sponsors!
Ed Wilson and Craig Liebendorfer, Scripting Guys