1 / 42

INF204 - What's New in Windows PowerShell V2

INF204 - What's New in Windows PowerShell V2. Jeffrey P. Snover Partner Architect. State of the Software – The Good. Phenomenal rate of adoption > 1.55 Million downloads in < 1 year

jedidiah
Download Presentation

INF204 - What's New in Windows PowerShell V2

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. INF204 - What's New in Windows PowerShell V2 Jeffrey P. SnoverPartner Architect

  2. State of the Software – The Good • Phenomenal rate of adoption • > 1.55 Million downloads in < 1 year • Exchange 2007, MOM 2007, Virtual Machine Manager 2007, Lotus Domino Transporter Suite, Data Protection Manager, Compute Cluster Tool Pack, Windows Server, Backup • Good ISV pickup • > 20 new internal partners • CEC 2009 requirement • Won both Best of TechEd and Teched Attendees Pick • Solid Community • Active and useful Newsgroups and Forums • 25 Codeplex projects (2 in the top 25 most active) • Strong group of MVPs • 14+ books • Strong tools

  3. Tower of Power

  4. Productivity

  5. State of the Software – Opportunities for Improvement • Cmdlet specific remoting • Can’t write Cmdlets in PowerShell • Script development via Notepad and PS-DEBUG • APIs did not address common GUI over CLI issues

  6. Announcing : PowerShell V2 Community Technology Preview (CTP)

  7. Availability /Applicability • CTP downloadable NOW • CTP is NOT Beta • Full regression tests against V1.0 functions • Good coverage against new functions • Catch-as-catch-can documentation • Things WILL change • Works on XP SP2 and Above • Must download WS-Management V1.1 first • On VISTA – SP1 is required (for remoting) • Replaces V1.0 • V1 compatible except for additions • New variable names • New Language/cmdlet features

  8. PowerShell V2 Themes

  9. PowerShell V2 Themes • Commands, expressions and ScriptBlocks can be run • in the foreground or background • on one or more machines • over a LAN or a WAN • in unrestricted or restricted environments • using short or long connections • using impersonation or supplied credentials • initiated by user input or by events

  10. Features • Remoting • Mobile Object Model • Background Jobs • Restricted Runspaces • Eventing (coming soon)

  11. Universal Code Execution Model

  12. Remoting

  13. Mobile Objects Model • Islands of optimization in a sea of interoperability • Whenever possible, use live.NET objects • Use typed property bags everywhere else • Live objects get serialized at runspace borders • Typed property bags using 22 core datatypes • Everything else is converted using ToString() • Process can be tweaked with typeXML entries • Automatically deserialized into typed property bags on receipt • Type: Deserializes.OriginalType • PSIPHostEntry added (ComputerName, Aliases, Addresses)

  14. Demo: PowerShell Remoting Jeffrey P. Snover Partner Architect

  15. Background Jobs • Commands, expressions and scriptblocks can be run in the foreground or background on one or more machines • PSJOB – Start, Get, Wait, Receive, Stop, Remove • Provide a runspace or it will create a local runspace connection • Jobs can contain ChildJobs • Operate on them individually or collectively

  16. Demo: Background Jobs Jeffrey P. Snover Partner Architect

  17. RistrictedRunspaces • Option for hosting PowerShell to create an environment to run potentially hostile requests safely • Service oriented scenarios • $executionContext.SessionState • LanguageMode • FullLanguage, DataLanguage, NoLanguage • Whitelists for Scripts and Applications • Visibility property on Commands and Variables • New model for creating initial session state

  18. Features • New hosting APIs • Runspace pooling

  19. Hosting APIs //Early bound API PowerShell ps = PowerShell.Create("get-process").AddParameter(“Name”,”*SS”).AddCommand("Sort-Object“); //Typed invocation Collection<Process> col = ps.Invoke<Process>(); //Cmd reuse Collection<Process> col = ps.Invoke<Process>();

  20. Demo: APIs Jeffrey P. Snover Partner Architect

  21. Features • Graphical PowerShell • Script Cmdlets • Script Internationalization/Data Language • Debugging • Packages and modules (coming soon)

  22. Demo: Graphical PowerShell Jeffrey P. Snover Partner Architect

  23. Script Cmdlets • Supports most everything a .NET Cmdlet can do • Attributes on Parameters • Attributes on Cmdlet • $CMDLET similar to a C# THIS • $Cmdlet.ShouldProcess(“Target”, “Action”) • $Cmdlet.ShouldContinue(“Query”, “Caption”) • Engine does a TON of work for you • Fewer lines of code delivers more functions in a more consistent way

  24. Demo: Script Cmdlets Jeffrey P. Snover Partner Architect

  25. Script Internationalization/ Data Language • Data var [–supportedcommandcmd] {scriptblock} • Limited subset of language: • Comparison operators (except –Match) • If, elseif, else • Well defined [safe] ConvertFrom-* cmdlets • Limited variables: $culture, $uiculture, $true, $false, $null • Comments and pipelines • Literals • Strings, hash, xml, etc • Save Cmdlets • ConvertFrom-StringData

  26. Script Internationalization/ Data Language Data msgs { ConvertFrom-StringData @” Usage = “Usage: Get-Process Name <name>” NoSuchProc = “No such Process Found” “@ } Import-LocalizedData –Bind msgs …. Throw $msgs.NoSuchProc

  27. Script Debugging • PSBreakPoint • New, Remove, Get, Enable, Disable • Breakpoints can be set on: • Lines, Line/ColumnNumber • Functions • Variable Read/Write • Cmdlets • Action scriptblocks • Step • Into, Over, Out • Get-PsCallStack

  28. Features • Language enhancements • Improved adapters • New/improved cmdlets

  29. Language Enhancements • Splatting operator • $a=@{id=13,23,33; ErrorAction="continue"; ErrorVariable="e"} • stop-process @a • -Split • $x = “1,2,3,4” • $x –split “,” • -Join • $x=“1”,”2”,”3”,”4” • $x –join “,” • [ADSISearcher] • [x[]] • [string[]]”a”,”b”,”c”

  30. Improved Adapters /ADSI support • Improved adapter lookup algorithm • Includes PSBASE to lookup path • Improved ADSI Adapter • Path, Children, Parent, SchemaClassName, SchemaEntry are now available on the object • [ADSISearcher] • DirectoryEntry type has marshalling code methods • ConvertDNBinaryToString • ConvertLargeIntegerToInt64

  31. WMI Improvements • Cmdlets • Get-WmiObject, Remove-WmiObject • Set-WMIInstance • Invoke-WmiMethod • New parameters • -Impersonation, -Authentication, -Locale, -EnableAllPrivileges, -Amended, -DirectRead, -Authority • Connection settings stay with the object [bug fix]

  32. Required slide: Please customize this slide with the resources relevant to your session Resources • Technical Communities, Webcasts, Blogs, Chats & User Groupshttp://www.microsoft.com/communities/default.mspx • Microsoft Learning and Certificationhttp://www.microsoft.com/learning/default.mspx • Microsoft Developer Network (MSDN) & TechNet http://microsoft.com/msdnhttp://microsoft.com/technet • Trial Software and Virtual Labshttp://www.microsoft.com/technet/downloads/trials/default.mspx • New, as a pilot for 2007, the Breakout sessions will be available post event, in the TechEd Video Library, via the My Event page of the website learn support connect subscribe MSDN Library Knowledge Base Forums MSDN Magazine User Groups Newsgroups E-learning Product Evaluations Videos Webcasts V-labs Blogs MVPs Certification Chats Visit MSDN in the ATE Pavilion and get a FREE 180-day trial of MS Visual Studio Team System!

  33. Complete your evaluation on the My Event pages of the website at the CommNet or the Feedback Terminals to win! All attendees who submit a session feedback form within 12 hours after the session ends will have the chance to win the very latest HTC 'Touch' smartphone complete with Windows Mobile® 6 Professional

  34. © 2007 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.

  35. Backup Slides

  36. Parser API • [System.Management.Automation.PSParser]::Tokenize • $psp = [System.Management.Automation.PSParser] • $psp::Tokenize(((cat $file) -join "`n"),[ref]$null) | where {$_.type –eq “Command” } | Group Content |sort Name

  37. Graphical PowerShell • VERY early release (lots of known issues) • Requires .NET 3.0 • Supports • Unicode output • Multiline input • Syntax coloring • Script editing • Multiple sessions

  38. Common Remoting Goals • Universal, free, and non-optional for all PowerShell functions/cmdlets/providers • Secure • Firewall Friendly • Protocol/Payload efficient • Streaming behaviour

  39. WS-MGMT • Remoting layers on top of WS-MGMT protocol • WINRM service • Uses HTTP over a fixed (configurable) port • Admin control over resource usage • Max shells per user • Concurrent users • $pshome\Configure-WSMAN.ps1

  40. Parameter Attributes • Mandatory • Position(int) • Alias(string) • ValueFromPipeline, ValueFromPipeLineByName • AllowNull, AllowEmptyString, AllowEmptyCollection • ValidateRange(int,int), ValidateLength(int,int) , ValidateNotNull, ValidateNotNullOrEmpty, ValidatePattern(regex), ValidateSet(string[],bool), ValidateCount(int,int), ValidateScript(scriptblock) • Customer attributes supported as well • ParameterSets are not supported in this CTP

  41. $cmdlet • Methods • CurrentProviderLocation, GetResolvedProviderPathFromPSPath, GetResourceString, GetUnresolvedProviderPathFromPSPath, GetVariableValue • Invoke • ShouldContinue, ShouldProcess • ThrowTerminatingError, • WriteCommandDetail, WriteDebug, WriteError, WriteObject, WriteProgress, WriteVerbose, WriteWarning • Properties • CommandOrigin, CommandRuntime, Host, InvokeCommand, InvokeProvider, JobRepository, MyInvocation, ParameterSetName, SessionState, Stopping

  42. ScriptCmdlet – Engine Functions • -OutVariable • -ErrorAction , -ErrorVariable • -Whatif, -Confirm, -Verbose • -Debug

More Related