views:

319

answers:

7

For work I am moving over to windows after being on linux for quite a while. I want to get some scripting skills going for administrative tasks in windows. I am quite good with bash, but bash's "libraries/tools" are missing a lot when it comes to windows. I see vbscript, wsh, powershell, cmd, jscript, etc and wondering what to learn, or what combination of things. I'm also learning .net so it might be nice if it helps with that, but its not a requirement.

+1  A: 

VBScript, batch and Powershell are the big ones I can think of. Also, learn how WMI works and how you can call it from VBScript/Powershell.

Jesse Weigert
+12  A: 

If you are learning .NET, Powershell is the only choice. VBScript has been around for much longer, and so there are probably more examples and samples out there for VBScript. But Powershell is where Microsoft is focusing for scripting for the future. It is included in WS2008 (R2), it will be in Win 7, and it can be added on to Vista or WS2003 or WS2008. Powershell is strategic. I find it much more powerful than VBScript.

The community around Powershell is ramping up, too. Just one example: If you go to powershell.com you can sign up for a "powershell tip of the day" sent in email.

As for .NET intersection - Powershell can load .NET assemblies and call into them, so the two things will be very complementary.

Cheeso
Thank you, noted.
Cheeso
+6  A: 

Powershell, no question about it if you're going to be administering a 2008 environment or later. I frequent Microsoft conferences and they are putting all their chips into Powershell.

Eric
+4  A: 

Cygwin can keep your unix scripting skills relevant in a Windows environment. Powershell seems to be the official .Net scripting language at the moment. However, don't discount other options. There is Ironpython, IronRuby, and others. Many of the Java scripting languages such as Groovy can be made operational under .Net via IKVM

Todd Stout
+5  A: 

I'll second the PowerShell recommendations. The developers on the PowerShell team were old Unix hands, and there are a number of Unix-like features in PowerShell.

Something like Cygwin would let you use bash directly, but I wouldn't recommend it for a couple reasons. First, if you're in a Windows environment, PowerShell would be easier for someone else without your bash experience to maintain. Second, Windows administration is going to be easier in an environment where you can easily access methods on WMI objects etc.

PowerShell has a lot of the benefits of a traditional Unix shell, but PowerShell has one huge advantage: you can call methods on objects rather than parsing text when you pipe commands together. Every command returns an object. See Comparing the Unix and PowerShell pipelines.

John D. Cook
A: 

I used PowerShell a lot it's very easy and powerful scipting language, but it does not support windows 2000! And it force me to install powershell runtime on each computer in LAN. As for IronRuby I recomend BOO - nice and powerful language.

Sergey Mirvoda
+2  A: 

I've been switched over to Linux for a few years myself, but I have recently done a few projects in Windows using Perl and I cannot recommend it enough. If you're actually going to be writing scripts, rather than single-commands, it's definitely worth considering. Check out Strawberry Perl. You might even be able to find a decent Perl shell that runs under strawberry perl, in which case you could use it for single-command stuff, too. Check out http://perldoc.perl.org/perlfaq3.html#Is-there-a-Perl-shell?

And don't think that Perl isn't good for scripting Windows stuff. In my recent projects, I've scripted with both Outlook and Excel in Perl using Win32::OLE, and it's worked like a charm!