yos montpellier - piloter office 365 grâce à powershell - les indispensables

47
yOS-Tour - yOS-Day ©2015. All rights reserved. #2 – yOS-Day à Montpellier le 12 juin 2015 www.yos-tour.com [email protected] @YosTour

Upload: benoit-jester

Post on 04-Aug-2015

338 views

Category:

Internet


1 download

TRANSCRIPT

yOS-Tour - yOS-Day ©2015. All rights reserved.

#2 – yOS-Day à Montpellier le 12 juin 2015

www.yos-tour.com

[email protected]

@YosTour

yOS-Tour - yOS-Day ©2015. All rights reserved.

PowerShell pour Office 365Piloter Office 365 grâce à PowerShell - Les

indispensables

+ =

yOS-Tour - yOS-Day ©2015. All rights reserved.

Benoît JesterMVP SharePoint, travaillant sur cette technologie depuis 10 ans. Administration, expertise SharePoint, Cloud, …

t: @spasipeb: spasipe.wordpress.comF: Benoit Jester

yOS-Tour - yOS-Day ©2015. All rights reserved.

Etienne BaillyMCT | Office 365 & SharePoint enthusiastFondateur de la société ISTEP

t: @etienne_bailly b: http://www.istep.fr/blogF : Etienne Bailly (Microsoft Certified Trainer)

yOS-Tour - yOS-Day ©2015. All rights reserved.

Agenda

yOS-Tour - yOS-Day ©2015. All rights reserved.

PowerShell ?

Pourquoi PowerShell pour Office 365 ?

Let’s connect to Office 365

PowerShell SharePoint

Démos !

Un peu de lecture …

Au menu de cette présentation

yOS-Tour - yOS-Day ©2015. All rights reserved.

PowerShell ?

yOS-Tour - yOS-Day ©2015. All rights reserved.

Langage de script orienté objet - repose sur le Framework .NetSnapins / 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 ?

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 gcmshcm

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)

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ésGet-Service | Where { $_.Status –eq 'Running' }

# Les process IIS gourmands....Get-Process | Where { $_.Name -like "*w3wp*" -and $_.PM –gt 300MB } | Sort PM -Descending

yOS-Tour - yOS-Day ©2015. All rights reserved.

Pourquoi PowerShell pour Office 365 ?

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 PowerShell peut révéler des informations « masquées », non disponibles dans le Centre d’administration

Office 365 comporte des fonctionnalités que vous ne pouvez configurer qu’à l’aide de Windows PowerShell

Windows PowerShell excelle à effectuer des opérations en bloc

Windows PowerShell filtre efficacement les données

Windows PowerShell facilite l’impression ou l’enregistrement des données

Windows PowerShell permet une gestion reposant sur plusieurs produits

C’est tout ? Non, pas tout à fait : l’utilisation de Windows PowerShell dans le cadre de la gestion d’Office 365 est pratiquement illimitée

yOS-Tour - yOS-Day ©2015. All rights reserved.

Les différents outils pour administrer Office 365

Office 365 Management APIs• Programmatic access• Innovate on top

Office 365 Management APIs

PowerShell for Office 365• Automate and customize• Advanced functions

PowerShell

Office 365 Admin Center• Out-of-the-box solution • Simple but extensible

Office 365 Admin Center

Office 365 Admin App• On-the-go solution• Contextual

Office 365 Admin App

yOS-Tour - yOS-Day ©2015. All rights reserved.

Let’s connect to Office 365 !

yOS-Tour - yOS-Day ©2015. All rights reserved.

Windows 7, 8, 8.1, …Windows Server 2008 R2, Windows Server 2012, 2012 R2 Microsoft .NET Framework 3.51 (min)

Microsoft Online Services Sign-in AssistantModule Azure Active Directory pour Windows PowerShell

Prérequis – PowerShell pour Office 365

yOS-Tour - yOS-Day ©2015. All rights reserved.

Microsoft Online Services Sign-In Assistanthttps://www.microsoft.com/en-us/download/details.aspx?id=41950

yOS-Tour - yOS-Day ©2015. All rights reserved.

Microsoft Online Services Sign-In Assistant

yOS-Tour - yOS-Day ©2015. All rights reserved.

