1

I am a young SharePoint OnLine user. I want Excel documents from all my sites to open directly with Excel and not Excel-OnLine. As I have a lot of sites and it would be long to make the sites one by one, I try to use PowerShell without success :

Import-Module -Name OfficeWebApps 

$tenantName = "mytenant"
$username = "myAdminEmail@myEntreprise.eu"
$password = "myPassword"

$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) 

# Credential SharePoint Online for admin tenant
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword) 
$adminCtx.Credentials = $credentials

New-SPWOPIBinding -ServerName "$tenantName.sharepoint.com" -Application "Excel"

I'm sure the path to PnP is good. Yet I get an error:

 "New-SPWOPIBinding : The term 'New-SPWOPIBinding' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the 
name, or if a path was included, verify that the path is correct and try again.
At line:37 char:1
+ New-SPWOPIBinding -ServerName "$tenantName.sharepoint.com" -Applicati ...
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (New-SPWOPIBinding:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException"
2

If you look at the documentation of the New-SPWOPIBinding, you see it is not meant for SharePoint online: https://docs.microsoft.com/en-us/powershell/module/sharepoint-server/new-spwopibinding?view=sharepoint-ps

I'm pretty sure you can't change this behavior with SharePoint online.

Update:


I stand corrected, I thought this was not possible with the new UI. The NEW-SPWOPIBinding definitely doesn't work. This is part of SharePoint onpremises. However, you are correct in the post below, that you can enable a feature that changes the default behavior.

I tested this script and can confirm that it works, although the users will likely get a mixed experience:

Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/sitename
Enable-PnPFeature -Identity 8a4b8de2-6fd8-41e9-923c-c7c3c00f8295 -Force -Scope Site

In the second command it's important to specify the -Scope Site as this is a site collection feature en the cmdlet defaults to the web scope.

  • Yet in this article, he says it's usable for SharePoint Online No? c-sharpcorner.com/article/… – DataCube Jul 25 '18 at 13:51
  • I did reference the official Microsoft documentation. For SharePoint online you can only use the SharePoint online management shell. And here's a list of the cmdlets: docs.microsoft.com/en-us/powershell/module/sharepoint-online/… – Oak3 Jul 25 '18 at 14:31
  • And your exact error states that the cmdlet is not available, as would seem logical based on the official docs. – Oak3 Jul 25 '18 at 14:31
  • Okay, thanks for your answer! So I'm condemned to settle each site one by one? – DataCube Jul 26 '18 at 6:49
  • I think so. I haven't tried myself but my expectation would be that this can't be changed. Especially in the modern ui. – Oak3 Jul 26 '18 at 7:11
1

I found the solution :

######################################################################################
## Script permettant d'activer une fonctionnalité sur une liste de sites
## La fonctionalitée est définie par un ID
## Il est nécéssaire d'avoir installé PowerShell PnP et lancé PowerShell en mode admin
## ==> Install-Module SharePointPnPPowerShellOnline -AllowClobber
######################################################################################

$username = Read-Host "Login (Adresse e-mail Admin) : "
$password = Read-Host -Prompt "Mot de passe de l'utilisateur $username" –AsSecureString
$Credential = New-Object PSCredential($userName,$passWord)
$outputfile = "C:\PSTools\sites_all.csv"

######################################################################################
## Main
######################################################################################
$csv = import-csv $outputfile -delimiter ";"
$indexMax = $csv.Count
$index = 0
$csv | ForEach-Object {
    try {

        $index ++
        $URL = $_.Url
        #Permet de sauter les URL incorrectes
        if ($URL.StartsWith("*")) { return } 

        write-host "************************************************" -foregroundcolor Gray
        write-host "$index / $indexMax  Activation de la fonctionnalité sur le site $($_.Title)" -foregroundcolor Gray
        write-host "************************************************" -foregroundcolor Gray

        #Connexion au site
        Connect-PnPOnline -Url $URL -Credentials $Credential

        #Activation de la fonctionnalitée
        Enable-PnPFeature -Identity 8a4b8de2-6fd8-41e9-923c-c7c3c00f8295 -Force -Scope Site
        Disconnect-PnPOnline 
        write-host "Fonctionnalité Activée !" -foregroundcolor Green
        }
    catch{
        write-host "/!\ Fonctionnalité NON Activée ! - ERREUR INCONNUE /!\" -foregroundcolor Red
    }
}
write-host "Fin du script" -foregroundcolor Blue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.