KEMBAR78
PowerShell Technical Overview | PPT
Windows PowerShell: A Technical Overview “ Something old, something new, something borrowed and something blue” Allan da Costa Pinto Windows PowerShell Fanboy Microsoft [email_address] http://blogs.msdn.com/allandcp
For the .NET Developers in the crowd:  Increase your .NET Skills with the free Training Kits http://tinyurl.com/6q5jqz
http://msevents.microsoft.com Search for Virtual Labs Search on PowerShell
 Ricky Buch Program Manager Microsoft Corporation  Kevin Michael Woley Program Manager Microsoft Corporation http://channel9.msdn.com/pdc2008/PC50/
 
 
 
http://blogs.msdn.com/powershell/archive/2009/01/14/windows-7-troubleshooting.aspx
More…
http://channel9.msdn.com/pdc2008/ES14/ ASP.NET on Server Core Integrated  PowerShell  Provider Integrated FTP and WebDAV  New IIS Manager Modules Configuration Logging & Tracing Best Practices Analyzer
http://channel9.msdn.com/pdc2008/ES06/
IIS/WAS Quadrant IIS Manager WF and WCF Frameworks Persistence SQL Persistence Provider Management APIs ( PowerShell  command-lets) WF and WCF Management  Modules Runtime Databases Persistence schema Monitoring schema Monitoring WF SQL Tracking Provider WCF SQL Tracking Behaviors Messaging Forwarding Service Hosting Durable Timer Service Visual Studio WF and WCF  Project Templates Windows Application Server Role Model Deployment to Dublin Discovery Service Dublin adds Dublin enhances Windows/IIS/.NET 4.0 Scale-out & Reliability Discovery & Control Application Monitoring Versioning, Partitioning, Routing System Center App Server SCOM Pack “ It just works!” http://channel9.msdn.com/pdc2008/BB18
 
