windows powershell v2 en actiondownload.microsoft.com/documents/france/msdays/2009/... ·...
TRANSCRIPT
1
Windows PowerShell V2 en action
Patrick Guimonet Architecte Microsoft France http://blogs.technet.com/powershell
Antoine Habert MVP PowerShell
Nelite http://www.devinfra.blogspot.com/
2
Agenda Windows PowerShell V2 en action
Introduction
Nouvelles fonctionnalités Démo 1 : Interface graphique & PowerShell
Démo 2
Démo 3
Démo 4
PoshBoard V2
Conclusion
3
• Inspiré des langages de scripts UNIX : ksh, bash, perl, …
• Mais spécifiquement Windows car reposant sur l'environnement .Net
• Syntaxe proche du C#
• Tous les produits serveurs de Microsoft doivent supporter PowerShell
Windows PowerShell Le langage de lignes de commande et de scripts
4
Exchange 2003 (VBScript) Exchange 2007 (PowerShell)
Mailbox Statistics
Set listExchange_Mailboxs =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\COMPUTERNAME\ROOT\MicrosoftExch
angeV2").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”
Productivité
5
Architecture de PowerShell
Expérience utilisateur
Shell
Langage
Debugger
Moteur
APIs
Contexte d'exécution
Gestionnnaire d'objets
Eléments gérés
Cmdlets
WMI
COM
.NET
XML
ADO
ADSI
Commandes natives
6
Thèmes PowerShell 2.0
Scripts de production
Environnement automatisé
Langage & Cmdlets
Interface graphique & PowerShell
7
Interface graphique & PowerShell
Expérience utilisateur
Shell
Langage
Debugger
Moteur
APIs
Contexte d'exécution
Gestionnnaire d'objets
Eléments gérés
Cmdlets
WMI
COM
.NET
XML
ADO
ADSI
Commandes natives
Console graphique
Out-Gridview
Nouvelles APIs
PSSession Pooling
Contrôle de Thread
Bibliothèques graphiques
8
Interface graphique & PowerShell
10
Scripts de production
Expérience utilisateur
Shell
Langage
Debugger
Moteur
APIs
Contexte d'exécution
Gestionnnaire d'objets
Eléments gérés
Cmdlets
WMI
COM
.NET
XML
ADO
ADSI
Commandes natives
Restricted Language
Modules
Debugger
Transactions
Code natif
Fonctions avancées
Fonctions avancées
11
Scripts de production : Fonctions avancées Modules Aide
12
Environnement automatisé
Expérience utilisateur
Shell
Langage
Debugger
Moteur
APIs
Contexte d'exécution
Gestionnnaire d'objets
Eléments gérés
Cmdlets
WMI
COM
.NET
XML
ADO
ADSI
Commandes natives
Execution à distance
Jobs
Evènements
Sessions restraintes
Mobile Object Model
15
Environnement automatisé : Jobs Exécution à distance Evènements
16
Retours de la communauté
Expérience utilisateur
Shell
Langage
Debugger
Moteur
APIs
Contexte d'exécution
Gestionnnaire d'objets
Eléments gérés
Cmdlets
WMI
COM
.NET
XML
ADO
ADSI
Commandes natives
Améliorations du langage
Adaptateurs d'objets
améliorés
Nouvelles Cmdlets
WMI++
17
Nouvelles Cmdlets …. Remoting:
Invoke-Command New-PSSession Get-PSSession Push-PSSession Pop-PSSession Remove-PSSession
Converting Types: Add-Type ConvertTo-Csv ConvertFrom-Csv ConvertTo-Xml ConvertFrom-StringData
Event Viewer and ETW Logs: Get-Event
Script Internationalization: Import-LocalizedData
Modules: Imort-Module Get-Module Remove-Module Export-ModuleMember
Transactions: Complete-Transaction Start-Transaction Undo-Transaction Use-Transaction
Debugging:
Set-PSBreakpoint
Get-PSBreakpoint
Enable-PSBreakpoint
Disable-PSBreakpoint
Remove-PSBreakpoint
Get-PSCallStack
Eventing:
Register-ObjectEvent
Register-Event
Wait-Event
Remove-Event
Unregister-Event
Get-Event
New-Event
Get-EventSubscriber
Background Jobs:
Start-Job
Get-Job
Stop-Job
Receive-Job
Wait-Job
Remove-Job
WMI: Register-WMIEvent
Set-WMIInstance
Invoke-WMIMethod
Remove-WMIObject
More Cmdlets: Clear-History
Get-Random
Out-GridView
Set-StrictMode
Update-List
Wait-Process
Computer Add-Computer
Checkpoint-Computer
Disable-ComputerRestore
Enable-ComputerRestore
Get-ComputerRestorePoint
Remove-Computer
Rename-Computer
Reset-ComputerMachinePassword
Restart-Computer
Restore-Computer
Stop-Computer
Test-ComputerSecureChannel
18
Un dernier exemple…
19
PoshBoard V2 par Antoine Habert MVP PowerShell
20
A retenir Windows PowerShell V2 en action
Interface graphique
Fonctions avancées
Modules Aide
Remoting Jobs Eventing
21
Et ensuite ?
S’informer sur Powershell
http://blogs.technet.com/powershell
http://blogs.msdn.com/powershell
Blog d'Antoine Habert
http://www.devinfra.blogspot.com
Télécharger la version http://blogs.msdn.com/powershell (en haut à droite)
22
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,
IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Votre potentiel, notre passion TM