Contenu connexe
Similaire à PowerShell pour Office 365 & SharePoint / yosTour Lyon / Gilles Pommier | Etienne Bailly (20)
PowerShell pour Office 365 & SharePoint / yosTour Lyon / Gilles Pommier | Etienne Bailly
- 1. yOS-Tour - yOS-Day ©2015. All rights reserved.
#4 – yOS-Day à Lyon le 11 décembre 2015
www.yos-tour.com
contact@yos-tour.com
@YosTour
- 2. yOS-Tour - yOS-Day ©2015. All rights reserved.
#4 – yOS-Day à Lyon le 11 décembre 2015
PowerShell pour Office 365 &
SharePoint
Geekons un peu
- 3. yOS-Tour - yOS-Day ©2015. All rights reserved.
Merci à nos sponsors
#4 – yOS-Day à Lyon le 11 décembre 2015
Et à nos soutiens
- 4. yOS-Tour - yOS-Day ©2015. All rights reserved.
Gilles POMMIER
MVP Office 365
SharePoint, Office 365
@: gilles.pommier@smartview.fr
b : www.smartview.fr
- 5. yOS-Tour - yOS-Day ©2015. All rights reserved.
Etienne BAILLY
MCT | Office 365 & SharePoint enthusiast
Fondateur de la société ISTEP
t: @etienne_bailly
b: istep.fr/blog
F: Etienne Bailly
- 7. yOS-Tour - yOS-Day ©2015. All rights reserved.
PowerShell ?
Pourquoi PowerShell pour Office 365 ?
Let’s connect to Office 365
Démos !
Office 365 API : Quel Objectif ?
Démos
PowerShell & SharePoint : Pourquoi l’utiliser ?
Démos
Agenda
- 9. yOS-Tour - yOS-Day ©2015. All rights reserved.
Langage de script orienté objet - repose sur le Framework .Net
Snapins / Modules
Cmdlets / Functions
Ex : Get-Service, Set-SPContentDatabase, …
Paramètres
-Debug, -ErrorAction, -ErrorVariable, -Whatif, -Confirm
Alias
dir Get-ChildItem
cd Set-Location
gcm Get-Command
PowerShell ?
- 10. yOS-Tour - yOS-Day ©2015. All rights reserved.
Cmdlet Description Alias
Get-Help
Aide sur une commande
-example
help, man
Get-Member Retourne les propriétés, méthodes d’un objet gm
Get-Module Liste les modules chargés gmo
Get-PSSnapin Liste les « snapins » chargés gsnp
Get-Command Ou « Show-Command » montre les Cdlets du Module
gcm
shcm
Description Alias
|
Un « Pipeline » peut contenir une ou plusieurs
commandes séparées par le caractère « pipe » ( | )
$PSItem Représente l’objet courant $_
Where Ou « Where-Object » ou « ? » ?
ForEach Ou « ForEach-Object » ou « % » %
Select Définit les propriétés à récupérer
Un peu de syntaxe …
Description
Import-Csv Import CSV
Out-File Export fichier (.txt)
Out-Csv Export CSV (.csv)
- 11. yOS-Tour - yOS-Day ©2015. All rights reserved.
PowerShell – quelques exemples
# Accès au journal des événements (Event Viewer). 50 dernières connexions
# "C'est ki ki s'est connecté pour tout fracasser sur le serveur de Prod ??"
Get-EventLog -LogName Security |
Where EventID -eq 4624 |
Select -First 50
# Les fichiers supérieurs à 50 Mb (en cascade - récursif)
Get-ChildItem -Path c:temp -Recurse | Where-Object { $_.Length -gt 20MB }
# Les services Windows démarrés
Get-Service | Where { $_.Status –eq 'Running' }
# Les process IIS gourmands....
Get-Process | Where { $_.Name -like "*w3wp*" -and $_.PM –gt 300MB } | Sort PM -Descending
- 13. yOS-Tour - yOS-Day ©2015. All rights reserved.
Six raisons pour lesquelles nous vous recommandons d’utiliser Windows PowerShell pour gérer Office 365
PowerShell, Pourquoi ?
Windows PowerShellpeut
révélerdes informations«
masquées», non disponibles
dans le Centred’administration
Office 365 comporte des
fonctionnalitésque vous ne
pouvez configurer qu’àl’aide de
Windows PowerShell
Windows PowerShellexcelle à
effectuerdesopérationsen
bloc
Windows PowerShellfiltre
efficacementles données
Windows PowerShellfacilite
l’import/ exportdesdonnées
Windows PowerShellpermet
une gestion reposantsur
plusieursproduits
- 14. yOS-Tour - yOS-Day ©2015. All rights reserved.
Les différents outils pour administrer Office 365
- 16. yOS-Tour - yOS-Day ©2015. All rights reserved.
Windows 7 ou + (Win 8, 8.1, 10, …)
Windows Server 2008 R2 ou + (Windows Server 2012, 2012 R2, 2016, …)
Microsoft .NET Framework 3.51 ou +
Microsoft Online Services Sign-in Assistant
Module Azure Active Directory pour Windows PowerShell
Prérequis – PowerShell pour Office 365
Toutes les infos pour bien démarrer avec PowerShell sur powershell.office.com
http://powershell.office.com/get-started
- 17. yOS-Tour - yOS-Day ©2015. All rights reserved.
Les univers « PowerShell » Office
365
Petite gymnastique : Un langage unique mais des modules séparés
# Exchange Online
$exchSession = New-PSSession `
–ConfigurationName Microsoft.Exchange `
-ConnectionUri https://ps.outlook.com/powershell `
-Credential $c `
-Authentication Basic `
–AllowRedirection
Import-PSSession $exchSession –AllowClobber
# SharePoint
Import-Module Microsoft.Online.Sharepoint.PowerShell
Connect-SPOService -Url https://tenant-admin.sharepoint.com/ -Credential $c
Module Azure Active Directory
(MSOnline)
# Skype for Business (aka Lync Online)
Import-Module LyncOnlineConnector
$skypeSession = New-CsOnlineSession -Credential $c
Import-PSSession $skypeSession –AllowClobber
- 18. yOS-Tour - yOS-Day ©2015. All rights reserved.
Se connecter à Office 365 avec PowerShell
##################################
# Connexion à Office 365
Import-Module MSOnline
$c = Get-Credential
Connect-MsolService –Credential $c
- 19. yOS-Tour - yOS-Day ©2015. All rights reserved.
Connexion à Exchange Online
avec PowerShell
- 21. yOS-Tour - yOS-Day ©2015. All rights reserved.
Démo – Mettre en place une signature dynamique
Import-Module MSOnline
$c = Get-Credential
$session = New-PSSession –ConfigurationName Microsoft.Exchange `
-ConnectionUri https://ps.outlook.com/powershell
-Credential $c -Authentication Basic –AllowRedirection
Import-PSSession $session –AllowClobber
Set-ExecutionPolicy RemoteSigned
Connect-MsolService –Credential $c
$fichHTML = "C:DevPowerShelltempHTMLsignature_YosDaysMontPellierDYNAMIQUE.html"
# On applique la signature spécifique à tous les utilisateurs
Get-MsolUser |
ForEach {
$signHTML = (Get-Content $fichHTML) -f $_.DisplayName, $_.Title, `
$_.MobilePhone, $_.UserPrincipalName
Set-MailboxMessageConfiguration `
–Identity $_.UserPrincipalName `
-AutoAddSignature $True `
-SignatureHtml $signHTML
}
- 25. yOS-Tour - yOS-Day ©2015. All rights reserved.
Cohérence de l’API : Microsoft Graph
Avant
Après
https://graph.microsoft.io/
- 27. yOS-Tour - yOS-Day ©2015. All rights reserved.
PowerShell & SharePoint: Pourquoi faire ?
- 28. yOS-Tour - yOS-Day ©2015. All rights reserved.
PowerShell et SharePoint : démarche pas à
pas
SPSite
SPWeb
SPList
SPListItem
- 29. yOS-Tour - yOS-Day ©2015. All rights reserved.
Référence PowerShell et O365
http://powershell.office.com
- 31. yOS-Tour - yOS-Day ©2015. All rights reserved.
Office 365 PowerShell site creation
Que faire maintenant ?
Utiliser CSOM avec les Cmdlets SPO ?
Utiliser les Cmdlets au niveau Site Collection ?
Utiliser CSOM pour travailler au niveau Webs ?
- 32. yOS-Tour - yOS-Day ©2015. All rights reserved.
Commandes PnP-PowerShell : où les
trouver ?
https://github.com/OfficeDev/PnP-PowerShell
- 33. yOS-Tour - yOS-Day ©2015. All rights reserved.
Commandes PnP-PowerShell : Pour quoi faire?
- 36. yOS-Tour - yOS-Day ©2015. All rights reserved.
http://powershell.office.com
• Scripts d’exemple
• Scénarios utiles
• Aide
PowerShell for Office 365
- 37. yOS-Tour - yOS-Day ©2015. All rights reserved.
PowerShell Tools for Visual Studio
https://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597
- 39. yOS-Tour - yOS-Day ©2015. All rights reserved.
http://technet.microsoft.com/en-us/office/dn788774
Technet – Bible technique
- 40. yOS-Tour - yOS-Day ©2015. All rights reserved.
#4 – yOS-Day à Lyon le 11 décembre 2015
www.yos-tour.com
contact@yos-tour.com
@YosTour
merci !