Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... ·...

20
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/

Transcript of Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... ·...

Page 1: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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/

Page 2: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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

Page 3: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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

Page 4: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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é

Page 5: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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

Page 6: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

6

Thèmes PowerShell 2.0

Scripts de production

Environnement automatisé

Langage & Cmdlets

Interface graphique & PowerShell

Page 7: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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

Page 8: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

8

Interface graphique & PowerShell

Page 9: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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

Page 10: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

11

Scripts de production : Fonctions avancées Modules Aide

Page 11: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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

Page 12: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

15

Environnement automatisé : Jobs Exécution à distance Evènements

Page 13: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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++

Page 14: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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

Page 15: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

18

Un dernier exemple…

Page 16: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

19

PoshBoard V2 par Antoine Habert MVP PowerShell

Page 17: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

20

A retenir Windows PowerShell V2 en action

Interface graphique

Fonctions avancées

Modules Aide

Remoting Jobs Eventing

Page 18: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

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)

Page 19: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

22

Page 20: Windows PowerShell V2 en actiondownload.microsoft.com/documents/France/MSDAYS/2009/... · 2018-12-05 · 2 Agenda Windows PowerShell V2 en action Introduction Nouvelles fonctionnalités

© 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