SlideShare une entreprise Scribd logo
Windows PowerShell  une nouvelle approche de l’administration des environnements Windows
Objectif Pour les néophiques : découvrir Windows PowerShell Pour les experts : comment étendre Windows Powershell Pas trop de blabla, des démonstrations !!
Windows PowerShell Windows PowerShell est une invite de commande (shell) interactive et un environnement de scripts offrant une manière de traiter des tâches  orientée commandes .  Les concepteurs ont suivi différentes approches afin que PowerShell soit : aussi  interactif  et  composable  que KSH ou BASH, aussi  programmable  que PERL ou RUBY, aussi  orienté-production  que VMS DCL ou AS400 CL. permettre l’accès aux sources de données aussi  facilement  que l’accès au système de fichiers
Agenda Découverte de Windows PowerShell Windows PowerShell et l’administration Etendre Windows PowerShell
Découverte de  PowerShell
Mieux comprendre la structure et les bénéfices de PowerShell !  « J’ai refait tous les calculs, ils confirment l’opinion des spécialistes : mon idée est irréalisable. Il ne me reste plus qu’une seule chose à faire : la réaliser »  Pierre-Georges Latécoère.
Découverte de PowerShell Les bases Le modèle des commandes Que manipule-t-on ? Expressions, Variables, Types Le pipeline & les filtres Constructions du langage Opérateurs Tests & boucles Intégration avec le système Lecteurs étendus WMI COM
Ressemblances et parenté Le cœur du langage est basé sur la norme POSIX 1003.2 suivie par  Korn shell . Il ressemble beaucoup à  PHP  et  Perl . La syntaxe a été alignée sur  C# On peut donc très facilement convertir du code  C#  en PS et réciproquement
Configuration de PowerShell Version 1.0 Pré-requis  :  Framework .Net 2.0 Disponible pour: http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx   Windows Server Code Name Longhorn Une « feature » à installer Pas installée par défaut Pas disponible avec « Server Core » x86 x64 IA64 Windows Server 2003 SP1 Une mise à jour système entre le SP1 et le SP2 (KB926139, 140, 141) A télécharger x86 x64 IA64 Windows Vista Une mise à jour  (KB928439) A télécharger x86 x64 Windows XP SP2 Une mise à jour système  (KB926139, 140, 141) A télécharger x86 x64
Multi-langues Version anglaise (KB926139) Ou version localisée en 10 autres langues (KB926140) : ou MUI (KB926141)
Homogénéité & Cohérence Get-Command   sur le modèle : avec un certain nombre de paramètres omniprésents : <verb>-<nom> Plus de détails :  help about-parameter  help about_commonparameters
Les 4 commandes de découverte Get-Command   informations de base sur les commandes Get-help aide de base  (utiliser  –full ) Get-member informations sur les objets Get-PSDrive informations sur les lecteurs étendus Get-command Get-help Get-member Get-psdrive parmi 129 commandes intégrées ou “ cmdlets ”  commandettes ?
5 categories de commandes Plus de détails :  get-command * | group commandtype
Manipulation des objets du langage
Tout est objet ! (date).adddays(100)
Le Pipeline gps|?{$_.handles -gt 500}|sort handles|ft name,handles gps (Get-Process) CLR PowerShell Engine ? (Where-Object) sort (Sort-Object) ft (Format-Table) (Out-Host) gps|?{$_.handles -gt 500}|sort handles|ft name,handles
L’accès aux objets est uniformisé ! .Net Object Adapter WMI Object Adapter COM Object Adapter Other Adapters : ADSI , ADO… Custom Object Adapter .Net Object WMI Object Script PowerShell accédant à un objet COM Object
Les Types
PowerShell et les nombres Plus de détails :  [math] | get-member -static
Les opérateurs PowerShell Plus de détails :  help about*operator*
Les instructions de contrôle de flux
Traitement d’erreurs
Fournisseurs et magasins de données
PowerShell et les fichiers
PowerShell et le texte
Les ordres de formatage
PowerShell et XML
PowerShell et l’accès au système
PowerShell et COM
PowerShell et .Net
Stratégie d’éxécution Contrôle ce qui peut être exécuté Get-ExecutionPolicy Set-ExecutionPolicy Set-ExecutionPolicy UnRestricted Plus de détails :  help about_signing
Accès universel ! ADSI  & ADO .Net webservice TXT Services & Processus WMI COM
Que faut-il retenir ? Une syntaxe homogène :  verbe-nom Les 4 commandes de base : Get-command, get-help, get-member, get-psdrive Tout est objet ! Le pipeline aussi ! Interactions avec le système via : Text & XML COM & .Net WMI et EventLog Sécurisé
Windows PowerShell et l’administration
L’administration  Outils d’administration « graphique » Outils en ligne de commande natifs (cmd, exe, etc…) Scripting Windows    Automatiser les tâches d'administration VBScript, WSH, WMI, ADSI, CDO et les objets COM
Windows PowerShell et l’administration L'objectif :  Améliorer  et  faciliter  le contrôle administratif sur les systèmes, que ce soit de manière interactive ou par le biais de scripts. Gestion des processus locaux  Gestion de services locaux Collecte d'informations sur des ordinateurs Utilisation d'installations logicielles  Changement d'état de l'ordinateur : verrouillage, fermeture de session, arrêt en cours et redémarrage  Utilisation d'imprimantes  Tâches de gestion de réseau  Utilisation des fichiers et dossiers Utilisation du registre
Au cœur des solutions d’entreprise
 
