I can't seem to find many examples of PoweShell scripts on EE. MS seems to be pushing PS, do the members of EE think it is worth migrating scripts to PS.
It PS a better future environment or is VBS still the best way to go for the near term? Are there compelling reasons like powerful new features in PS to make it worth the switch?
PowershellVB Script
Last Comment
ElegantSolutions
8/22/2022 - Mon
RobSampson
In my opinion, for logon scripts, given that they're relatively simple in their functionality, VBS and Powershell are much the same. Of course they are different in syntax, but I actually find VBScript a bit simpler for these simple tasks.
I think Powershell is more suited to more administrative type scripts, that you run from an administrator console to retrieve information. Powershell if a very efficient way of getting a job done with less code though, and is often less than half of the code of an equivalent VBScript, especially when working with files, active directory objects, and output formatting, as a lot of the operations are performed under hood behind single commands.
For me, I will definitely keep using VBScript for Logon tasks, probably until the Windows Script Host no longer ships with Windows
Great stuff footech. I like that mantra, it's similar to "if it ain't broke, don't fix it". I would re-iterate that, don't rewrite scripts, unless you want to use them as a good learning point, because you know what you should end up with.
Rob.
footech
Yes, rewriting VB scripts can be used as a learning experience. My approach in that case would be to determine the goals of the VB script, and it's intermediate goals, and then just apply PS techniques to accomplish those goals - rather than doing a line-by-line (or command-by-command) translation. It's similar to how you might rewrite a script to optimize it - the first time writing a script you might use whatever you could find, then later on, with greater experience, you might examine what you wrote previously and see how you could accomplish the same goal in a much more efficient manner.
One other bit that I would put forward in support of knowing PowerShell is that many (and increasing in number) Microsoft (and even non-Microsoft) products are managed/configured through PS.
In Powershell, you map a drive using:
Open in new window
In VBScript, you use this:
Open in new window
I think Powershell is more suited to more administrative type scripts, that you run from an administrator console to retrieve information. Powershell if a very efficient way of getting a job done with less code though, and is often less than half of the code of an equivalent VBScript, especially when working with files, active directory objects, and output formatting, as a lot of the operations are performed under hood behind single commands.
For me, I will definitely keep using VBScript for Logon tasks, probably until the Windows Script Host no longer ships with Windows
Rob.