6

Given basic shell commands and scripting are necessary for a developer in UNIX-type environments – I'm talking rounded, small-shop, devops types – is Powershell the equivalent for Windows?

I have a Windows 7 machine at work, but I do all my development in a UNIX environment, either on a Mac or a Linux guest with VMWare. I'm not a sysadmin per se but I fill in as one here and there. Grep, sed, awk, the file structure, networking, etc, in UNIX are pretty well ingrained. I've been using these tools for years. Decades, even.

I have been fooling around on a Windows machine a bit more lately. My habit is to drop down to the command line to get stuff done, rather than all the pointing and clicking mania usually associated with Windows use. But with Powershell I'm totally lost. Nothing makes sense to me.

Is it worth learning? Is this even the way Windows folk work? Is it all going to change suddenly? Are there advantages to becoming a Powershell guru?

Bill Ingram
  • 1,162
  • 12
  • 14

4 Answers4

5

I believe so. PowerShell is the management interface for Windows Server 2012, and almost all of that has been ported back to 2008R2 & Win7 as well (Windows Management Framework 3.0).

There are a lot of people resisting the transition to PowerShell, but MS has decreed that it's the way forward. End users won't use it much, just as with Command Prompt, but developers & admins absolutely need to understand it.

Advantages to becoming a PowerShell guru? You can automate a lot more of Windows, much more easily, than you can with BAT/CMD scripts or Windows Script Host (VBScript/JScript). Remote management/access is very easy & designed to let you manage large numbers of machines from one central location.

I find myself doing a lot of tasks in PowerShell that I used to jump to Visual Studio for, because it's faster to get started with, lets me prototype quickly on the command line, and there are a lot of cmdlets built in that perform tasks that I would normally have to write a dozen lines of C# to do.

alroc
  • 27,574
  • 6
  • 51
  • 97
  • 1
    I'd be interested in learning more about the tasks you automate in PS. Do you ever blog about it? – Bill Ingram Nov 16 '12 at 01:00
  • 1
    At the moment, I do not blog about it but that may be changing soon. Most recently, I have written scripts to manipulate XML configuration files to prepare them for an upgrade of the system they belong to, parse worksheets in large Excel workbooks out into individual XLSX files (120 worksheets in 1 workbook to 120 individual files), upload & download files to/from (S)FTP(S) sites, and run SSRS reports exported to Excel format & uploaded to an FTPS site. – alroc Nov 16 '12 at 03:07
3

I believe it can be just as powerful as Bash, but all the command names and syntax are different. Check out this article, it compares some common UNIX commands to the powershell equivalents.

http://windows-powershell-scripts.blogspot.com/2009/06/unix-equivalents-in-powershell.html

As I have started to use powershell more, I find that it is definitely worth learning.

Impossibear
  • 195
  • 5
  • Good article. It links to other, similarly-useful articles elsewhere on the blog. Unfortunately, the author stops in '09. – Bill Ingram Nov 16 '12 at 01:08
  • I don't know why they couldn't just port over a set of the long-used, tried and true tools from UNIX, like grep, sed, etc. Instead, they write their own commands that basically do the same thing, but name them differently. Maybe I'm missing the bigger picture of Powershell as an environment. Perhaps if I were coming from the .NET world, it would all make more sense. – Bill Ingram Nov 16 '12 at 01:12
  • Check out the aliases in PowerShell - there is an alias for `Select-String` which is...`grep`. `Get-ChildItem` is aliased to `ls` and `Out-Printer` is aliased to `lp`. They couldn't just port over the UNIX tools & keep the same names because that would break significantly from the design philosophy that underlies .NET and PowerShell. – alroc Nov 16 '12 at 03:02
  • @waingram have you ever heard of Cygwin? Even if we had all of *nix tools and shells on Windows by default, I still think PowerShell would be a better shell than Bash or Zsh for the reasons outlined here - http://stackoverflow.com/a/3640403/291709 – Rynant Nov 16 '12 at 14:18
  • 2
    I have used Cygwin a little bit, but it always feels clunky. Not *quite* UNIX, not *quite* Windows, and a little quirky because of the little differences. – alroc Nov 16 '12 at 15:31
  • I also find this reference very userful: [BASH and PowerShell Quick Reference](http://cecs.wright.edu/~pmateti/Courses/233/Labs/Scripting/bashVsPowerShellTable.html) – orad Nov 22 '13 at 14:59
  • Did you know that through GnuWin you can use the most common Gnu utilities from within Powershell? While I think the Powershell equivs of ls, time, which, etc are more powerful than the Gnu equivs, Powershell doesn't have simple equivs for awk, sed, cut, etc - so I intersperse those Gnu utils into my Powershell scripts - the best of both worlds! – Justin Dunlap Aug 30 '14 at 19:40
1

My 2 cents:

I'm a sysadmin full time, a developper freelance and a photographer for passion. For my sysadmin job I use very often powershell. As a developper sometimes as a photographer sometimes too ( for manage my pics!). In my job environment there are 6 developpers ( .net ) full time and no one know powershell ( and some one never know what is). Powershell is really a power shell as bash is, with the big difference that it's based on a .net framework and works with objects rather than only strings.

CB.
  • 58,865
  • 9
  • 159
  • 159
  • 1
    It's funny you mention the .NET developer who doesn't even know what Powershell is. I've never worked on a large corporate or government development team, but I have worked with people from that world. It is surprising how narrow their skill set often is, especially the .NET folks. They are killer C# programmers, but have no idea how anything else works. – Bill Ingram Nov 16 '12 at 01:20
  • 1
    That sort of individual knows enough to do their job, within their job scope. And they're usually very good - but in a very narrow domain. Once they get into the weeds, they get lost in a big hurry. – alroc Nov 16 '12 at 03:09
0

PowerShell can't be compared with Unix console environments, the approach is very different...

On win you can get some scripting using native vbs, but are very limited the tools included, maybe you can use gnuwin32 to try some basic unix tools on windows env..

On my experience using win7, I can tell you that powershell is powerfull only for windows products, like exchange, active directory, and others, but is very frustrating try to use it like unix shells, you can't...(You can't change live state flags from kernel on windows like linux)

I'm using now the simple windows shell with python to get some high developer features that I miss from Unix systems....but isn't enough yet..

chespinoza
  • 2,638
  • 1
  • 23
  • 46
  • 2
    You may be interested to know that 3rd parties like VMWare & NetApp have also shipped modules & snap-ins for PowerShell to interact with their products. You can manage your VMWare environment extensively through PowerShell. It's not "only for Windows products". You are correct in saying that it doesn't work exactly like a UNIX shell, but it also doesn't pretend to be a UNIX shell. – alroc Nov 16 '12 at 02:59
  • Very cool. I know of the option to allow Visual Studio access to VMWare, but was not aware of the PowerShell feature. I want to check this out. – Bill Ingram Nov 16 '12 at 15:26
  • @waingram, check out http://blogs.vmware.com/vipowershell/ – alroc Nov 16 '12 at 15:29