Using VB.NET to Migrate From VBScript

by Jun 10, 2009

If you have ever written scripts using VBScript and now are trying to migrate them to PowerShell, you may miss a lot of useful commands not available in PowerShell. However, you can continue to use your favorites such as MsgBox() or InputBox()with a little trick. Simply load the VB.NET assembly that ships with .NET since it comes with almost all of your beloved VBScript commands:

[system.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') |
[Microsoft.VisualBasic.Interaction]::MsgBox("Isn't that cool?", 1+32, 'Survey')

Use Get-Member with the -static parameter to get a list of all the commands this .NET class provides:

[Microsoft.VisualBasic.Interaction] | Get-Member -static

Or try PowerShellPlus. It pops up code completion menus automatically.