Solved

VBScript or Powershell?

Posted on 2013-01-26
13
354 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

863 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

23 Experts available now in Live!

Get 1:1 Help Now