A Windows PowerShell Carol: Ebenezer Script Integrates with VBScript
Summary: A Windows PowerShell Carol in which Ebenezer Script learns how to integrate VBScript with PowerShell. Hey, Scripting Guy! Will Ebenezer Script learn how to integrate VBScript with Windows PowerShell? — JS Hello JS, Microsoft Scripting Guy Ed Wilson here. It is almost the end of the year and we have decided to devote some posts to the holiday season. We even have guest bloggers from around the world to share some holiday spirit. This week we have Sean Kearney. You can learn more about Sean in Monday’s blog introduction. Be sure to check out Sean’s theme song for this week’s PowerShell Carol posts. Ebenezer’s eyes cleared as he looked up. It was Clippy, Jacob Clippy, back from the dead (or wherever retired Office Assistants go). Jacob moved and a large rattling sound echoed loudly through the room. Ebenezer looked up. A thousand large, blocky yet somehow familiar objects hung off his legs connected by long, thin, gray cables. “Ebenezer, you have become a miserable Administrator; cruel — foul and detestable.” The air filled with Jacob Clippy’s words. “Why thank you. I do try you know,” muttered old Mr. Script. “Nooooo! You should not dwell and be proud of those ways! For every joy I removed from a user; a 10 MB drive is attached to my leg!” “10 MB? Bah! Why I could carry that many floppies without a challenge!” “No, Ebenezer,” Clippy blinked, “but a 10 MB full height MFM hard drive for each user’s joy. Let me remind you, I irritated a LOT of people; this is heavy chain I carry. There is such a chain for you my friend, for you are already forging one away. Yet yours is twice as large and formed from old Battery backups.“ Ebenezer was about to faint until Jacob Clippy poked him. “There is still time for you to change. You will be visited by THREE spirits tonight.” “Clippy,” Ebenezer quickly spoke up, “this sounds vaguely like you are copying some OTHER famous Holiday story.” “It is parody so within legal guidelines; and you have little time to speak, Oh Crotchety One. As I said, three spirits will visit you this evening to try and save you from the fate I carved out for myself.” Ebenezer looked up. An eternity with technology did not sound so bad, but battery backups were never meant to be moved. He wondered if they come with a pushcart for the batteries. As if knowing his thoughts, Jacob muttered, “…and you will not get a push cart you cantankerous toad.” Jacob Clippy pulled out a thin device called a “Slate” and invoked Windows PowerShell. “Ebenezer, what do you see here?” The old scripter glanced. “I see nothing more than a blue looking command prompt! It’s that blasted Windows PowerShell! Useless! It’s separate from VBScript. I’d have to learn everything all over again! It’s CODEBUG!” “I see. So how would you launch a VBScript normally?” the Spirit glanced over at his old friend. “You dead old fool, to launch a VBScript application all I need to do it this.”
Jacob Clippy looked down at his old friend. “Would it surprise you to know that is how you launch it from Windows PowerShell, and that it can pass parameters directly to your original VBScripts?” Ebenezer shook his head, “Bah! ‘Tis all a load of Codebug!” Jacob keyed in two small scripts. The first was in VBScript. A simple one line script that was saved as myscript.vbs in a file.
wscript.echo wscript.arguments(0) & ” is being Visited by a Spirit!”
The second was in Windows PowerShell. It looked like this:
$Name=READ-HOST “Enter a Name here”
He ran ./JACOB.PS1 and filled in Ebenezer’s name. Its response was:
“Ebenezer is being Visited by a Spirit!”
For a moment, the Spirit saw a spark of possibility hit his old friend’s eyes when the two technologies merged seamlessly. “Ebenezer, I do not understand you. You still seem to love to script, yet so angry at new scripting and technologies. I see the spark that once lit your eyes when we launched that script. That old spark I once knew. Perhaps the night will yield a future you cannot foresee.” With a blink, Clippy faded into the night, the last thing Ebenezer saw was his two oversized catatonic eyeballs. “Spirits in the night,” thought Ebenezer, “more like Ghosts in the Machine.” The grumpy old fellow wandered up the stairs, tripping on the occasionally floppy. “Bah! Codebug!” was all that could be heard under his breath as he was heading up the stairs to sleep. Will Ebenezer stop having strange visions of giant, floating paperclips? Will the Three Spirits REALLY visit him tonight? Will the lawyers for a famous British person chase after the writer for use of parody? These and more questions answered (or not, as is the writer’s discretion). JS, that is all there is to using Windows PowerShell and VBScript together. Holiday guest blogger week will continue tomorrow. I invite you to follow me on Twitter or Facebook. If you have any questions, send email to me at firstname.lastname@example.org or post them on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy