0

Currently I am running into an issue. I have an app installed from the SharePoint store "Docusign" and it is at the top level site collection. I have to manually go to every subsite and click the gear and choose add an app, then choose docusign and then click Trust It. I want to enable this "app" on all the subsites of said site collection with a Powershell script/command.

Site Collection 1 Where app was initially added

Subsite1 Subsite2 ....etc I am very new to powershell and I have tried to copy and paste some scripts together to get this to work but keep hitting a wall. Any help on this would be greatly appreciated or should I approach this a different way?

$app = new-object -com shell.application $ie=$app.windows() $ie=$ie | ?{$_.locationurl -match "SiteCollectionURL"}

if($ie -ne $null) { Write-host Connected $url='https://test.sharepoint.com/sites/Site/subsite5/_layouts/15/storefront.aspx?source=%2Fsites%2FSite%2Fsubsite5&sname=subsite5#qry=%22Docusign%20for%20SharePoint%22,vw=AppDetailsView,app=WA104218069,clg=0' $ie.Navigate($url) Start-Sleep -s 10

$addItButton=$ie.Document.body.getElementsByTagName('button') |? {$_.value -match 'Add' }
if($addItButton.disabled -eq $false)
{
    $addItButton.click()
    Start-Sleep -Seconds 5
    
    $trustIt=$ie.Document.IHTMLDocument3_getElementById('ctl00_PlaceHolderMain_BtnAllow')
    
    $trustIt.click()
}

//The above code successfully clicks on Add button but when the pop up comes, the above code fails to click on Trust It button

3
  • What "wall" are you hitting? What is the approach you take, and what error you are encountering when executing it?
    – RuneBH
    Nov 10, 2020 at 13:54
  • Please find my updated query. I have included my code as well. Nov 11, 2020 at 4:01
  • Hi @SB_LoneWolf - It sure looks like javascript and not Powershell from your snippet above. With the same user that is executing the script have you tried to manually install and trust the app? It could be lack of of permissions. Also, depending on the scenario, you could consider trusting the app on tenant level and thus not having to trust it everytime you install it on a site collection.
    – RuneBH
    Nov 15, 2020 at 21:49

1 Answer 1

0

For managing apps tenant level, you will need to first create a SharePoint app catalog. Then you can manage the app deployment there. Here are tutorials about it, have a check on it. And just like you said, after the deployment, still you will need to add the app by hand(Trust it and add it). After deployment in app catalog, it makes the app available on those sites.

https://docs.microsoft.com/en-us/sharepoint/use-app-catalog

https://www.sharepointdiary.com/2019/10/add-app-to-sharepoint-online-site-using-powershell.html

1
  • I have already Deployed with the help of App Catalog. I just want to automate process of trusting app at Site and Subsites level. Nov 11, 2020 at 4:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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