8 votes
Accepted

Retrieve Permissions at folder and file level in Powershell

This is the method using PnP Online. Retrieve the additional properties using Get-PnPProperty Connect-PnPOnline -Url $siteUrl $context = Get-PnPContext For Files $file = Get-PnPFile -Url $...
user avatar
8 votes

Export/import content type to another site collection pnp powershell

Connect-PnPOnline https://yoursite.com/sites/yourFIRSTsite Get-PnPProvisioningTemplate -Out "MyTemplate.xml" -Handlers Lists,ContentTypes Disconnect-PnPOnline Connect-PnPOnline https://yoursite.com/...
user avatar
  • 5,403
7 votes
Accepted

PnP Poweshell: Get-PnPListItem Restrict to a Specific View

Unfortunately, There is no direct parameter like -View to specify your View Name in Get-PnPListItem Meanwhile, as a workaround solution, you can pass the CAML Query to the -Query parameter based on ...
user avatar
6 votes

Pnp powershell boolean field

After you create your field using Add-PnPField, you need to get that field using Get-PnPField and set the default value as below: $field = Get-PnPField -List CustomList -Identity "BoolField" $field....
user avatar
  • 30.3k
6 votes
Accepted

How i can verify that our migrated "Contribute" permission level is exactly the same as the source Contribute permission

I can show how to get this using JavaScript and REST: $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/RoleDefinitions/getByName('Contribute')", async: false, headers: { ...
user avatar
  • 1,505
6 votes
Accepted

How to disable "Connect to Teams" banner in SharePoint Online

You need to use /_api/groupsitemanager/HideTeamifyPrompt method to disable the Teamify banner. You can use it in PnP PowerShell as below: Connect-PnPOnline -Url "https://tenant.sharepoint.com/sites/...
user avatar
  • 30.3k
5 votes

PowerShell Script to Find SharePoint List Template ID

For starters, you compare on the wrong property (and you are not using a PowerShell compare operator): Change if($mylistsToIgnore==$eachList.TempladID) to if($mylistsToIgnore -eq $eachList....
user avatar
5 votes

Connecting to SP2016 using PnP

I have the same issue. A workaround is to use the parameter -UseWebLogin. Connect-PnPOnline -Url https://collab.myCorp.com -UseWebLogin
user avatar
  • 4,335
5 votes

catch statement does not work SharePoint Online PNP

I had the same issue of not being able to catch exceptions with Add-PnPListItem. Running it in a variable and adding -ErrorAction Stop worked for me. Using parts of the OP's script for this example, ...
user avatar
  • 53
4 votes

Sharepoint Online: Powershell recursive CAML query possible?

Try <View Scope='Recursive'> ViewScope enumeration Example, Get Items Under Folder CAML
user avatar
  • 5,361
4 votes

SharePoint/PnP PowerShell with PowerShell Core 6.0

Unfortunately, the answer is no at the moment. PowerShell Core 6.0 is built on top of .NET Core 2.0 runtime. But the thing is, PnP PowerShell depends on PnP CSOM Core components which are dependent ...
user avatar
  • 30.3k
4 votes
Accepted

Add site collection level application catalog

1) You need SharePoint tenant admin access to enable Site collection app catalog. It is assumed that the we already have a tenant app catalog. If its not present, you need to create that first and ...
user avatar
  • 30.3k
4 votes
Accepted

Site provisioning: add web part to page

You can use the {{listid:ListName}} token instead of hard-coding the GUID. When you use this token , the provisioning engine will fix the placeholder with the actual value of the List ID. For ...
user avatar
  • 30.3k
4 votes
Accepted

PnP (PowerShell)

You can get the relative URL this way: $file = Find-PnPFile -Match myFile.docx $file.ServerRelativeUrl Just prefix https://tenantName.sharepoint.com to get the absolute path.
user avatar
  • 28.9k
4 votes
Accepted

How to determine what columns the sharepoint visitors group has

For most PowerShell cmdlets, try something like this: get-pnpgroupmembers -identity "visitors group" | select * or get-pnpgroupmembers -identity "visitors group" | Get-Member As the PNP cmdlets ...
user avatar
4 votes
Accepted

