Skip to main content
9 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/...
theChrisKent's user avatar
  • 6,121
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 ...
Mohamed El-Qassas MVP's user avatar
7 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, ...
sonyab's user avatar
  • 73
7 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: { ...
Joe McShea's user avatar
  • 1,525
7 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/...
Gautam Sheth's user avatar
  • 31.1k
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....
Gautam Sheth's user avatar
  • 31.1k
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
Ola's user avatar
  • 4,405
5 votes
Accepted

How do i get the a folder ID based on folder name with pnp powershell?

Updated solution: We have to load the ListItemsAllFields first. Use $folder.Context.Load($folder.ListItemAllFields) $folder.Context.ExecuteQuery() Set-PnPListItemPermission -List 'Team Reports' -...
Lutz's user avatar
  • 101
5 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 ...
Gautam Sheth's user avatar
  • 31.1k
5 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 ...
Siddharth Vaghasia's user avatar
5 votes
Accepted

Connect-SPOService: Could not load type 'Microsoft.SharePoint.Client.SharePointOnlineCredentials' from assembly 'Microsoft.SharePoint.Client.Runtime,

For PowerShell 7, you have to use the Windows PowerShell Compatibility feature because the Microsoft.Online.SharePoint.PowerShell module was built with .NET Framework and not .NET Core. The way this ...
John Holliday's user avatar
4 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["...
Gautam Sheth's user avatar
  • 31.1k
4 votes
Accepted

Add QuickLinks with powershell-pnp

The trick lies in getting the webpart JSON from a workbench page. Go to the workbench page, https://tenant.sharepoint.com/sites/test/_layouts/15/workbench.aspx. On this page, configure your quick ...
Gautam Sheth's user avatar
  • 31.1k
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 ...
Gautam Sheth's user avatar
  • 31.1k
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 are ...
Mike Smith - MCT's user avatar
4 votes

Configure LookUp field using Sharepoint PNP Powershell

Example, we can configure the lookup list and show field for lookup field using the PowerShell below. Connect-PnPOnline –Url https://tenant.sharepoint.com/sites/lz –Credentials (Get-Credential) $...
LZ_MSFT's user avatar
  • 6,269
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 ...
Gautam Sheth's user avatar
  • 31.1k
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 -...
Gautam Sheth's user avatar
  • 31.1k
4 votes
Accepted

Use App Password to Authenticate with PowerShell PnP

Yes. You can use app password to authenticate SharePoint Online site using PowerShell PnP. Hit below URL: Connect-PnPOnline -Url https://contoso.sharepoint.com It will open a pop-up like below where ...
Ganesh Sanap - MVP's user avatar
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 = "...
Rune Sperre's user avatar
  • 2,249
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/...
Akshay Randive's 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 ...
Donspeck's user avatar
  • 302
4 votes
Accepted

How to delete rows from a SharePoint list using PnP PowerShell?

I think this is what you are asking for: Remove-PnPListItem -List "[Your list Title goes here]" -Identity ($TheItemId)
dinos.kon's user avatar
  • 187
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("[email protected]") $ctx = Get-PnPContext ...
Derek Gusoff's user avatar
  • 8,062
3 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 ...
Gautam Sheth's user avatar
  • 31.1k
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 ...
Gautam Sheth's user avatar
  • 31.1k
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
colonel_claypoo's user avatar
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
Ram's user avatar
  • 723
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-...
Alberto S.'s user avatar

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