Powershell



  • I just got back from the local SQL users group meeting where tonights topic was on tips and tricks of DB administration. One of the main parts of the presenters talk was the rising importance of powereshell in Microsofts vision of how admins should do their work - basically that if you do windows server work you need to be learning powershell ASAP. I know about powershell but have never used it, however I do recognize that MS is trying hard to put together systems that are fully scriptable. So in that area I have no complaints (other people can chime in on their thoughts on the product if they want)

    Anyway a large part of the powershell section of the presentation went something like this:

    • Look, with powershell I can list the contents of a directory
    • Or I can do a recursive list - look at all those script files I have in my directories
    • But if I want I can use some fancy pattern matching to select only files with specific names. What is that called again? Oh yeah .. regular expressions
    • Maybe I don't know the name of the file I want. Look I can search for words inside each file. And it shows me every occurrence of that word in every file.
    • But seeing the same word multiple times in the same file isn't what I want. So with powershell I can filter out the duplicates!

    At this point I'm slapping my forehead, saying to myself "WTF .. did you just discover grep??!?!?!?!?"


  • No shit, they should be adding noodles to their hoard and jamming it.



  • @OzPeter said:

    At this point I'm slapping my forehead, saying to myself "WTF .. did you just discover grep??!?!?!?!?"

    You've got to start somewhere. Most Windows admins I know can't script anything.

    Also, PowerShell is way different from grep. *NIX utilities are all about chaining together stand-alone single-purpose programs using stdin and stdout. PowerShell is all about strongly-typed libraries and streams of objects. Even an accomplished Linux jockey would have to start at the basics to get the hang of the PowerShell model (error handling was downright bizarre in PowerShell 1.0).

    Oh, and most of Microsoft's products have been highly scriptable for more than ten years. Microsoft is simply making yet another push to try to get lazy admin's to pull their heads out of their asses. I wrote a set of MS SQL maintenance scripts in the late 1990's and I'm still using them. I add a few tricks every few years, but this is not new stuff.



  • @OzPeter said:

    select only files with specific names. What is that called again? Oh yeah .. regular expressions
     

    Up where they script, up where they type
    Up where they pass IO through a pipe
    GUI free - wish I could be
    [url="http://www.fpx.de/fp/Disney/Lyrics/TheLittleMermaid.html#Part of Your World"]Part of that world[/url]

     @Rosie said:







  • @Jaime said:

    Also, PowerShell is way different from grep. *NIX utilities are all about chaining together stand-alone single-purpose programs using stdin and stdout. PowerShell is all about strongly-typed libraries and streams of objects. Even an accomplished Linux jockey would have to start at the basics to get the hang of the PowerShell model (error handling was downright bizarre in PowerShell 1.0).
    On one hand I'm annoyed that to do some scripting on Windows I'd have to learn a whole new bunch of crap to do what I've been doing in linux for years. On the other, Bash scripting (and I assume this is also true for other shells) is like pulling teeth so maybe PowerShell might have some redeeming qualities.



  • @OzPeter said:

    At this point I'm slapping my forehead, saying to myself "WTF .. did you just discover grep??!?!?!?!?"


    What were you expecting in a room full of MS oriented DBAs?



  • @DOA said:

    On the other, Bash scripting (and I assume this is also true for other shells) is like pulling teeth [...]
    Bash is rather frivolously full of features when compared to the Bourne shell.

    In fact, because it's the only standard Unix shell that you can rely on, I tend to write Unix shell scripts compatible with Bourne shell, even though my login shell is tcsh.

     



  • @Jaime said:

    @OzPeter said:
    At this point I'm slapping my forehead, saying to myself "WTF .. did you just discover grep??!?!?!?!?"

    You've got to start somewhere. Most Windows admins I know can't script anything.

    I have no problem with starting at the bottom, and at least half the room admitted to not using powershell. But I was flabbergasted at the presenters' "sense of wonderment" in his discovery of grep. If he had said "Here .. with powershell you can do the equivalent of grep" I would have felt different. I know it was the presentation and not the subject matter that I was reacting against.

    And yeah I know of powershell's object model. They mentioned it a bit, but it was never really demo'ed. Yet there was a great opportunity with one audience member question of basically "I know VBScript backwards, and I've tried to learn powershell. But I find it hard. So why should I?" but I don't think the presenter capitalized on it as much as he could.



  • @ubersoldat said:

    @OzPeter said:
    At this point I'm slapping my forehead, saying to myself "WTF .. did you just discover grep??!?!?!?!?"


    What were you expecting in a room full of MS oriented DBAs?

    The guy who runs the group stated that
    Anyone working for him who requires a single mouse click for configuration when building a server has failed in their job
    So there goes your generalization of MS oriented DBAs.

    Quite a lot of the particiants work on complex and interesting products that require high levels of skill. A presentation on indexing and query optimisation last year was fascinating - and then the presenter went on to say that they had just put a Terrabyte of RAM in their main system. So don't write people who use MS technology as dummies.



  • @OzPeter said:

    At this point I'm slapping my forehead, saying to myself "WTF .. did you just discover findstr??!?!?!?!?"

    FTFY...

    @Jaime said:
    You've got to start somewhere. Most Windows admins I know can't script anything.

    Many *nix admins I know also can't script anything.

    I advocate that anyone doing *nix sysadmin should know some scripting, if only to understand existing scripts. Some sysadmins I know are more systems managers, spending more time matching business demands to delivery capability, managing team members that can script utils upon demand, so are less concerned with how to write scripts.

    Oddly, many Windows admins I know that know their stuff[1] tend to do a lot of command-line stuff (net user, cacls, netsh, etc).

    @Jaime said:

    Also, PowerShell is way different from grep

    grep is a command. PowerShell is an interpreter, a shell, more like Perl... isn't it?.

    @OzPeter said:

    So don't write people who use MS technology as dummies.

    .. as opposed to writing people who teach MS technology as dummies, evidenced above?

    [1] okay, they give the appearance that they know their stuff.



  • I know very little PowerShell but I have used it before, mostly for doing some automated tasks as build steps on a .NET project. The great thing about PowerShell is you have full access to the .NET Framework and any .NET libraries you have. The bad thing is the syntax, it's one of the stranger languages I've come across. I wish they'd just used C# or VB syntax but left it as a dynamic scripting environment, that would make it much easier to get into for .NET programmers which I think is one of the markets PowerShell tries to cater to. As it is, most of the time I just write a small throwaway compiled C# console application to do something where a scripting environment would actually be more appropriate.



  • @mott555 said:

    I know very little PowerShell but I have used it before, mostly for doing some automated tasks as build steps on a .NET project. The great thing about PowerShell is you have full access to the .NET Framework and any .NET libraries you have. The bad thing is the syntax, it's one of the stranger languages I've come across. I wish they'd just used C# or VB syntax but left it as a dynamic scripting environment, that would make it much easier to get into for .NET programmers which I think is one of the markets PowerShell tries to cater to. As it is, most of the time I just write a small throwaway compiled C# console application to do something where a scripting environment would actually be more appropriate.

    Huh, I was just going to write basically that. I've looked at it once, determined that I could do what I needed to do quicker in C#, and never looked back.



  • @pkmnfrk said:

    @mott555 said:

    I know very little PowerShell but I have used it before, mostly for doing some automated tasks as build steps on a .NET project. The great thing about PowerShell is you have full access to the .NET Framework and any .NET libraries you have. The bad thing is the syntax, it's one of the stranger languages I've come across. I wish they'd just used C# or VB syntax but left it as a dynamic scripting environment, that would make it much easier to get into for .NET programmers which I think is one of the markets PowerShell tries to cater to. As it is, most of the time I just write a small throwaway compiled C# console application to do something where a scripting environment would actually be more appropriate.

    Huh, I was just going to write basically that. I've looked at it once, determined that I could do what I needed to do quicker in C#, and never looked back.

    PowerShell is easier for "get this from here, filter it, and run it through that" type scripts.  Compared to LINQ, PowerShell's pipe syntax is much cleaner.  Since PowerShell is installed on Server 2008 by default, scripts are much more portable than C# code.


  •  @ubersoldat said:

    @OzPeter said:
    At this point I'm slapping my forehead, saying to myself "WTF .. did you just discover grep??!?!?!?!?"


    What were you expecting in a room full of MS oriented DBAs?

    As a reformed developer and full on DBA these days. I run a SQL Server users group in my area and like most groups attendence is a mix of DBA, dev, and BI roles.

     The thing about user group presentations is often we have a mix of skill levels in attendance.  Sometimes you have level a 100 introductory presentation and sometime you might see level 200 or 300.  It's also possible the speaker was new to presenting or was just having a bad night.  The solution in either case is feedback.  Usually for us our speakers are Microsoft MVPs so they are seasoned presenters. From time to time though, we wil give the floor to someone who wants to get into presenting.

     The presentation itself is not the only value in a user group either.  Its the sharing of knowledge and experience.  I can call or email someone and get some advice that could save me hours of time.

    user groups are also one of the best places to find a decent job.



  • @Jaime said:

    Since PowerShell is installed on Server 2008 by default, scripts are much more portable than C# code.

    I imagine the .NET Framework is installed on Server 2008 by default, or at least I've never met a Windows Server without it installed.

    Even if you need to recompile from source: C:\windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe code.cs. Done.

     



  • @heterodox said:

    @Jaime said:

    Since PowerShell is installed on Server 2008 by default, scripts are much more portable than C# code.

    I imagine the .NET Framework is installed on Server 2008 by default, or at least I've never met a Windows Server without it installed.

    Even if you need to recompile from source: C:\windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe code.cs. Done.

     

    Yes.  in windows server 2008 its required to have the .net framework role enabled in order to install sql server 2008.  Some of the functionality in sql server 2008 is also written in .net.  For example the spatial datatypes are actually sqlclr objects.

     



  • they had just put a Terrabyte of RAM in their main system..


    Buff! When you cross the Marsbyte limit, things start going downwards. OTOH the other day I saw a Sunnybyte setup... it was massive!


  • @ubersoldat said:

    Buff! When you cross the Marsbyte limit, things start going downwards. OTOH the other day I saw a Sunnybyte setup... it was massive!

    Until the Shi'itebyte server bombed it.




  • File F:\TRWTF.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.

    At line:1 char:12

    • .\TRWTF.ps1 <<<<
      • CategoryInfo : NotSpecified: (:) [], PSSecurityException
      • FullyQualifiedErrorId : RuntimeException



  • @OzPeter said:

    @Jaime said:
    @OzPeter said:
    At this point I'm slapping my forehead, saying to myself "WTF .. did you just discover grep??!?!?!?!?"

    You've got to start somewhere. Most Windows admins I know can't script anything.

    I have no problem with starting at the bottom, and at least half the room admitted to not using powershell. But I was flabbergasted at the presenters' "sense of wonderment" in his discovery of grep. If he had said "Here .. with powershell you can do the equivalent of grep" I would have felt different.

    By the way, have you seen this amazing technology called HTML5? You can do all kinds of cool new things: 2D animations, 3D animations, playing video, even storing files locally!



  • @OzPeter said:

    "WTF .. did you just discover grep??!?!?!?!?"
     

    Yes, they did. Or rather, they just "encountered" grep. There's not a lot new in PowerShell - most of it comes almost unchanged from Bourne shell - but a lot of it is new to WIndows admins who entered the industry after the rise of the GUI. I am often training people with years of WIndows experience who don't know "copy con" or "dir /s".

    PowerShell is not a new paradigm but it is a paradigm shift for most Windows administrators.

     



  • @galgorah said:

    Yes.  in windows server 2008 its required to have the .net framework role enabled in order to install sql server 2008.  Some of the functionality in sql server 2008 is also written in .net.  For example the spatial datatypes are actually sqlclr objects.
     

    SQL Server requires .NET Framework because it is a .NET application.

    As far as I am it is mostly written in C# with a bit of the low-level system handling stuff written in C++.

     



  • @OzPeter said:

    Anyway a large part of the powershell section of the presentation went something like this:

    • Look, with powershell I can list the contents of a directory
    • Or I can do a recursive list - look at all those script files I have in my directories
    • But if I want I can use some fancy pattern matching to select only files with specific names. What is that called again? Oh yeah .. regular expressions
    • Maybe I don't know the name of the file I want. Look I can search for words inside each file. And it shows me every occurrence of that word in every file.
    • But seeing the same word multiple times in the same file isn't what I want. So with powershell I can filter out the duplicates!

    At this point I'm slapping my forehead, saying to myself "WTF .. did you just discover grep??!?!?!?!?"

    Your whole understanding of the event can be cleared up with two statements:

    1. Demonstrations of technology often feature simple problems so as not to get in the way of the technology (e.g. Hello World).
    2. Presenters like to pretend everything is exciting so their audience doesn't fall asleep.

    I taught for a long time and I always tried hard not to fall into this trap. If you pretend you are saving the world, but you are really doing something trivial, you may keep the neophytes awake, but you are going to lose the respect of anyone who knows what they are doing. This is exactly what happened to you. I always worked hard to come up with a simple example that really had some meat to it. I guess the presenter you had felt that feigned excitement was all you were worth.



  • @MiffTheFox said:


    File F:\TRWTF.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.

    At line:1 char:12

    • .\TRWTF.ps1 <<<<
      • CategoryInfo : NotSpecified: (:) [], PSSecurityException
      • FullyQualifiedErrorId : RuntimeException


     Set-Executionpolicy remote-signed

     



  • @Jaime said:

    Your whole understanding of the event can be cleared up with two statements:

    1. Demonstrations of technology often feature simple problems so as not to get in the way of the technology (e.g. Hello World).
    2. Presenters like to pretend everything is exciting so their audience doesn't fall asleep.

    .. and the value of the event can be determined by two questions:

    1. did the DBAs there (apart from you) actually know this stuff - or was it new to them?
    2. would this stuff actually prove useful to them in their daily job?

    It may not seem obvious to you, but given that specific audience the examples used would have also been my choice, since I'm essentially replicating "SELECT" and "WHERE" in another a command line to query and return results from my filesystem.

    Your reported WTF is only based upon your more extensive experience and knowledge.  What did the rest of the crowd think?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.