powershell
23 TopicsPnP-PowerShell Connect-PnPOnline using AppId gives Access denied
I'm creating a PowerShell script to connect to SharePoint Online and authenticate as a registered Azure AD application (not a user). In Azure AD I have registered the application and I have the AppId and AppSecret. Through Azure AD I have granted the application API access to the SharePoint Online API with the application permissions 'Have full control of all site collections' and 'Read and write managed metadata'. I have also performed admin consent for the app by going to the URL: https://login.microsoftonline.com/<tenant>.onmicrosoft.com/oauth2/authorize?client_id=<client id>&response_type=code&prompt=admin_consent. When I use the cmdlet: Connect-PnPOnline -Url $siteUrl -AppId $appId -AppSecret $appSecret no message is displayed as if the connection occurs properly. However, when I use ANY cmdlet (i.e. Get-PnPWeb) I receive 'Access denied. You do not have permission to perform this action or access this resource.' Any help is appreciated.Solved32KViews0likes6CommentsHow do I set DenyAddAndCustomizePages for SharePoint 2019 communication site
Hello, I've set up a fresh new instance of SharePoint 2019, I've set up a communication site in Dev environment and wanted to save this site as a template, unfortunatly the option is not available and I get an "access denied" when accessing to the page thanks to the url. Anyonye know if the same option can be applied as we can you in SharePoint Online: set-sposite https://tenant.sharepoint.com/sites/communication -denyaddandcustomizepages $false Thanks by advance26KViews0likes7CommentsSet-PnPListItem - Multiple User Field
Hey Folks, Trying to update a List item via PowerShell, the column is a multiple user field. The updated users are currently in an array of Email Addresses which is causing an error. Wondering if anyone knows how I could easily convert this to a string or if there's a workaround? Thanks!15KViews0likes10CommentsUsing PowerShell to change page banner image
Hi Folks, Currently have a automatic site creation tool up and running. I know using the PnP engine no content will be included in the template, but is there any way on the newly created site on the main home page (Modern Page) I can change the banner image using PowerShell to reference an image stored somewhere else? Thanks!Solved8.3KViews0likes4Comments401 Error using PnP PowerShell in Azure Runbooks
Trying to get PnP PowerShell cmdlets to work within an Azure Runbook with modern authentication (no username/password). I tried registering an Azure AD app and a Service Principal (Run as account) from the automation account that hosts the Runbook. Both use a certificate thumbprint and authorization itself doesn't throw an error. Here's the code I'm using: $connection = Get-AutomationConnection –Name "AzureRunAsConnection" $tenant = '[tenant].onmicrosoft.com' $url = 'https://[tenant].sharepoint.com/sites/test' Connect-PnPOnline -Url $url –Thumbprint $connection.CertificateThumbprint –ClientId $connection.ApplicationID -Tenant $tenant For every PnP cmdlet this throws the following error. Get-PnPTenantSite : The remote server returned an error: (401) Unauthorized. At line:7 char:1 + Get-PnPTenantSite + ~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-PnPTenantSite], WebException + FullyQualifiedErrorId : System.Net.WebException,PnP.PowerShell.Commands.GetTenantSite I have also updated the cmdlets from SharePointPnPPowerShellOnline to the newest PnP.PowerShell. Furthermore, the Azure app and service principal are members of the SharePoint administrators group. When I attempt to reproduce the issue on a local machine I get the same 401 error. Any ideas? Thanks!Solved7.5KViews0likes3CommentsCan't turn off "Visible on New Button" for Content Type using PnP PowerShell
Hi, I'm having trouble turning off the "Visible on New Button" option for a Content Type on a Document Library. I'm trying to use the "UniqueContentTypeOrder" to do that. So far, it's not taking -- any thoughts? Snippet of script below. Many thanks. $doclib = Get-PnPList -Identity "Quotes" -Includes RootFolder.UniqueContentTypeOrder $lct = $doclib.ContentTypes $ctx.Load($lct) $ctx.ExecuteQuery() $rootFolder = $doclib.RootFolder $lucto = $doclib.ContentTypes | ?{$_.Name -ne "<Content Type I'm Trying to Hide>"} $list = New-Object 'System.Collections.Generic.List[Microsoft.SharePoint.Client.ContentTypeId]' foreach ($i in $lucto) { $id = $i.Id $list.Add($id) } $rootFolder.UniqueContentTypeOrder = $list $rootFolder.Update() $doclib.Update()4.2KViews0likes4CommentsAdvanced Doc Library Settings with PowerShell - i.e. turn off "New Folder"
I'd like to be able to programmatically modify some of the advanced settings on some document libraries using PnP Powershell. Specifically, I'd like to be able to set "Make "New Folder" command available?" to "No" and I'd like to change the value for "Default open behavior for browser-enabled documents:" to "Open in the Client Application". I've had a look around at various properties, but just can't seem to find it. Any pointers greatly received. Many thanks, D.Solved3.8KViews0likes1CommentConnect-PnPOnline : Not working if I execute it through a .ps1 file
All, I have a .ps1 file that has this cmdlet Connect-PnPOnline –Url $siteURL –Credentials (Get-Credential) I'm getting the below error after executing it A positional parameter cannot be found that accepts argument 'System.Management.Automation.PSCredential'. ..... + CategoryInfo : InvalidArgument: (:) [Connect-PnPOnline], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,SharePointPnP.PowerShell.Commands.Base.Connec tOnline But if I am executing the cmdlet directly(i.e., typing the command) in the shell then there are no errors. It connects to the site. I tried with below code too in .ps1 file, failed $encpassword = convertto-securestring -String $password -AsPlainText -Force $cred = New-Object -typename System.Management.Automation.PSCredential($username, $encpassword) Connect-PnPOnline –Url $siteURL –Credentials $cred What is going on? Version check Name Version ---- ------- SharePointPnPPowerShellOnline 2.27.1806.13KViews0likes0CommentsPNP SharePoint Modern Lists DefaultEditFormUrl
Hi, Is there a way with PNP PowerShell to change a modern lists (SharePoint Online) default DefaultEditFormUrl. I know we can get the current values, but looking for a way to set it to my own custom page. Connect-PnPOnline -Url "https://tenanr.sharepoint.com/sites/x" $list = Get-PnPList -Identity "listane" -Includes DefaultDisplayFormUrl, DefaultEditFormUrl, DefaultNewFormUrl $list.DefaultDisplayFormUrl $list.DefaultEditFormUrl $list.DefaultNewFormUrl Thanks 🙂2.6KViews0likes1CommentGetting All Publishing Pages into Output Xml format
When I issue the following command against a Publishing Site: Get-PnPProvisioningTemplate -Handlers Pages,PageContents,Publishing,WebPart -PersistPublishingFiles -IncludeNativePublishingFiles -Verbose -Force -Debug -Out $recent/MySitePagesTemplate2-Search.xml The Output only returns the File content for default.aspx, it does not return ANY other file located in the Search Center Pages folder. There are several pages, results.aspx, videresults.aspx, that are not generated in the output. Is a custom handler needed? How do I get it to recognize the other pages. I am willing to develop the code. First, I would need some guidance for the best means to setup a test case in the PnP PowerShell library and then work out the code issues as required. Any help or guidance is greatly appreciated.2.2KViews0likes0Comments