Etendre Windows PowerShell
Etendre Windows PowerShell Comment fonctionne Windows PowerShell Les différentes manières d’étendre Windows PowerShell
 
Functions/Filters/Scripts Cmdlets Providers Hosts
Etendre PowerShell
Shared Source development effort for Cmdlets, Providers, Aliases, Filters, Functions, and Scripts Cmdlets: Less, *ClipBoard, TabExpansion, convert*,Format*,Get*,Write* Providers Directory Services, GAC PSCX V1.1 available now http://www.codeplex.com/PowerShellCX
Communauté Française :  http://www.powershell-scripting.com/ Newsgroup:  Microsoft.Public.Windows.PowerShell Team blog:  http://blogs.msdn.com/PowerShell/ Channel 9 tag:  http://channel9.msdn.com/tags/PowerShell OMark van Orsouw’s blog:  http://ThePowerShellGuy.Com Wiki:   http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki Script Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx Manning Press book by Bruce Payette:  PowerShell in Action  http://manning.com/powershell/   O’Reilly book – Monad:  Introducing the MSH Command Shell and Language  http://www.oreilly.com/catalog/msh/ Sapien Press book by Don Jones: PowerShell http://www.sapienpress.com/ MshAnalyzer tool http://www.karlprosser.com/coder/?cat=8
Questions?
Ressources Technical Chats and Webcasts http://www.microsoft.com/communities/chats/default.mspx   http://www.microsoft.com/usa/webcasts/default.asp Microsoft Learning and Certification http://www.microsoft.com/learning/default.mspx MSDN & TechNet  http://microsoft.com/msdn http://microsoft.com/technet Virtual Labs http://www.microsoft.com/technet/traincert/virtuallab/rms.mspx Newsgroups http://communities2.microsoft.com/ communities/newsgroups/en-us/default.aspx Technical Community Sites http://www.microsoft.com/communities/default.mspx User Groups http://www.microsoft.com/communities/usergroups/default.mspx
. Scripts . News . Tutoriaux . Forum www.PowerShell-Scripting.com Entrez dans la communauté francophone Profitez d’un partage de connaissances autour de PowerShell
Ressources
© 2007 Microsoft France Votre potentiel, notre passion  TM
Reference Slides
Access existing instrumentation Bind to COM objects $fso = New-Object -ComObject Scripting.FileSystemObject $m = [System.Runtime.InteropServices.Marshal] $word = $m::GetActiveObject(&quot;Word.Application&quot;)  Invoke methods/access properties $fso.GetDrive(“C:”) $fso.VolumeName = “System Drive” Understand/extend instrumentation Extend and discover properties/methods Update-TypeData Office.Word.Types.ps1xml $fso | Get-Member Manipulate and format results Define and import custom formating Update-FormatData  Office.Word.Format.ps1xml $word.RecentFiles | Sort name | Format-Table  Allows more simpler/more powerful COM scripts because of utilities and formatting
PowerShell provides native WMI support Get-WmiObject Allows for inspection of WMI namespace Get-WmiObject –list [-Namespace xx] Get-WmiObject –Class xx –Namespace xx –Property xxx – Filter xxx –ComputerName xxx –Credential xxx Native language support [WMI] “\\JPSDESK10\root\cimv2:Win32_Process.Handle=&quot;0“ [WMICLASS] &quot;ROOT\cimv2:WIN32_PROCESS&quot; [WMISEARCHER]&quot;select * from Win32_process WHERE Name = 'calc.exe'&quot;
PowerShell provides native access to any .NET class Create any object [reflection.assembly]::LoadWithPartialName(&quot;System.Windows.Forms&quot;) $d = New-Object System.DateTime 2006,12,25 Access Properties/Invoke Methods $d.DayOfWeek $d.AddDays(-30) Access Statics [DateTime]::Now [DateTime]::IsLeapYear(2006)  Allows admins to easily access and leverage a huge API set because of scriptability, utilities and formatting
PowerShell provides native XML support Native datatype $x=[xml]&quot;<a><b><c>TEST</c></b></a>“ $b =[xml](type c:\i386\mssecure.xml) Native syntax to access “data” view of properties $b.BulletinDataStore.Bulletins.Bulletin[0] Access to XML methods  $b.BulletinDataStore.SelectNodes(“//Patch”) XML properties available through PSBase property $b.BulletinDataStore.PSBase.innerXml
Invoke existing tools  Existing command run directly after variables are expanded Harvest data from existing tools Parse output into variables using text utilities.  Pipe data to SELECT and use –FIRST and –LAST  Select-String <REGEX> <Path> Dir | Select-String <REGEX> [DateTime]”12/25/2006 7:00” ([DateTime]”12/25/2006 7:00”).AddDays(-30) Use functions/scripts to wrap the commands and convert output to objects or provide standard syntax Safely  process text Use CLR types via Windows PowerShell to safely parse text [URI]” http://blogs.msdn.com/powershell/archive/2006/04/25/583234.aspx” Allows admins to get 2-10x more power out of existing commands because of scriptability

Contenu connexe

PDF
Tuto VP IPSEC Site-to-site
PPTX
Bagaimana Torrent Bekerja
PDF
Étude et mise en place d'un serveur messengerie
PDF
Rapport sécurité
PPTX
Wazuh Pre.pptx
PDF
vpn-site-a-site-avec-des-routeurs-cisco
PDF
Chapitre 11: Expression Lambda et Référence de méthode en Java
PDF
Ieee 802.1 x
Tuto VP IPSEC Site-to-site
Bagaimana Torrent Bekerja
Étude et mise en place d'un serveur messengerie
Rapport sécurité
Wazuh Pre.pptx
vpn-site-a-site-avec-des-routeurs-cisco
Chapitre 11: Expression Lambda et Référence de méthode en Java
Ieee 802.1 x

Tendances (20)

PDF
Premiers pas avec snort
PDF
Algorithmes de tri
PDF
Introduction to SIP(Session Initiation Protocol)
PDF
Tp2 - WS avec JAXRS
PDF
Tp soa avec talend esb
PPT
Présentation SOA
PDF
Connexion point à point (ppp, hdlc)
PDF
Cours informatique chapitre 1 ordinateur et système d'exploitation 7ème
PDF
Support programmation orientée objet c# .net version f8
DOCX
Résumer sur les fichier et les enregistrement
PPT
Les Contraintes | SQL Oracle
PDF
Gestion des threads
PPTX
Les collections en Java
PPT
CCNA Exploration 1 - Chapter 1
PDF
Chapitre 2 complexité
DOCX
Les trames reseaux
PDF
Cours photo filtre - collège pilote Tunisie
PPTX
OSI Model VS TCP/IP Model|| Difference Between them
PPTX
Chp2 - Vers les Architectures Orientées Services
PDF
Développement informatique : Programmation réseau
Premiers pas avec snort
Algorithmes de tri
Introduction to SIP(Session Initiation Protocol)
Tp2 - WS avec JAXRS
Tp soa avec talend esb
Présentation SOA
Connexion point à point (ppp, hdlc)
Cours informatique chapitre 1 ordinateur et système d'exploitation 7ème
Support programmation orientée objet c# .net version f8
Résumer sur les fichier et les enregistrement
Les Contraintes | SQL Oracle
Gestion des threads
Les collections en Java
CCNA Exploration 1 - Chapter 1
Chapitre 2 complexité
Les trames reseaux
Cours photo filtre - collège pilote Tunisie
OSI Model VS TCP/IP Model|| Difference Between them
Chp2 - Vers les Architectures Orientées Services
Développement informatique : Programmation réseau
Publicité

En vedette (20)

PDF
Rapport Administration des systémes Linux (Shells bash)
PDF
Per lameliorer
PPTX
Cool Feature in PoweShell - Out gridview cmlet
DOCX
Business Propsal
PPTX
Webinar azuretalk
PDF
30 Excel Tips in 30 Minutes
PPTX
PowerShell - Be A Cool Blue Kid
PPTX
Powershell
PPTX
Powershell
 
PDF
Exchange Server 2010
PPT
PPTX
Réduisez vos Coûts d'Administration et les Risques d'erreurs avec Windows Pow...
PPT
2008-09-30 Administration automatisée avec Powershell
PPTX
Power Shell V2 en action - avec Posh Board 2.0
PPTX
Powershell et les techniques de remoting
PDF
360 Degrees Credentials Presentation
PDF
Writing Modular Command-line Apps with App::Cmd
PPTX
Using PowerShell for active directory management
PDF
F Les Scripts En Power Shell
Rapport Administration des systémes Linux (Shells bash)
Per lameliorer
Cool Feature in PoweShell - Out gridview cmlet
Business Propsal
Webinar azuretalk
30 Excel Tips in 30 Minutes
PowerShell - Be A Cool Blue Kid
Powershell
Powershell
 
Exchange Server 2010
Réduisez vos Coûts d'Administration et les Risques d'erreurs avec Windows Pow...
2008-09-30 Administration automatisée avec Powershell
Power Shell V2 en action - avec Posh Board 2.0
Powershell et les techniques de remoting
360 Degrees Credentials Presentation
Writing Modular Command-line Apps with App::Cmd
Using PowerShell for active directory management
F Les Scripts En Power Shell
Publicité

Similaire à Powershell (20)

PPTX
Les nouveautés de PowerShell 3.0
PPTX
Powershell overview
PDF
alphorm.com - Formation Powershell 2.0
PDF
Power Shell V2 Full
PPTX
EXO_Rguibi_marwan.pptx
PPTX
Power shell saturday Paris 2017 Omiossec
PPTX
PowerShell mtl-dev 2015
PPTX
PowerShell - NIk Charlebois
PPTX
Retour d'expérience sur PowerShell
PPTX
Automatiser le déploiement d'environnements SharePoint 2010/2013 grâce à Powe...
PPTX
Automatiser le déploiement d'environnements SharePoint 2010/2013 grâce à Powe...
PPTX
Presentation sur la technologie powershell.pptx
PPT
Formation Script MS-DOS.ppt
PPTX
certification MCSA: Windows Server 2012 22410B_04.pptx
PPTX
PowerShell - Retours d'expériences
PPTX
Gestion-des-parcs-informatiques Windows et Linux.pptx
PPTX
PowerShell pour Office 365 & SharePoint / yosTour Lyon / Gilles Pommier | Eti...
PDF
2018-10-17 J1 4B - Présentation METSYS débuter avec PowerShell DSC- Thomas Il...
PPTX
Déploiement et destion de windows server
PPTX
Sp summit2014 session 10-2
Les nouveautés de PowerShell 3.0
Powershell overview
alphorm.com - Formation Powershell 2.0
Power Shell V2 Full
EXO_Rguibi_marwan.pptx
Power shell saturday Paris 2017 Omiossec
PowerShell mtl-dev 2015
PowerShell - NIk Charlebois
Retour d'expérience sur PowerShell
Automatiser le déploiement d'environnements SharePoint 2010/2013 grâce à Powe...
Automatiser le déploiement d'environnements SharePoint 2010/2013 grâce à Powe...
Presentation sur la technologie powershell.pptx
Formation Script MS-DOS.ppt
certification MCSA: Windows Server 2012 22410B_04.pptx
PowerShell - Retours d'expériences
Gestion-des-parcs-informatiques Windows et Linux.pptx
PowerShell pour Office 365 & SharePoint / yosTour Lyon / Gilles Pommier | Eti...
2018-10-17 J1 4B - Présentation METSYS débuter avec PowerShell DSC- Thomas Il...
Déploiement et destion de windows server
Sp summit2014 session 10-2

Plus de UGAIA (20)

PDF
Guide G·IA-GENEALOGIE et Artificielle Intelligence Version 0.1
PDF
Grille de contrôle de l'intelligence artificielle
PPTX
Présentation sur l'Intelligence Artificielle et ses Métiers
PDF
Intelligence Artificielle et ses Métiers
PDF
Les Metiers de IA la Listes et les axes principaux
PDF
Les métiers dans l'Intelligence Artificielle
PDF
Plan de Travail et questionnaire en 8 points pour la Gouvernance de l'IA
PDF
AUDITs et PLANs avec T2B incluant les KPIs pour un PLAN DE GOUVERNANCE.
PDF
Création d’un agent pour le CHAT Mistral avec des questions sur la généalogie.
PDF
Mes 15 Livres Users Group Artificial Intelligence Andorra (U.G.A.I.A.)
PDF
Tableau Tarifs et Fonctionnalités de 6 IA.pdf
PDF
Ma Lettre numéro 1 sur l'intelligence artificielle et la G·IA
PDF
Formations-IA-Liens de mes lectures Lettre G·IA
PPTX
HISTORIQUE de l'Intelligence Artificielle par l'UGAIA Users Group Artificial...
PDF
Des OUTILS pour l'IA : un tableau sur GOUVERNANCES ET DE PILOTAGES.
PPTX
Copilot - Documents de formation pour les utilisateurs par UGAIA
PPTX
Les principales percées de l’IA – COPILOT – BING – GPT – W12… par UGAIA
PPTX
Chronologie et historique des principales percées de l’IA
PPTX
Les fondamentaux d’une IA générative responsable et éthique...
PPTX
Cadre Éthique et Conformité pour l'IA dans les Entreprises
Guide G·IA-GENEALOGIE et Artificielle Intelligence Version 0.1
Grille de contrôle de l'intelligence artificielle
Présentation sur l'Intelligence Artificielle et ses Métiers
Intelligence Artificielle et ses Métiers
Les Metiers de IA la Listes et les axes principaux
Les métiers dans l'Intelligence Artificielle
Plan de Travail et questionnaire en 8 points pour la Gouvernance de l'IA
AUDITs et PLANs avec T2B incluant les KPIs pour un PLAN DE GOUVERNANCE.
Création d’un agent pour le CHAT Mistral avec des questions sur la généalogie.
Mes 15 Livres Users Group Artificial Intelligence Andorra (U.G.A.I.A.)
Tableau Tarifs et Fonctionnalités de 6 IA.pdf
Ma Lettre numéro 1 sur l'intelligence artificielle et la G·IA
Formations-IA-Liens de mes lectures Lettre G·IA
HISTORIQUE de l'Intelligence Artificielle par l'UGAIA Users Group Artificial...
Des OUTILS pour l'IA : un tableau sur GOUVERNANCES ET DE PILOTAGES.
Copilot - Documents de formation pour les utilisateurs par UGAIA
Les principales percées de l’IA – COPILOT – BING – GPT – W12… par UGAIA
Chronologie et historique des principales percées de l’IA
Les fondamentaux d’une IA générative responsable et éthique...
Cadre Éthique et Conformité pour l'IA dans les Entreprises

Powershell

  • 1. Windows PowerShell une nouvelle approche de l’administration des environnements Windows
  • 2. Objectif Pour les néophiques : découvrir Windows PowerShell Pour les experts : comment étendre Windows Powershell Pas trop de blabla, des démonstrations !!
  • 3. Windows PowerShell Windows PowerShell est une invite de commande (shell) interactive et un environnement de scripts offrant une manière de traiter des tâches orientée commandes . Les concepteurs ont suivi différentes approches afin que PowerShell soit : aussi interactif et composable que KSH ou BASH, aussi programmable que PERL ou RUBY, aussi orienté-production que VMS DCL ou AS400 CL. permettre l’accès aux sources de données aussi facilement que l’accès au système de fichiers
  • 4. Agenda Découverte de Windows PowerShell Windows PowerShell et l’administration Etendre Windows PowerShell
  • 5. Découverte de PowerShell
  • 6. Mieux comprendre la structure et les bénéfices de PowerShell ! « J’ai refait tous les calculs, ils confirment l’opinion des spécialistes : mon idée est irréalisable. Il ne me reste plus qu’une seule chose à faire : la réaliser » Pierre-Georges Latécoère.
  • 7. Découverte de PowerShell Les bases Le modèle des commandes Que manipule-t-on ? Expressions, Variables, Types Le pipeline & les filtres Constructions du langage Opérateurs Tests & boucles Intégration avec le système Lecteurs étendus WMI COM
  • 8. Ressemblances et parenté Le cœur du langage est basé sur la norme POSIX 1003.2 suivie par Korn shell . Il ressemble beaucoup à PHP et Perl . La syntaxe a été alignée sur C# On peut donc très facilement convertir du code C# en PS et réciproquement
  • 9. Configuration de PowerShell Version 1.0 Pré-requis : Framework .Net 2.0 Disponible pour: http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx Windows Server Code Name Longhorn Une « feature » à installer Pas installée par défaut Pas disponible avec « Server Core » x86 x64 IA64 Windows Server 2003 SP1 Une mise à jour système entre le SP1 et le SP2 (KB926139, 140, 141) A télécharger x86 x64 IA64 Windows Vista Une mise à jour (KB928439) A télécharger x86 x64 Windows XP SP2 Une mise à jour système (KB926139, 140, 141) A télécharger x86 x64
  • 10. Multi-langues Version anglaise (KB926139) Ou version localisée en 10 autres langues (KB926140) : ou MUI (KB926141)
  • 11. Homogénéité & Cohérence Get-Command sur le modèle : avec un certain nombre de paramètres omniprésents : <verb>-<nom> Plus de détails : help about-parameter help about_commonparameters
  • 12. Les 4 commandes de découverte Get-Command informations de base sur les commandes Get-help aide de base (utiliser –full ) Get-member informations sur les objets Get-PSDrive informations sur les lecteurs étendus Get-command Get-help Get-member Get-psdrive parmi 129 commandes intégrées ou “ cmdlets ” commandettes ?
  • 13. 5 categories de commandes Plus de détails : get-command * | group commandtype
  • 15. Tout est objet ! (date).adddays(100)
  • 16. Le Pipeline gps|?{$_.handles -gt 500}|sort handles|ft name,handles gps (Get-Process) CLR PowerShell Engine ? (Where-Object) sort (Sort-Object) ft (Format-Table) (Out-Host) gps|?{$_.handles -gt 500}|sort handles|ft name,handles
  • 17. L’accès aux objets est uniformisé ! .Net Object Adapter WMI Object Adapter COM Object Adapter Other Adapters : ADSI , ADO… Custom Object Adapter .Net Object WMI Object Script PowerShell accédant à un objet COM Object
  • 19. PowerShell et les nombres Plus de détails : [math] | get-member -static
  • 20. Les opérateurs PowerShell Plus de détails : help about*operator*
  • 21. Les instructions de contrôle de flux
  • 24. PowerShell et les fichiers
  • 26. Les ordres de formatage
  • 31. Stratégie d’éxécution Contrôle ce qui peut être exécuté Get-ExecutionPolicy Set-ExecutionPolicy Set-ExecutionPolicy UnRestricted Plus de détails : help about_signing
  • 32. Accès universel ! ADSI & ADO .Net webservice TXT Services & Processus WMI COM
  • 33. Que faut-il retenir ? Une syntaxe homogène : verbe-nom Les 4 commandes de base : Get-command, get-help, get-member, get-psdrive Tout est objet ! Le pipeline aussi ! Interactions avec le système via : Text & XML COM & .Net WMI et EventLog Sécurisé
  • 34. Windows PowerShell et l’administration
  • 35. L’administration Outils d’administration « graphique » Outils en ligne de commande natifs (cmd, exe, etc…) Scripting Windows  Automatiser les tâches d'administration VBScript, WSH, WMI, ADSI, CDO et les objets COM
  • 36. Windows PowerShell et l’administration L'objectif : Améliorer et faciliter le contrôle administratif sur les systèmes, que ce soit de manière interactive ou par le biais de scripts. Gestion des processus locaux Gestion de services locaux Collecte d'informations sur des ordinateurs Utilisation d'installations logicielles Changement d'état de l'ordinateur : verrouillage, fermeture de session, arrêt en cours et redémarrage Utilisation d'imprimantes Tâches de gestion de réseau Utilisation des fichiers et dossiers Utilisation du registre
  • 37. Au cœur des solutions d’entreprise
  • 38.  
  • 40. Etendre Windows PowerShell Comment fonctionne Windows PowerShell Les différentes manières d’étendre Windows PowerShell
  • 41.  
  • 44. Shared Source development effort for Cmdlets, Providers, Aliases, Filters, Functions, and Scripts Cmdlets: Less, *ClipBoard, TabExpansion, convert*,Format*,Get*,Write* Providers Directory Services, GAC PSCX V1.1 available now http://www.codeplex.com/PowerShellCX
  • 45. Communauté Française : http://www.powershell-scripting.com/ Newsgroup: Microsoft.Public.Windows.PowerShell Team blog: http://blogs.msdn.com/PowerShell/ Channel 9 tag: http://channel9.msdn.com/tags/PowerShell OMark van Orsouw’s blog: http://ThePowerShellGuy.Com Wiki: http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellWiki Script Center: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx Manning Press book by Bruce Payette: PowerShell in Action http://manning.com/powershell/ O’Reilly book – Monad: Introducing the MSH Command Shell and Language http://www.oreilly.com/catalog/msh/ Sapien Press book by Don Jones: PowerShell http://www.sapienpress.com/ MshAnalyzer tool http://www.karlprosser.com/coder/?cat=8
  • 47. Ressources Technical Chats and Webcasts http://www.microsoft.com/communities/chats/default.mspx http://www.microsoft.com/usa/webcasts/default.asp Microsoft Learning and Certification http://www.microsoft.com/learning/default.mspx MSDN & TechNet http://microsoft.com/msdn http://microsoft.com/technet Virtual Labs http://www.microsoft.com/technet/traincert/virtuallab/rms.mspx Newsgroups http://communities2.microsoft.com/ communities/newsgroups/en-us/default.aspx Technical Community Sites http://www.microsoft.com/communities/default.mspx User Groups http://www.microsoft.com/communities/usergroups/default.mspx
  • 48. . Scripts . News . Tutoriaux . Forum www.PowerShell-Scripting.com Entrez dans la communauté francophone Profitez d’un partage de connaissances autour de PowerShell
  • 50. © 2007 Microsoft France Votre potentiel, notre passion TM
  • 52. Access existing instrumentation Bind to COM objects $fso = New-Object -ComObject Scripting.FileSystemObject $m = [System.Runtime.InteropServices.Marshal] $word = $m::GetActiveObject(&quot;Word.Application&quot;) Invoke methods/access properties $fso.GetDrive(“C:”) $fso.VolumeName = “System Drive” Understand/extend instrumentation Extend and discover properties/methods Update-TypeData Office.Word.Types.ps1xml $fso | Get-Member Manipulate and format results Define and import custom formating Update-FormatData Office.Word.Format.ps1xml $word.RecentFiles | Sort name | Format-Table Allows more simpler/more powerful COM scripts because of utilities and formatting
  • 53. PowerShell provides native WMI support Get-WmiObject Allows for inspection of WMI namespace Get-WmiObject –list [-Namespace xx] Get-WmiObject –Class xx –Namespace xx –Property xxx – Filter xxx –ComputerName xxx –Credential xxx Native language support [WMI] “\\JPSDESK10\root\cimv2:Win32_Process.Handle=&quot;0“ [WMICLASS] &quot;ROOT\cimv2:WIN32_PROCESS&quot; [WMISEARCHER]&quot;select * from Win32_process WHERE Name = 'calc.exe'&quot;
  • 54. PowerShell provides native access to any .NET class Create any object [reflection.assembly]::LoadWithPartialName(&quot;System.Windows.Forms&quot;) $d = New-Object System.DateTime 2006,12,25 Access Properties/Invoke Methods $d.DayOfWeek $d.AddDays(-30) Access Statics [DateTime]::Now [DateTime]::IsLeapYear(2006) Allows admins to easily access and leverage a huge API set because of scriptability, utilities and formatting
  • 55. PowerShell provides native XML support Native datatype $x=[xml]&quot;<a><b><c>TEST</c></b></a>“ $b =[xml](type c:\i386\mssecure.xml) Native syntax to access “data” view of properties $b.BulletinDataStore.Bulletins.Bulletin[0] Access to XML methods $b.BulletinDataStore.SelectNodes(“//Patch”) XML properties available through PSBase property $b.BulletinDataStore.PSBase.innerXml
  • 56. Invoke existing tools Existing command run directly after variables are expanded Harvest data from existing tools Parse output into variables using text utilities. Pipe data to SELECT and use –FIRST and –LAST Select-String <REGEX> <Path> Dir | Select-String <REGEX> [DateTime]”12/25/2006 7:00” ([DateTime]”12/25/2006 7:00”).AddDays(-30) Use functions/scripts to wrap the commands and convert output to objects or provide standard syntax Safely process text Use CLR types via Windows PowerShell to safely parse text [URI]” http://blogs.msdn.com/powershell/archive/2006/04/25/583234.aspx” Allows admins to get 2-10x more power out of existing commands because of scriptability

Notes de l'éditeur

  • #2: 06/03/09 06:51 © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. 5 minutes