Calling PowerShell from VBScript

by May 29, 2009

Maybe you are happy with other scripting languages, like VBScript, and would like to stick to that for awhile. Still, you’d like to enhance your scripts with PowerShell functionality.

To call a PowerShell script from another scripting language like VBScript, you should make sure you add the following command to launch the PowerShell script:

powershell.exe -noprofile -command “Path to .PS1 script file”

This is necessary because .ps1 files are by default not associated with powershell.exe. The parameter -noprofile skips your PowerShell profiles, which increases startup time and decreases memory footprint. Omit -noprofile only if you load important things in your profiles that your script depends on, such as loading additional snap-ins.