I’ve been using VBScript for a very long time. One drawback it has always had as a scripting language is an INCLUDE statement. In other languages you can use something like INCLUDE scriptfile at the beginning of the script. This would load any functions and variables in the specified script file into your current script. In PowerShell we can accomplish this by dot sourcing scripts. I never knew of a way to do the same thing with VBScript until now.
Category: Howto
Good, Better, Best
I’m very happy to see more and more people getting their hands dirty with Windows PowerShell. A common challenge I see across different support forums is getting information from one part of a script to another. Very often the user has created a function and is attempting to use its output elsewhere in their script. Often I can tell the scripter is coming from a VBScript background or at least thinking that way. There’s nothing necessarily wrong with writing a PowerShell script in a VBScript style, but these scripts are missing out. Let me walk you through several iterations of a function to demonstrate.
Registering PrimalPad as your default editor
Associating a file type with a specific application has always been fairly easy to do under the various incarnations of Windows. Basically, you can right-click on a file of the type you wish to use, select the Open With | Choose Program context menu option, then select the program like PrimalPad from the list or […]
Product Highlight – PrimalSQL and PrimalXML Example
In this blog, I will demonstrate how to use the features of PrimalSQL and PrimalXML to accomplish sample tasks. In this example, I will need to gather product information from a database and produce an XML file that will be used for offline processing. In addition, I would like to create a static drop down […]
Create A Remote File Share
This topic came up recently in the PowerShell forum at ScriptingAnswers.com and I thought you might find it helpful. The issue was creating a file share remotely. In the “olden days”, this would have meant using a command line tool like RMTSHARE, which is really just fine. But if you have a larger workflow, doing it natively in PowerShell may be more desirable.
Let me show you how easy it is to create a file share using Windows Management Instrumentation (WMI). I wrote a function called New-FileShare.
Hash Table Happiness
The other day I wrote an entry about using the Dictionary object in VBScript . I alluded to how you could use a hash table in PowerShell. Let me show you how and I think you’ll also appreciate how much more you can do with them in PowerShell with less coding.
Using the VBScript Dictionary
I don’t want you to think that it is PowerShell now and forever more. VBScript isn’t going away anytime soon and I still answer plenty of VBScript questions in the forums at ScriptingAnswers.com. A topic that has come up several times in recent days is the Dictionary object. It is easy to use in VBScript and often comes in handy. Let me show you how.
Are you leading me on?
Recently in the VBScript forum at ScriptingAnswers.com there was a question about creating a file name from the current date, but with leading zeros. This is a pretty common question. It is easy enough to get the month or day portion of the current day.
dy=Day(Now)
However there is no VBScript function to format this to provide a leading 0. Neither FormatDate or FormatNumber can help. So instead I offered a function. Here is a modified version of what I originally offered that is a little more flexible.
February PowerShell One-Liner
If you subscribe to the SAPIEN newsletter you should have seen this already. If not, why don’t you take a moment to subscribe? Each month you’ll get all the latest product and training news from SAPIEN Technologies as well as useful tips like this Powershell one-liner that produces a report on event log sizes for multiple computers.
Sneaky Aliases
love aliases in PowerShell because they make working in the interactive shell so much easier and faster. I’ve even created aliases for common apps I use like PrimalScript and PrimalForms so I can launch them from PowerShell with a few keystrokes. One drawback to aliases is that you can use them to reference any command that takes parameters. The alias can only substitute for the command. But there is a sneaky work around.