Solved

VBScript or Powershell?

Posted on 2013-01-26
13
353 Views
Last Modified: 2013-02-03
Hi,

I'm in Windows IT quite some years but never touched any scripting myself (yes, I did some copy pasting "writing my own scripts", but that's about it).

Now I would like to dive deeper into it but just wonder what I should "learn" VBScript first, then Powershell or directly Powershell.
Reason: a lot of Powershell scripts exist and not all Windows-es have powershell. On the other hand, I don't want to spend 2 times the effort.

Please advise.
J.
0
Comment
Question by:janhoedt
  • 6
  • 4
  • 2
13 Comments
 
LVL 68

Expert Comment

by:Qlemo
ID: 38824271
If you do a fresh start in regard of learning, you should go with PowerShell. Even XP allows for PS, and anything older than that should cease to be used ;-).
VBS requires you to use some workarounds for things you can do with PS easily. Both besides having control over .NET functions, they are not much comparable or interchangable.

Getting the concepts right with PS needs some more initial effort than with VBS, at least if you are already used to any programming or scripting language. Writing in VBS is more easy for the simple things, however, and calling it is faster. Nevertheless, PS is the way to go, VBS will keep to exist for a long time still as there is so much code out there.
0
 

Author Comment

by:janhoedt
ID: 38824446
Thanks. But as you mention "VBS will keep to exist for a long time still as there is so much code out there." In order to interprete/change that code I still need to understand VBS ....
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38824481
You'll need to understand VBS, but not be able to fully handle it. That makes a big difference. If you see VBS code, most of it can be understood without having too much knowledge.

You can say the same about PowerShell, but that isn't true. Modifying PS code needs more insight in what it is doing, and why.

But in the end it depends on what you know already, and what you are after.
If you just want to paste code you find on the Web together, VBS cide is usally easier to adapt.
If you want to write code yourself, PowerShell gives you more feedback with less ado.
0
 
LVL 2

Accepted Solution

by:
feaglin earned 500 total points
ID: 38824580
VBscript is a lot more complicated, and can't be run interactively from the command line.  It's easier to write and test Powershell scripts because you can run single commands or small sections of code from the command line to see the results.

  I use PowerShell more than the GUI for day to day systems administration.  After you've forced yourself to go through the learning curve it's a lot faster to make a change to one server or AD account than to do a dozen clicks for the same task.  And if you need to make the same change to 3 or a 100 servers/account it's trivial to wrap a simple loop around your command instead of spending your day clicking.

  Finally, Microsoft has not actively developed VBscript for quite a while.  It's kept around for backwards compatibility.  Microsoft made PowerShell part of it's "Common Engineering Criteria" (I think I have the name right) a year or two ago.  That mean every Microsoft product has to managed, support, PowerShell.  In Exchange 2010 every button you click runs a PowerShell script.  You can right click on a button to see what the script is.  The same goes for Windows Server 2012 management consoles, and I've read that it also has a window that shows the PowerShell code as it runs whenever you click a button in the Management console.

  Summary: VBscript is last decade's solution, PowerShell is the future.  Unless your current job has a lot of VBscript code in day to day use I would forget VBscript exists and learn PowerShell now.  (Don Jones has a favorite saying: "If you're a SysAdmin either learn PowerShell or learn how to say 'Do you want fries with that?'".

  There are a lot of free e-books out there, and the PowerScripting Podcast is a good resource.  Look through old topics to pick the interesting ones at first.  The book publisher Manning.com has several good PowerShell books and the best ebook policy I've seen.  Sign up for their daily newsletter and within a couple of months the book you want will be half price.

Good luck.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38824604
... and the book you want should be Windows PowerShell In Action, 2nd Edition (ISBN 978-1-935182-13-9).

I absolutely agree to the interactive part, though I do not use the shell that way often. Quest's (free) PowerGUI Script Editoris much better for trying things out, debug, and monitor. It's kind of "fat" in memory usage, however.
0
 
LVL 2

Expert Comment

by:feaglin
ID: 38824635
"PowerShell in Action" is great, but it's on the advanced side.  It's written by the guy who did the majority of the design and development of PowerShell.  A better starter book would be "PowerShell in a Month of Lunches" to learn the basic concepts, and the "PowerShell Cookbook" to get instant examples on a variety of Windows OS tasks, and afterward move on to "PowerShell in Action".  Of course, everything in the cookbook is on the Internet, but you have to wade through the Internet, so the cookbook is more of a convenience, I think.

http://poshcode.org and http://www.codeplex.com are good sources for scripts.

hth
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 68

Expert Comment

by:Qlemo
ID: 38824818
I'm not in total disagreement about PSiA being advanced. think that you can read each chapter as far as you dare, and still have a good introduction into the "machine". You do not get a lot of example code, that's true. The book is a two or three pass adventure.

If you look for free ebooks, make sure you get PowerShell 2.0 related stuff - with 1.0 many things were much more complicated, and you had to fall back to WMI often.
0
 

Author Comment

by:janhoedt
ID: 38824865
What about logonscripts , can powershell be used?
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38824893
Yes, but for interacting with AD either the ActiveDirectory module should be used (W2008R2 and above), or the Quest cmdlets loaded, to simplify tasks.
0
 

Author Comment

by:janhoedt
ID: 38825812
So every client needs this module loaded in order to run logonscript?
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 38826523
The logon script will have to load the module. As said, you can go without, but it is more demanding then.
0
 

Author Comment

by:janhoedt
ID: 38826537
So the client needs to load the module = powershell  installed.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now