使用PowerShell PNP的SharePoint OnLine

时间:2018-07-26 13:53:09

标签: powershell sharepoint sharepoint-online

我是一个年轻的SharePoint OnLine用户。我希望我所有站点的Excel文档都可以直接使用Excel而不是Excel-OnLine打开。由于我有很多站点,并且一个接一个地建立站点很长,因此我尝试制作一个PowerShell却没有成功:

$tenantName = "myTenant"
$username = "my@email.com"
$password = "myPassword"
$url = "MySharePointSiteToTest"

#  Reference au module Pnp Client 
#  En cas de problème, vérifier les chemains d'accès !
$pnpModule = Get-Module SharePointPnPPowerShell* -ListAvailable
$pnpPath = $pnpModule.ModuleBase
Add-Type -Path "C:\PSTools\Modules\SharePointPnPPowerShellOnline\2.15.1705.0\Microsoft.SharePoint.Client.dll" 
Add-Type -Path "C:\PSTools\Modules\SharePointPnPPowerShellOnline\2.15.1705.0\Microsoft.SharePoint.Client.Runtime.dll" 
Add-Type -Path "C:\PSTools\Modules\SharePointPnPPowerShellOnline\2.15.1705.0\Microsoft.SharePoint.Client.UserProfiles.dll"
Add-Type -Path "C:\PSTools\Modules\SharePointPnPPowerShellOnline\2.15.1705.0\Microsoft.Online.SharePoint.Client.Tenant.dll"

# internal params
$adminUrl = "https://$tenantName-admin.sharepoint.com"
$rootUrl = "https://$tenantName.sharepoint.com"
Write-Host *********************************
Write-Host "Admin Url : $adminUrl"
Write-Host "Root Url : $rootUrl"
Write-Host *********************************
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force 

# Admin connection
$adminCtx = New-Object Microsoft.SharePoint.Client.ClientContext($adminUrl) 

# SharePoint Online with PNP
$psCredential = New-Object System.Management.Automation.PSCredential($username, $securePassword)
$spCredential = Get-Credential -Credential $psCredential


# PnP Connect
Connect-PnPOnline -Url $url -Credentials $spCredential

#Permet d'activer la fonctionalitée de l'ID correspondant 
Enable-PnPFeature -Identity 8a4b8de2-6fd8-41e9-923c-c7c3c00f8295 -Force

我没有收到错误消息。显然我必须忘记代码中的某些内容

0 个答案:

没有答案