Solved

VBScript or Powershell?

Posted on 2013-01-26
13
357 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 69

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 69

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
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.

 
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 69

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
 
LVL 69

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 69

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 69

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

776 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