Can i using PnP script Update our custom list items "Status" field without affecting the ModifiedBy and Modifed fields

Yes, you can use Get-PnPListItem with CAML query to fetch the based on your conditions and then update them using Set-PnPListItem and passing the SystemUpdate parameter which wont change the modified ...
user avatar
  • 30.3k
4 votes
Accepted

Batch update via PNP Powershell

By default CSOM is batch update request so all the request are queued until execute query method is called. Use Powershell SPO online commands to create new item but do not call execute query until ...
user avatar
4 votes

New-PnPSite - Check if site is allready created?

You can use the Get-PnPTenantSite command to check if a site collection exists or not as below: $site = "" Try { Write-Host "Checking, if site already exists..." $site = Get-PnPTenantSite -...
user avatar
  • 30.3k
4 votes

Download specific files from a folder in Sharepoint by using Powershell

You could use a CAML query to select your files. This example will get the last 5 modified files. Note that RowLimit won't work as expected, hence the select -first 5 at the end $listname = "...
user avatar
  • 2,229
4 votes
Accepted

get-pnpweb example with connection parameter

Connection needs to be returned from PnP command when you connect to a site/web you can implement this as below. #Web 1 already connected Connect-PnPOnline -Url "https://mytenant.sharepoint.com/...
user avatar
4 votes
Accepted

Bulk Upload 1M files with SharePoint PnP PowerShell

Try this: create a sample document; for instance demodoc.pdf in a folder called DemoFolder use the below PowerShell script to multiply the document demodoc.pdf into one million copies, each with ...
user avatar
  • 172
3 votes

PowerShell Script to Find SharePoint List Template ID

There is no TemplateId property in SPList object. You have to find it by TemplateFeatureId in SPWeb.ListTemplates. $myListColl = $eachWeb.Lists $mylistsToIgnore = @(101) foreach ($eachList in $...
user avatar
  • 1,661
3 votes

Sharepoint Online: Powershell recursive CAML query possible?

Get-PnPListItem -List $targetList -Query "<View Scope=`"RecursiveAll`"><Query><Where><Eq><FieldRef Name = 'FileLeafRef'/><Value Type = 'Text'>Test.txt</Value&...
user avatar
  • 32.4k
3 votes
Accepted

Unable to remove Office 365 Group Site Collection

The solution for the 403 error was to unlock the site collection. Set-SPOSite -Identity <URL> -LockState unlock After that the site collection could be removed with Remove-SPOSite
user avatar
3 votes
Accepted

Using PnP Powershell, retreive a document's path

You need to use $libitem["FileRef"]. So, modify your inner foreach loop as below: foreach($libitem in $libitems) { if({$_.Name -match ".doc*"}) { write-host "lib path... " $libitem["...
user avatar
  • 30.3k
3 votes
Accepted

I need a PowerShell script to Enumerate Sites, Sub-sites,Lists and document libraries and print them in a .csv file (SP 2007)

Here is a tool which we used for SharePoint 2007. http://spm.codeplex.com/releases/view/22762
user avatar
  • 703
3 votes

Convert the SOM to PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue; $spSite=Get-SPSite -Identity "http://sp/sites/dev" $spwWeb=$spSite.OpenWeb() $spAuditQuery=New-Object ...
user avatar
  • 1,737
3 votes

Retrieve Permissions at folder and file level in Powershell

In case you just want to use pnp-powershell, All you need to do for each one of those folders / files: FILE $result = Get-PnPProperty -ClientObject $file -Property RoleAssignments Get-...
user avatar
3 votes
Accepted

understanding set-pnplistitempermission

By list item object, it means passing the Microsoft.SharePoint.Client.ListItem object. You are currently passing string which will not work. You need to use Get-PnPListItem to get the list item and ...
user avatar
  • 30.3k
3 votes

How to lookup AD users with pnp-powershell in SharePoint Online?

There is no PnP native way to do this but you can do it by dropping down into the CSOM EnsureUser method. Try this: $web = get-pnpweb $user = $web.EnsureUser("user@company.com") $ctx = Get-PnPContext ...
user avatar
  • 7,798

Only top scored, non community-wiki answers of a minimum length are eligible