http://www.codeplex.com/PSHyperv
http://www-01.ibm.com/support/docview.wss?rs=171&uid=swg24017698
http://halr9000.com/article/716 Costly
I don’t have an iPhone but if I did… http://tinyurl.com/b62o8f
No .NET? Know .NET? Object Oriented   scripting language and shell built on  .NET Framework Backwards Compatible   and works with COM, WMI, .NET, XML Easy to learn, adopt, automate and  extend  with a  thriving community   Hosted  in other applications (MMC 3.0, custom) Available for Windows XP, Windows 2003 and Windows Vista In the box   with Windows Server 2008, Windows 7 and Windows Server 2008 R2 1.0  born in 2006,  2.0  currently in CTP V3
Exchange 2007 –eq "Much Simpler" Exchange Server 2003 (VBScript) E2K7 (PowerShell one-liner) Mailbox Statistics Set listExchange_Mailboxs =  GetObject("winmgmts:{impersonationLevel=impersonate}!\\COMPUTERNAME\ROOT\MicrosoftExchangeV2").InstancesOf("Exchange_Mailbox") For Each objExchange_Mailbox in listExchange_Mailboxs WScript.echo "AssocContentCount  =” + objExchange_Mailbox.AssocContentCount WScript.echo " DateDiscoveredAbsentInDS =” + objExchange_Mailbox.DateDiscoveredAbsentInDS WScript.echo " DeletedMessageSizeExtended =” + objExchange_Mailbox. DeletedMessageSizeExtended WScript.echo " LastLoggedOnUserAccount =” + objExchange_Mailbox. LastLoggedOnUserAccount WScript.echo " LastLogoffTime =” + objExchange_Mailbox. LastLogoffTime WScript.echo " LastLogonTime  =” + objExchange_Mailbox. LastLogonTime  WScript.echo " LegacyDN =” + objExchange_Mailbox. LegacyDN WScript.echo " MailboxDisplayName =” + objExchange_Mailbox. MailboxDisplayName WScript.echo " MailboxGUID  =” + objExchange_Mailbox. MailboxGUID  WScript.echo " ServerName  =” + objExchange_Mailbox. ServerName  WScript.echo " Size =” + objExchange_Mailbox. Size WScript.echo " StorageGroupName  =” + objExchange_Mailbox. StorageGroupName  WScript.echo " StorageLimitInfo  =” + objExchange_Mailbox. StorageLimitInfo  WScript.echo " StoreName  =” + objExchange_Mailbox. StoreName  WScript.echo " TotalItems  =” + objExchange_Mailbox. TotalItems  Next get-mailboxstatistics  – server $servername Database Mgmt Dim StorGroup as New CDOEXM.StorageGroup StorGroup.DataSource.Open "LDAP://" + DCServer + "/ CN=First Storage Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group, CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services, CN=Configuration," + DomainName  StorGroup.MoveLogFiles("C:\newlogPath", 0) move-storagegrouppath  -identity “First Storage  Group“  – log "C:\newlogPath” Recipient Mgmt Dim objMailbox As CDOEXM.IMailboxStore Set objMailbox = GetObject("LDAP://" + DCServer + "CN=FOO,CN=users," + DomainName) objMailbox.CreateMailbox "LDAP://" + DCServer + "/CN=Private MDB,CN=First Storage Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group, CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services, CN=Configuration," + DomainName enable-mailbox  -identity domain\FOO  – database “First Storage Group\Private MDB”
Exchange 2007 Management Architecture CLI GUI Setup Process Boundary   Exchange cmdlets Configuration Data Objects/Access PowerShell Data Provider PowerShell Engine Windows Forms Early-bound objs Windows Forms ADO.NET MAPI Store Registry Meta base AD
Get-Command Get-Help Get-Member Get-PSDrive Get the Free eBook and information about the 4 most important CmdLets http://tinyurl.com/powershell4
Anatomy
http://www.flickr.com/photos/ajari/2288043144/
http://www.flickr.com/photos/mnkyhead/3292809/
Verb – Noun Clear – Host Set – ExecutionPolicy Get – Help Write – Debug Restart – Computer  Don’t do this during session, but  -whatif   you did? Drink – Beer Do this before session  
http://www.flickr.com/photos/dnorman/2249376120/
http://www.flickr.com/photos/9229859@N02/1951252254/
http://www.flickr.com/photos/adactio/377537734/
The PowerShell pipeline Get-Process | Where { $_.handles –gt 500 } | Sort handles | Format-Table Get-Process Cmdlet Common Windows PowerShell Parser Windows PowerShell Pipeline Processor Where-Object Cmdlet Sort -Object Cmdlet Format-Table Cmdlet Alias Alias
A Review Cmdlets Tiny commands Composability Providers Abstraction of drives Discoverability Snap-ins Unit of deployment Wraps cmdlets, providers, etc PS C:\>  Get-Process PS C:\> cd HKLM: PS  HKLM:\ > PS C:\>  add-pssnapin  MySnapIn
Modifying the system Support -confirm and -whatif operations CmdletAttribute[...,  SupportsShouldProcess = true ] Call  ShouldProcess  for initial confirmation Are you sure? Call  ShouldContinue  for additional confirmation Are you really sure? Enable/disable “yes to all” and “no to all” options Provide a “force” parameter to bypass these calls Specify the impact of the cmdlet Allows user to set the confirm sensitivity CmdletAttribute[...,  ConfirmImpact = ConfirmImpact.High ]
Extending Windows PowerShell Aliases Functions Cmdlets Write them in .NET (v1) Write them in PowerShell (v2) Providers IIS, SQL, Exchange, Yours Custom Hosts http://blogs.msdn.com/daiken/archive/2007/06/22/hosting-windows-powershell-sample-code.aspx
PowerShell Architecture
PowerShell Architecture Add Creativity Here!
PowerShell V2 Themes
Extended Type System (ETS) Type Adapters provide consistent object access across different technologies .NET, COM, WMI, ADSI, XML, ADO Allows scripts to be general regardless of “native” object interaction Scripts can be based on property names not programming knowledge classes and types Object utilities work against all objects http://www.flickr.com/photos/foundphotoslj/449085680/
Shell Defaults No scripts run  (ExecutionPolicy=Restricted) .ps1 is associated  with Notepad Must provide a path to a script file in order to run it You Can Configure ExecutionPolicy Restricted AllSigned RemoteSigned Unrestricted (No!!!) Centrally configurable  via Group Policy In V2 Constrain Runspaces
Resources! Team blog http://blogs.msdn.com/PowerShell/ PowerShellCommunity.Org http://www.PowershellCommunity.Org Channel 9 http://channel9.msdn.com/tags/PowerShell http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki Script Center http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx CodePlex http://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershell Books I own Manning Press book by PowerShell Dev Lead Bruce Payette: PowerShell in Action  http://manning.com/powershell/ O’Reilly book by PowerShell Dev Lee Holmes – Windows PowerShell Cookbook http://www.oreilly.com/catalog/9780596528492/index.html Newsgroup:  Microsoft.Public.Windows.PowerShell
Out-Thankyou PS C:\> Thank you for your time and attention. Good luck in your PowerShell Adventures! Get-Allandcp PS C:\> Allan da Costa Pinto Microsoft [email_address] http://blogs.msdn.com/allandcp

