pnp powershell
16 TopicsCopy-PnPFile Not Working Value cannot be null.\r\nParameter name: Null value for source item at
I'm tying to use Copy-PnPFile command to copy all files and folders from site collection A document library to another site collection B/folder but it's not working. Following is the command I'm using: Copy-PnPFile -SourceUrl "/sites/AshTest/Docs" -TargetUrl "/sites/ADM-AshTest/TestDocs/Docs" -Force Error, please let me know what can be done to make it work. Copy-PnPFile : {"odata.error":{"code":"-2147467261, System.ArgumentNullException","message":{"lang":"en-US","value":"Value cannot be null.\r\nParameter name: Null value for source item at https://tenant.sharepoint.com/sites/AshTest/Docs"}}} At line:1 char:1 + Copy-PnPFile -SourceUrl "/sites/AshTest/Docs" -TargetUrl "/sites/ADM- ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (:) [Copy-PnPFile], HttpRequestException + FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Files.CopyFile2.7KViews0likes3CommentsRename-pnpFile gives me access denied with admin rights
Hello! I have problems renaming my files. I'm using these commands: #this is one command i tried connect-pnponline -url "https://contoso.sharepoint.com/sites/Clients" -interactive -validateconnection $file = Get-PnPFile -Url "/sites/Clients/folder/subfolder/IT_testi_password.txt" Rename-PnPFile -SiteRelativeUrl $file -TargetFileName "renamedfile.txt" -Force -Verbose # this is another connect-pnponline -url "https://contoso.sharepoint.com/sites/Clients" -interactive -validateconnection Rename-PnPFile -SiteRelativeUrl "/sites/Clients/folder/subfolder/IT_testi_password.txt" -TargetFileName "renamed.txt" -Force -Verbose I tried those commands too with overwrite but I only get access denied (I dont know what is checking to say me that because i can put everything in the source and it says me same ) the error: #I'm putting this error to show that i can put anything i want Line | 4 | Rename-PnPFile -SiteRelativeUrl "asrfeqrew" -TargetFileName "workingc … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Access denied. PS /Users/user> #and this one is a common one Rename-PnPFile: /Users/user/Desktop/project/Scripts/Untitled-1.ps1:4:1 Line | 4 | Rename-PnPFile -SiteRelativeUrl "/sites/Clients/folder/subfolder/IT_testi_password.txt" -T … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Access denied. I'm using visual studio with a mac and have Sharepoint administrator right, also i can rename the same file via web. Can someone help me with this problem?2KViews0likes4CommentsFacing issue in installing the Pnp PowerShell Module for SharePoint 2013/Online
Hi All, I am facing issue in installing the PnP PowerShell module for SharePoint 2013/online. Please let me know if anyone has faced such issue Chendrayan Venkatesan . Error Description: PS C:\WINDOWS\system32> Install-Module SharePointPnPPowerShell2013 PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'SharePointPnPPowerShell2013'. Try Get-PSRepository to see all available registered module repositories. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21 + ... $null = PackageManagement\Install-Package @PSBoundParameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage PS C:\WINDOWS\system32> Install-Module SharePointPnPPowerShellOnline PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'SharePointPnPPowerShellOnline'. Try Get-PSRepository to see all available registered module repositories. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21 + ... $null = PackageManagement\Install-Package @PSBoundParameters + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage PS C:\WINDOWS\system32> $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 5 1 17134 407 Thanks, Prabhu36KViews0likes5CommentsError when invoke PnP Template from legacy team site to modern team site
Hi , we have a legacy team site, which has a document library with 2013 workflows migrated in it. We want to create a test document library same columns under modern team site and perform some test on them. While deploying the exported template we are getting following error which seems like causing due to legacy and modern site difference. is there any work around that we can just move the document library to modern site with out any items in it? Error: Invoke-PnPSiteTemplate : Referenced content type 0x0120D520 not available in site or in template After some research, found this article but not sure how to use the fix in my case? https://techcommunity.microsoft.com/t5/sharepoint-developer/pnp-provisioning-framework-referenced-co... Thanks599Views0likes0Commentsget warning WARNING: Parameter 'Web' is obsolete. The -Web parameter will be removed in a future
hi, While using a pnp script I got a warning as below. Can you advise how to remove the warning WARNING: Parameter 'Web' is obsolete. The -Web parameter will be removed in a future release. thanks1.7KViews0likes3CommentsDynamically copy Sharepoint lists' content with circular lookups to the another site
Hello! For about two weeks I've been researching for a solution to move a couple of sites from one site to another. I've come up with two Powershell scripts, first, to create an exact copy of a source site's structure and second, to move all of the items, including lookup fields, to that site. The idea is to get all of the source list's items, populate the gaps between items with "dummies" or, better to be called, just empty records, upload it to the csv file and then, from the csv file to the destination site. At the end delete the dummies, directly from the list. It may sound dumb but I'm new into Powershell and Microsoft services at all. Scripts use PnP Powershell and work with Sharepoint Online sites. My problem is with multi lookup fields. I do not know how to correctly write them into the CSV file so they can be later uploaded in to hashtable and then, to the destination list. Also, maybe there is easier way to do such a thing, so I'd be glad if you could help me to find it out. Scripts: Script #1 - create a template, based on the source site's lists, and upload it to the specified site Connect-PnPOnline -Url https://myenvironment.sharepoint.com/sites/source_site -Interactive $template = "C:\Users\myuser\...\temp.xml" Get-PnPSiteTemplate -Out $template -ListsToExtract "list1", "list2", "list3" -Handlers Lists Connect-PnPOnline -Url https://myenvironment.sharepoint.com/sites/destination_site -Interactive Invoke-PnPSiteTemplate -Path $template Script #2 - copy the source site's items to the destiniation site's newly created lists Connect-PnPOnline -Url $source_site -Interactive $source_site = "https://myenvironment.sharepoint.com/sites/source_site" $destination_site = "https://myenvironment.sharepoint.com/sites/destnation_site" $source_list = read-host "Set the destination list: " $csv_path = "C:\Users\myuser\...\temp.csv" $fields = @(Get-PnPField -List $source_list -ReturnTyped | Where-Object { $_.Hidden -eq $false -and $_.ReadOnlyField -eq $false -and $_.InternalName -ne "Attachments" -and $_.InternalName -ne "ContentType" -or $_.InternalName -eq "ID"}).InternalName $dummies = 1..((Get-PnPListItem -List $source_list).Length*2) $list_items = Get-PnPListItem -List $source_list -Fields $fields $object_array = @() $list_items | ForEach-Object { $object = New-Object PSCustomObject $fields_values = Get-PnPProperty -ClientObject $_ -Property FieldValuesAsText ForEach($field in $fields) { if((Get-PnPField -List $source_list -Identity $field).TypeAsString -eq "Lookup") { Get-PnPListItem -List $source_list -Fields $field | Out-Null $lookup = [Microsoft.SharePoint.Client.FieldLookupValue]$_[$field] $object | Add-Member Noteproperty $field $lookup.LookupId } else { $object | Add-Member Noteproperty $field $fields_values[$field] } } $object_array += $object } for($i=1; $i -le $dummies.Length; $i++) { if($object_array.ID -notcontains $i){ $object = New-Object PSCustomObject ForEach($field in $fields) { if($field -eq "ID") { $object | Add-Member Noteproperty $field $i } else { $object | Add-Member Noteproperty $field 0 } } $object_array += $object } } $object_array = $object_array | Sort-Object -Property ID $object_array | Export-CSV $csv_path -NoTypeInformation -Encoding UTF8 $csv_table = Import-Csv $csv_path | Select * -ExcludeProperty ID Connect-PnPOnline -Url $destination_site -Interactive foreach($row in $csv_table) { $item_values = @{} $row.psobject.properties | Foreach {$item_values[$_.Name] = $_.Value} Add-PnPListItem -List $source_list -Values $item_values } $fields_to_delete = Get-PnPListItem -List $source_list foreach($element in $fields_to_delete) { if($element["Title"] -eq "0"){Remove-PnPListItem -List $source_list -Identity $element["ID"] -Force} } Thanks for help!974Views0likes0CommentsContent editor web part losing table format and images inside a table on editing the modernized page
Problem Area Page Transformation: Error during the use of page transformation from PnP PowerShell Expected or Desired Behavior Content in the tables having custom formatting for the table and images added within the table cells in the content editor web part in the classic web part pages should be modernized properly. PnP PowerShell Online Version Details: Name: SharePointPnPPowerShellOnline Version: 3.29.2101.0 Observed Behavior Content in the content editor web parts having tables with formatting and images within the table are migrated properly but when we edit the page and save the modernized page, it is losing its table format along with the inline images in the table. Classic Web part page Modernized page Edit and save the modernized page You can notice, it is losing the image on save and for other cases it is also losing formatting in the tables which has highly customized formatting. Steps to Reproduce Create a classic web part page -> add content editor web part -> Insert tables -> apply custom formatting -> add images in the table cell -> save the page Then use the below script to modernize the page: ConvertTo-PnPPage -Identity $page.FieldValues["ID"] -Overwrite -DisablePageComments -AddTableListImageAsImageWebPart: $false -ClearCache -SkipItemLevelPermissionCopyToClientSidePage -TakeSourcePageName:$TakeSourcePageName -LogType File -LogFolder $LogOutputFolder -LogVerbose -LogSkipFlush -KeepPageCreationModificationInformation -CopyPageMetadata806Views0likes0CommentsAdd-PnPClientSideWebPart : One or more errors occurred.
Why is this happening? Does not matter what kind of web part, this one a document library, I still get the same kind of error message. Using the latest version of PnP for SharePoint Online. I can create a page with PnP, add a Text part and so on... https://github.com/pnp/PnP-PowerShell/issues/2913 Add-PnPClientSideWebPart -Page $Page -DefaultWebPartType List -Section 1 -Column 1 -WebPartProperties @{isDocumentLibrary="true";selectedListId="a4140c74-b780-417c-89c1-381e24a6e699"} Add-PnPClientSideWebPart : One or more errors occurred. At line:1 char:1 + Add-PnPClientSideWebPart -Page $Page -DefaultWebPartType List -Sectio ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : WriteError: (:) [Add-PnPClientSideWebPart], AggregateException + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.WebParts.AddClientSideWebPart2.2KViews0likes1CommentEmpty space between Sections when creating Webparts via PnP
Hey, I am still in the process of creating a script that automatically makes various adjustments when a new site is created. Among other things 3 webparts should be added. 1 list with a custom JSON formatting, 1 group calendar and "Highlight Content". This all works very well in itself, but I have a big empty gap within the first sections. As soon as I click on Edit in the GUI the gap is gone. Do I have an error in the script or do I have to add a separate command at the end that it renders the page again? Here is an extract from the script and the result #Add needed Webparts $list = Get-PnPList -Identity $ListName $views = Get-PnPProperty -ClientObject $list -Property Views foreach ($view in $views) { if ($view.Title -eq $ViewName) { $viewID = $view.id } } Add-PnPClientSidePageSection -Page $page -SectionTemplate TwoColumn Add-PnPClientSideWebPart -Page $page -DefaultWebPartType “List” -Section 1 -Column 1 -WebPartProperties @{isDocumentLibrary="false";selectedListId=$list.Id; selectedViewId=$viewID; hideCommandBar="true"; webpartHeightKey="4"} Add-PnPClientSideWebPart -Page $page -DefaultWebPartType "GroupCalendar" -Section 2 -Column 2 -WebPartProperties @{title=”Upcoming Appointment”;showPerPage="3"; selectedGroupId=$groupID; accessType="private"} $JSONMostRecent = '{"query":{"contentLocation":4,"contentTypes":[1],"sortType":1,"filters":[{"filterType":1,"value":"","values":[]}],"documentTypes":[99],"advancedQueryText":""},"templateId":1,"maxItemsPerPage":8,"hideWebPartWhenEmpty":false,"sites":[],"queryMode":"Basic","layoutId":"Card","dataProviderId":"List","webId":"$($web.id)","siteId":"$($site.id)","lastListId":"$($list.id)","listId":"$($list.id)","listTitle":"Documents","caml":"<View Scope=\"RecursiveAll\"><Query><Where><Eq><FieldRef Name=\"FSObjType\" /><Value Type=\"Integer\">0</Value></Eq></Where><OrderBy><FieldRef Name=\"Modified\" Ascending=\"false\" /></OrderBy></Query><ViewFields><FieldRef Name=\"Editor\" /><FieldRef Name=\"FileLeafRef\" /><FieldRef Name=\"File_x0020_Type\" /><FieldRef Name=\"ID\" /><FieldRef Name=\"Modified\" /><FieldRef Name=\"Title\" /><FieldRef Name=\"UniqueID\" /><FieldRef Name=\"_ShortcutUrl\" /></ViewFields><RowLimit Paged=\"false\">8</RowLimit></View>"}' Add-PnPClientSideWebPart -Page $page -DefaultWebPartType "ContentRollup" -Section 2 -Column 1 -WebPartProperties $JSONMostRecent Many thanks for your answers and advice. Best regards1.6KViews0likes1CommentAzure Automation Runbooks using Powershell: Push notifications error?
I'm trying to run some PnP PowerShell commands in an Azure Runbook (e.g. Get-PnPContentType, Apply-PnPProvisioningTemplate, etc. ) over a SharePoint site, but it keeps returning the error below: The Push Notifications feature is not activated on the site The correct modules have been imported and it only errors on some commands. Running the commands in a PowerShell window with the same credentials doesn't produce any errors, and activating the 'Push Notifications' feature manually and retriggering the Runbook won't produce any error output, but will say that the Runbook failed to run 3 times.4.2KViews0likes1Comment