You can reuse VBS code inside your PowerShell scripts. The key is the MSScriptControl COM object that is designed to act as a script host. Within a PowerShell script, you can use this object to embed VBS code, e.g. load VBS code, call a function from it, pass arguments to it, and get its return values. Sounds cool? It is! And it's not that difficult as well.
The attached function - Load-VbsCode - passes VBS code to MSScriptControl and returns a code object with methods that represent the functions defined within the VBS code.
Let's say you have a VBS file ConvertFunctions.vbs that, among others, contains this function:
Function Celsius(GradF)
Celsius = (GradF - 32) * 5 / 9
End Function
The following example shows how to use the Load-VbsCode function in order to embed the above vbs code:
# pass the entire vbs file to Load-VbsCode
$vbs = Load-VbsCode $(Get-Content .\ConvertFunctions.vbs)
# Ready to use the Celsius function...
$f = 70
$c = $vbs.Celsius($f)
Write-Host "$f Fahrenheit are $c Celsius."