1 / 17

Powershell and the web

Powershell and the web. PowerShell Summit 2014 Trond Hindenes, Crayon AS (@ trondhindenes ). The IT Automation Pyramid. PowerShell Integration Maturity. Why step to the left?. Low quality vendor-supplied CmdLets Lack of functionality. Types of Web Services.

eddy
Download Presentation

Powershell and the web

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Powershell and the web PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)

  2. The IT Automation Pyramid

  3. PowerShell Integration Maturity

  4. Why step to the left? • Low quality vendor-supplied CmdLets • Lack of functionality

  5. Types of Web Services • Generation 1: XML Web Services (SOAP) • Stateful (or, acting like they are stateful) • Generation 2: RESTful services (JSON/XML) • Stateless • Good overview at:http://www.developingthefuture.net/web-services-overview/

  6. Types of Web Services (2) • SOAP: Access api through methods on the proxy object$citynames = $proxy.LatLonListCityNames(1) • REST: Each operation has a URL: • http://server/api/customers/fred/orders • HTTP DELETE to http://server/api/products/orange

  7. Authentication Gotcha’s • The life of a http request • Authentication types: • Unauthenticated or IP based • Basic/NTLM • Token based

  8. Visual Studio Lightswitch • Rapid development of Data-driven applications • Can be self-hosted or built as a Sharepoint 2013 “app” • The backend data is served using WCF OData

  9. Patterns for Lightswitch + PowerShell • Develop the app • Deploy it somewhere • Generate proxy dll • Use the proxy to interact with the serviceendpoint

  10. Examining the proxy dll • Use the VS Object Browser to inspect the dll • Or use Ilspy (http://ilspy.net/)

  11. PowerShell and RESTfulservices with JSON aka Invoke-Restmethod • JSON – Javascript Object Notation • “Human readable objects” • Similar to XML, but lighter weight (XML is wire-heavy)

  12. Rest Gotchas • Everything is a PsCustomObject • No “.gettype()” • Each request is atomic • No “state” • API examples often use curl • Important differences between PowerShell and curl (authentication) • Be mindful of JSON syntax • You'll often end up with lots of "nested" objects

  13. Generating “proper” objects • New-Struct to the rescue • (http://powershellcommunity.poshcode.org/3146)

  14. ASP.Net MVC/Web API • General-purpose web app framework for building “stuff” • Scott Guthrie’sbrainchild • Web API is a flexible framework for building (among others) RESTful web services • Natively supports both JSON and xml

  15. Case: Hosted mail flow monitoring

  16. Fun with web • SpamTitan (super-simple XML/Rest) • Geckoboard (complex json) • PagerDuty (simple json)

  17. Thank you!

More Related