PowerShell

Windows PowerShell et Windows PowerShell ISE sont disponibles avec Windows.

SharePoint Online Management Shell

Pour pouvoir utiliser les cmdlet de SharePoint, il faut installer SharePoint Online Management Shell.

Télécharger:

https://www.microsoft.com/en-us/download/details.aspx?id=35588

Commandes SPO

Pour mettre à jour le module SPO:
Update-Module -Name Microsoft.Online.SharePoint.PowerShell

Le module est installé: C:\Program Files\WindowsPowerShell\Modules\Microsoft.Online.SharePoint.PowerShell

Vous pouvez alors tester à l’aide de Get-SPOSite si les cmdlet de SharePoint sont disponibles.

Voici la liste des cmdlet:

https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/?view=sharepoint-ps

Il est aussi possible d’énumérer la liste des cmdlet par:

Get-Command -Module « Microsoft.Online.SharePoint.PowerShell »

Une fois que SharePoint Online Management Shell est installé sur l’ordinateur, il est possible d’utiliser ces cmdlet à l’aide de Windows Powershell ou Windows Powershell ISE.

Get started with the SharePoint Online Management Shell | Microsoft Docs

Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Uninstall-Module -Name Microsoft.Online.SharePoint.PowerShell -AllVersions
Import-Module -Name Microsoft.Online.SharePoint.PowerShell

SharePoint Online PnP

Pour pouvoir avoir plus de choix de commande, vous pouvez installer SharePoint PnP.

PnP Patterns and Practices est une librairie de commandes pour SharePoint

https://github.com/SharePoint/PnP-PowerShell

Pour installer PnP, nouvelle version
Install-Module -Name PnP.PowerShell

Pour installer PnP, ancienne version:
Install-Module -Name SharePointPnPPowerShellOnline (avec -Force)

Le module est installé dans C:\Program Files\WindowsPowerShell\Modules\SharePointPnPPowerShellOnline
C:\Program Files\WindowsPowerShell\Modules\PnP.PowerShell

https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-design-pnppowershell

Voici la liste des cmdlet:

https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/?view=sharepoint-ps

Il est aussi possible d’énumérer la liste des cmdlet avec Windows Powershell (ISE) avec:

Get-Command -Module SharePointPnPPowerShellOnline (ancienne version)

Get-Command -Module PnP.PowerShell

Pour valider quelle version est installée:

Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending

CSOM Client-side object model

ClientContext

https://www.c-sharpcorner.com/article/list-item-operations-using-csom-with-powershell-for-sharepoi/


SharePoint Online Management Shell

Télécharger:

https://www.microsoft.com/en-us/download/details.aspx?id=35588

Connecter: Connect-SPOService -Url https://OrgName-admin.sharepoint.com

https://docs.microsoft.com/en-ca/powershell/sharepoint/sharepoint-online/connect-sharepoint-online?view=sharepoint-ps

Windows PowerShell ISE

https://docs.microsoft.com/en-us/powershell/scripting/core-powershell/ise/introducing-the-windows-powershell-ise?view=powershell-6

Pour utiliser les cmdlets de SharePoint:

Get-Command -Module « Microsoft.SharePoint.PowerShell »

Pour tester: Get-SPOSite

Pour utiliser les cmdlet de SharePoint Online avec Windows PowerShell ISE, il faut installer SharePoint Online Management Shell sur le poste.

Exécuter un script PS1

Ajouter .\ devant le nom du fichier ps1

Note:

https://www.powershellgallery.com/packages/SharePointPnPPowerShellOnline/3.4.1812.2

Exemple Hub Site:

Exemples:

get-spoexternaluser

get-spouser

get -azureADuser

unifiedlog

Publicité

Laisser un commentaire

Entrer les renseignements ci-dessous ou cliquer sur une icône pour ouvrir une session :

Logo WordPress.com

Vous commentez à l’aide de votre compte WordPress.com. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l’aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s