PowerShell Technical Overview

  • 1.
    Windows PowerShell: ATechnical Overview “ Something old, something new, something borrowed and something blue” Allan da Costa Pinto Windows PowerShell Fanboy Microsoft [email_address] http://blogs.msdn.com/allandcp
  • 2.
    For the .NETDevelopers in the crowd: Increase your .NET Skills with the free Training Kits http://tinyurl.com/6q5jqz
  • 3.
    http://msevents.microsoft.com Search forVirtual Labs Search on PowerShell
  • 4.
     Ricky BuchProgram Manager Microsoft Corporation  Kevin Michael Woley Program Manager Microsoft Corporation http://channel9.msdn.com/pdc2008/PC50/
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
    http://channel9.msdn.com/pdc2008/ES14/ ASP.NET onServer Core Integrated PowerShell Provider Integrated FTP and WebDAV New IIS Manager Modules Configuration Logging & Tracing Best Practices Analyzer
  • 11.
  • 12.
    IIS/WAS Quadrant IISManager WF and WCF Frameworks Persistence SQL Persistence Provider Management APIs ( PowerShell command-lets) WF and WCF Management Modules Runtime Databases Persistence schema Monitoring schema Monitoring WF SQL Tracking Provider WCF SQL Tracking Behaviors Messaging Forwarding Service Hosting Durable Timer Service Visual Studio WF and WCF Project Templates Windows Application Server Role Model Deployment to Dublin Discovery Service Dublin adds Dublin enhances Windows/IIS/.NET 4.0 Scale-out & Reliability Discovery & Control Application Monitoring Versioning, Partitioning, Routing System Center App Server SCOM Pack “ It just works!” http://channel9.msdn.com/pdc2008/BB18
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
    I don’t havean iPhone but if I did… http://tinyurl.com/b62o8f
  • 18.
    No .NET? Know.NET? Object Oriented scripting language and shell built on .NET Framework Backwards Compatible and works with COM, WMI, .NET, XML Easy to learn, adopt, automate and extend with a thriving community Hosted in other applications (MMC 3.0, custom) Available for Windows XP, Windows 2003 and Windows Vista In the box with Windows Server 2008, Windows 7 and Windows Server 2008 R2 1.0 born in 2006, 2.0 currently in CTP V3
  • 19.
    Exchange 2007 –eq"Much Simpler" Exchange Server 2003 (VBScript) E2K7 (PowerShell one-liner) Mailbox Statistics Set listExchange_Mailboxs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\COMPUTERNAME\ROOT\MicrosoftExchangeV2").InstancesOf("Exchange_Mailbox") For Each objExchange_Mailbox in listExchange_Mailboxs WScript.echo "AssocContentCount =” + objExchange_Mailbox.AssocContentCount WScript.echo " DateDiscoveredAbsentInDS =” + objExchange_Mailbox.DateDiscoveredAbsentInDS WScript.echo " DeletedMessageSizeExtended =” + objExchange_Mailbox. DeletedMessageSizeExtended WScript.echo " LastLoggedOnUserAccount =” + objExchange_Mailbox. LastLoggedOnUserAccount WScript.echo " LastLogoffTime =” + objExchange_Mailbox. LastLogoffTime WScript.echo " LastLogonTime =” + objExchange_Mailbox. LastLogonTime WScript.echo " LegacyDN =” + objExchange_Mailbox. LegacyDN WScript.echo " MailboxDisplayName =” + objExchange_Mailbox. MailboxDisplayName WScript.echo " MailboxGUID =” + objExchange_Mailbox. MailboxGUID WScript.echo " ServerName =” + objExchange_Mailbox. ServerName WScript.echo " Size =” + objExchange_Mailbox. Size WScript.echo " StorageGroupName =” + objExchange_Mailbox. StorageGroupName WScript.echo " StorageLimitInfo =” + objExchange_Mailbox. StorageLimitInfo WScript.echo " StoreName =” + objExchange_Mailbox. StoreName WScript.echo " TotalItems =” + objExchange_Mailbox. TotalItems Next get-mailboxstatistics – server $servername Database Mgmt Dim StorGroup as New CDOEXM.StorageGroup StorGroup.DataSource.Open "LDAP://" + DCServer + "/ CN=First Storage Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group, CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services, CN=Configuration," + DomainName StorGroup.MoveLogFiles("C:\newlogPath", 0) move-storagegrouppath -identity “First Storage Group“ – log "C:\newlogPath” Recipient Mgmt Dim objMailbox As CDOEXM.IMailboxStore Set objMailbox = GetObject("LDAP://" + DCServer + "CN=FOO,CN=users," + DomainName) objMailbox.CreateMailbox "LDAP://" + DCServer + "/CN=Private MDB,CN=First Storage Group,CN=InformationStore,CN=" + Server + ",CN=Servers,CN=First Administrative Group, CN=Administrative Groups,CN=First Organization, CN=Microsoft Exchange,CN=Services, CN=Configuration," + DomainName enable-mailbox -identity domain\FOO – database “First Storage Group\Private MDB”
  • 20.
    Exchange 2007 ManagementArchitecture CLI GUI Setup Process Boundary Exchange cmdlets Configuration Data Objects/Access PowerShell Data Provider PowerShell Engine Windows Forms Early-bound objs Windows Forms ADO.NET MAPI Store Registry Meta base AD
  • 21.
    Get-Command Get-Help Get-MemberGet-PSDrive Get the Free eBook and information about the 4 most important CmdLets http://tinyurl.com/powershell4
  • 22.
  • 23.
  • 24.
  • 25.
    Verb – NounClear – Host Set – ExecutionPolicy Get – Help Write – Debug Restart – Computer Don’t do this during session, but -whatif you did? Drink – Beer Do this before session 
  • 26.
  • 27.
  • 28.
  • 29.
    The PowerShell pipelineGet-Process | Where { $_.handles –gt 500 } | Sort handles | Format-Table Get-Process Cmdlet Common Windows PowerShell Parser Windows PowerShell Pipeline Processor Where-Object Cmdlet Sort -Object Cmdlet Format-Table Cmdlet Alias Alias
  • 30.
    A Review CmdletsTiny commands Composability Providers Abstraction of drives Discoverability Snap-ins Unit of deployment Wraps cmdlets, providers, etc PS C:\> Get-Process PS C:\> cd HKLM: PS HKLM:\ > PS C:\> add-pssnapin MySnapIn
  • 31.
    Modifying the systemSupport -confirm and -whatif operations CmdletAttribute[..., SupportsShouldProcess = true ] Call ShouldProcess for initial confirmation Are you sure? Call ShouldContinue for additional confirmation Are you really sure? Enable/disable “yes to all” and “no to all” options Provide a “force” parameter to bypass these calls Specify the impact of the cmdlet Allows user to set the confirm sensitivity CmdletAttribute[..., ConfirmImpact = ConfirmImpact.High ]
  • 32.
    Extending Windows PowerShellAliases Functions Cmdlets Write them in .NET (v1) Write them in PowerShell (v2) Providers IIS, SQL, Exchange, Yours Custom Hosts http://blogs.msdn.com/daiken/archive/2007/06/22/hosting-windows-powershell-sample-code.aspx
  • 33.
  • 34.
  • 35.
  • 36.
    Extended Type System(ETS) Type Adapters provide consistent object access across different technologies .NET, COM, WMI, ADSI, XML, ADO Allows scripts to be general regardless of “native” object interaction Scripts can be based on property names not programming knowledge classes and types Object utilities work against all objects http://www.flickr.com/photos/foundphotoslj/449085680/
  • 37.
    Shell Defaults Noscripts run (ExecutionPolicy=Restricted) .ps1 is associated with Notepad Must provide a path to a script file in order to run it You Can Configure ExecutionPolicy Restricted AllSigned RemoteSigned Unrestricted (No!!!) Centrally configurable via Group Policy In V2 Constrain Runspaces
  • 38.
    Resources! Team bloghttp://blogs.msdn.com/PowerShell/ PowerShellCommunity.Org http://www.PowershellCommunity.Org Channel 9 http://channel9.msdn.com/tags/PowerShell http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki Script Center http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx CodePlex http://codeplex.com/Project/ProjectDirectory.aspx?TagName=powershell Books I own Manning Press book by PowerShell Dev Lead Bruce Payette: PowerShell in Action http://manning.com/powershell/ O’Reilly book by PowerShell Dev Lee Holmes – Windows PowerShell Cookbook http://www.oreilly.com/catalog/9780596528492/index.html Newsgroup: Microsoft.Public.Windows.PowerShell
  • 39.
    Out-Thankyou PS C:\>Thank you for your time and attention. Good luck in your PowerShell Adventures! Get-Allandcp PS C:\> Allan da Costa Pinto Microsoft [email_address] http://blogs.msdn.com/allandcp