Module Azure Active Directory pour Windows PowerShellhttp://go.microsoft.com/fwlink/p/?linkid=236297

yOS-Tour - yOS-Day ©2015. All rights reserved.

Se connecter à Office 365 avec PowerShell

################################### Connexion à Office 365Import-Module MSOnline

$c = Get-Credential

Connect-MsolService –Credential $c

yOS-Tour - yOS-Day ©2015. All rights reserved.

Connexion à Exchange Onlineavec PowerShell

################################### Connexion à Exchange Online Import-Module MSOnline # Azure AD Module$c = Get-Credential$exchSession = New-PSSession `–ConfigurationName Microsoft.Exchange `-ConnectionUri https://ps.outlook.com/powershell `-Credential $c `-Authentication Basic `–AllowRedirectionImport-PSSession $exchSession –AllowClobberSet-ExecutionPolicy RemoteSignedConnect-MsolService –Credential $c

yOS-Tour - yOS-Day ©2015. All rights reserved.

Connexion à Exchange Onlineavec PowerShell

yOS-Tour - yOS-Day ©2015. All rights reserved.

Connexion à Exchange Onlineavec PowerShell

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 `–AllowRedirectionImport-PSSession $exchSession –AllowClobber

# SharePoint Import-Module Microsoft.Online.Sharepoint.PowerShellConnect-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 $cImport-PSSession $skypeSession –AllowClobber

yOS-Tour - yOS-Day ©2015. All rights reserved.

PowerShell SharePoint

yOS-Tour - yOS-Day ©2015. All rights reserved.

Installation• PowerShell 3.0• SharePoint Online Management Shell

Utilisation• Lancement du Shell• Connexion au Centre d’administration SharePoint Online• Enjoy !

Installation et Connexion

yOS-Tour - yOS-Day ©2015. All rights reserved.

David contre Goliath• SharePoint On-Premises : 772 cmdlets• SharePoint Online : 33 cmdlets

Nommage OnPrem vs Online• Get-SPSite / Get-SPOSite• Add-SPUser / Add-SPOUser• Upgrade-SPSite / Upgrade-SPOSite

Les cmdlets SPO, quelles limitations ?• Leur nombre• Leur périmètre d’utilisation

Cmdlets SharePoint vs SharePoint Online

yOS-Tour - yOS-Day ©2015. All rights reserved.

Collections de site• Get-SPOSite / New-SPOSite / Remove-SPOSite / Set-SPOSite• Repair-SPOSite / Test-SPOSite / Upgrade-SPOSite / Request-SPOUpgradeEvaluationSite• Get-SPODeletedSite / Remove-SPODeletedSite / Restore-SPODeletedSite

Tenants• Get-SPOTenant• Get-SPOTenantLogEntry• Get-SPOTenantLogLastAvailableTimeInUtc• Set-SPOTenant

Utilisateurs• Add-SPOUser / Get-SPOUser / Remove-SPOUser / Set-SPOUser• Get-SPOExternalUser / Remove-SPOExternalUser

Cmdlets SharePoint Online - Périmètre

yOS-Tour - yOS-Day ©2015. All rights reserved.

Opérations « basiques »• Recensement et export csv des collections de site d’un tenant• Départ d’un employé : remplacement de l’utilisateur par un autre

Pour aller plus loin …• Créer une liste ?• Supprimer un sous-site ? Les cmdlets ne le permettent pas

La solution ? • Associer ces cmdlets à du CSOM

Quelques exemples d’utilisation des cmdlets

yOS-Tour - yOS-Day ©2015. All rights reserved.

Client Side Object Model• Sous-ensemble du modèle objet• Utilisation différente

Pourquoi utiliser CSOM en plus des cmdlets SPO?• Les cmdlets SPO sont utilisables au niveau du tenant• CSOM est utilisable à tous les niveaux

Utilisation• Possibilités infinies en combinant les 2• Ex : Récupération des MySites (non renvoyés par le cmdlet Get-SPOSite)

Cmdlets SPO+ CSOM =

yOS-Tour - yOS-Day ©2015. All rights reserved.

Office 365 PnP – Quels usages ?

yOS-Tour - yOS-Day ©2015. All rights reserved.

Office 365 PnP - Vos identifiants ? Stockez-les !

# SharePoint Online with PNP PowerShell Commands ###Import-Module Microsoft.Online.Sharepoint.PowerShellConnect-SPOnline -Url https://istep365.sharepoint.com -Credentials etienneO365Get-SPOWeb

yOS-Tour - yOS-Day ©2015. All rights reserved.

Démos

yOS-Tour - yOS-Day ©2015. All rights reserved.

Démo – Mettre en place une signature dynamiqueImport-Module MSOnline$c = Get-Credential$session = New-PSSession –ConfigurationName Microsoft.Exchange `-ConnectionUri https://ps.outlook.com/powershell -Credential $c -Authentication Basic –AllowRedirectionImport-PSSession $session –AllowClobberSet-ExecutionPolicy RemoteSignedConnect-MsolService –Credential $c

