Adam Weigert Puts NetApp On a String

Adam Weigert Puts NetApp On a String

  • Comments 3

Adam Weigert has started a new Codeplex project PowerShell OnTap.   (That brings the total number of PowerShell-related CodePlex projects to 48!)  OnTap provides a functions to manipulate NetApp servers using the OnTAP web service APIs.

I’m not a NetApp user but I was interested in what he was doing and was delighted to read his code.  It is an excellent example of PowerShell coding practices and has a number of excellent and clever techniques in it.   I LOVE Adam’s code – it is logical, clean and visually coherent.  You should view it in an editor that does syntax coloring (like PowerShell V2 CTP2).

My only complaint would be that he should use HERE Strings more.  A number of the utility functions he provides in his library are useful to everyone – I know because I came the same conclusion and we are adding them the next CTP of PowerShell! 

Go read his code and enjoy.  Oh yea, and if you use NetApps, you’ll want to go check it out as well.  :-)

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Leave a Comment
  • Please add 3 and 4 and type the answer here:
  • Post
  • Have a question ..

    What is the reason for putting $SCRIPT: in front of everything ?

    I have no idea what that means .. Does it mean its available to any part of the script kind like a global thing ?

    Chris

  • I was trying to get the script to act like a class module where when a function defined in that scope would have access to variables only in that scope, so only the functions and variables needed would be exposed. I released v0.1 today without all that junk and hopefully it is a little less confusing.

  • Hi Jeffrey.

    With the Here strings you probably refer to code like:

    $requestXml = "<?xml version=""1.0"" encoding=""utf-8"" ?><!DOCTYPE netapp SYSTEM ""{0}""><netapp {1}version=""{2}"" xmlns=""{3}"">{4}</netapp>" -f (

                      $NaOnTAPDTD,

                      $(if (![string]::IsNullOrEmpty($server.vFiler)) { "vfiler=""$($server.vFiler) """ }),

                      $server.Version,

                      $NaOnTAPXMLNS,

                      $request.ToXml()

                  )

    I think the approach taken by Adam is better than using Here strings. If you include your variables into Here strings, you don't get any checking of the variables, types are not reported. With using -f you get an error when you mistyped a variable name. Another thing is that you need to include a lot of $(...) in your Here string to do more complex evaluations.

    Regards,

    Serge van den Oever

Page 1 of 1 (3 items)