powershell and the web powershell summit 2014 trond hindenes, crayon as (@trondhindenes)
TRANSCRIPT
![Page 1: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/1.jpg)
POWERSHELL AND THE WEBPowerShell Summit 2014
Trond Hindenes, Crayon AS (@trondhindenes)
![Page 2: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/2.jpg)
THE IT AUTOMATION PYRAMID
Integratio
n
Orchestration
Automation
![Page 3: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/3.jpg)
POWERSHELL INTEGRATION MATURITY
HTTP API (rest)
.Net wrapper
(dll)
PS Module
![Page 4: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/4.jpg)
WHY STEP TO THE LEFT?
•Low quality vendor-supplied CmdLets•Lack of functionality
![Page 5: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/5.jpg)
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/
![Page 6: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/6.jpg)
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
![Page 7: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/7.jpg)
AUTHENTICATION GOTCHA’S
•The life of a http request•Authentication types:•Unauthenticated or IP based•Basic/NTLM•Token based
![Page 8: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/8.jpg)
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
![Page 9: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/9.jpg)
PATTERNS FOR LIGHTSWITCH + POWERSHELL
•Develop the app•Deploy it somewhere•Generate proxy dll•Use the proxy to interact with the service endpoint
![Page 10: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/10.jpg)
EXAMINING THE PROXY DLL
•Use the VS Object Browser to inspect the dll•Or use Ilspy (http://ilspy.net/)
![Page 11: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/11.jpg)
POWERSHELL AND RESTFUL SERVICES WITH JSON AKA INVOKE-RESTMETHOD
• JSON – Javascript Object Notation•“Human readable objects”•Similar to XML, but lighter weight (XML is wire-heavy)
Construct Object
Convert to Json
Send to server
Get stuff back
![Page 12: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/12.jpg)
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
![Page 13: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/13.jpg)
GENERATING “PROPER” OBJECTS
•New-Struct to the rescue• (http://powershellcommunity.poshcode.org/3146)
![Page 14: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/14.jpg)
ASP.NET MVC/WEB API
•General-purpose web app framework for building “stuff”•Scott Guthrie’s brainchild•Web API is a flexible framework for building (among others) RESTful web services•Natively supports both JSON and xml
![Page 15: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/15.jpg)
CASE: HOSTED MAIL FLOW MONITORING
IaaS hMail
Azure Web Site Web API
Operations Manager
![Page 16: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/16.jpg)
FUN WITH WEB
•SpamTitan (super-simple XML/Rest)•Geckoboard (complex json)•PagerDuty (simple json)
![Page 17: POWERSHELL AND THE WEB PowerShell Summit 2014 Trond Hindenes, Crayon AS (@trondhindenes)](https://reader036.vdocuments.mx/reader036/viewer/2022062511/5516c306550346f6208b590c/html5/thumbnails/17.jpg)
THANK YOU!