$fichHTML = "C:\DevPowerShell\temp\HTML\signature_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

}

yOS-Tour - yOS-Day ©2015. All rights reserved.

Un peu de lecture…

yOS-Tour - yOS-Day ©2015. All rights reserved. 37

http://technet.microsoft.com/en-us/office/dn788774

Technet – Bible technique

yOS-Tour - yOS-Day ©2015. All rights reserved. 38

Technet Microsofthttps://technet.microsoft.com/fr-fr/

Active Directory Administration with Windows PowerShellhttps://technet.microsoft.com/fr-fr/library/dd378937(v=ws.10).aspx

Active Directory Cmdlets in Windows PowerShellhttps://technet.microsoft.com/fr-fr/library/ee617195.aspx

PowerShell Tools for Visual Studiohttps://visualstudiogallery.msdn.microsoft.com/c9eb3ba8-0c59-4944-9a62-6eee37294597

Connect to Office 365 by using a single Windows PowerShell windowhttps://technet.microsoft.com/en-us/library/dn568015.aspx

Scripts Office 365 – Exemple Gestion Mailshttp://www.sysco.ch/website/?it=101785

Use PowerShell to Manage Office 365 Usershttp://blogs.technet.com/b/heyscriptingguy/archive/2014/03/26/se-powershell-to-manage-office-365-users.aspx

Liens utiles

yOS-Tour - yOS-Day ©2015. All rights reserved. 39

Skype for Business (aka Lync Online) PowerShellhttp://blogs.technet.com/b/csps/

Configuring your computer for Lync Online managementhttps://technet.microsoft.com/en-us/library/dn362839.aspx

Windows PowerShell Module for Lync Onlinehttps://www.microsoft.com/en-us/download/details.aspx?id=39366

Liens utiles

yOS-Tour - yOS-Day ©2015. All rights reserved. 40

Twitter officiels Office 365https://twitter.com/Office365_Techhttps://twitter.com/Office365

Twitter Benoit Jester @SPAsipehttps://twitter.com/spasipe

Twitter Etienne Bailly @etienne_baillyhttps://twitter.com/etienne_bailly

Yammer IT Pro Networkhttps://yammer.com/itpronetwork

Twitter & Yammer utiles

yOS-Tour - yOS-Day ©2015. All rights reserved.

PowerShell Tools for Visual Studio

yOS-Tour - yOS-Day ©2015. All rights reserved.

http://powershell.office.com

• Scripts d’exemple• Scénarios utiles• Aide

Coming Soon PowerShell for Office

yOS-Tour - yOS-Day ©2015. All rights reserved.

Office 365 Resources

Office 365 Roadmap - roadmap.office.com

Office Blogs - blogs.office.com

Office 365 Network - www.yammer.com/itpronetwork

PowerShell for Office 365 - powershell.office.com

Office 365 Developer - dev.office.com

Office 365 Trust Center - trust.office365.com

yOS-Tour - yOS-Day ©2015. All rights reserved.

Questions ?

yOS-Tour - yOS-Day ©2015. All rights reserved.

#2 – yOS-Day à Montpellier le 12 juin 2015

Merci à nos sponsors

yOS-Tour - yOS-Day ©2015. All rights reserved.

#2 – yOS-Day à Montpellier le 12 juin 2015

yOS-Tour - yOS-Day ©2015. All rights reserved.Le yOS-Tour débarque à Lyon !!!

11 décembre 2015