Skip to content

Cesivi Server - PnP PowerShell Guide

Version: 2.0 Last Updated: 2026-03-28


Overview

Cesivi Server supports PnP PowerShell cmdlets for SharePoint Server 2019 and Subscription Edition. This enables automation and scripting using the familiar PnP PowerShell module.

Supported PnP Version: PnP.PowerShell for SharePoint On-Premises (v1.x) Compatibility: ~88% of PnP cmdlets are supported (196P/27F/50S)


Setup

Installation

Install PnP PowerShell module:

# For SharePoint On-Premises 2019/SE
Install-Module -Name SharePointPnPPowerShellOnline -Force

# Or for newer PnP module
Install-Module -Name PnP.PowerShell -Force

Connect to Cesivi Server

# Connect with credentials
$siteUrl = "http://localhost:5000/Default/RootSite"
Connect-PnPOnline -Url $siteUrl -Credentials (Get-Credential)

# Or with username and password directly
$username = "admin"
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential($username, $password)
Connect-PnPOnline -Url $siteUrl -Credentials $credentials

Common Operations

Web Operations

# Get current web
$web = Get-PnPWeb
Write-Host "Site: $($web.Title)"

# Get web properties
Get-PnPProperty -ClientObject $web -Property Title, Description, Created

List Operations

# Create a list
New-PnPList -Title "Project Tasks" -Template GenericList

# Get a list
$list = Get-PnPList -Identity "Project Tasks"

# Get all lists
Get-PnPList | Select-Object Title, ItemCount

# Delete a list
Remove-PnPList -Identity "Project Tasks" -Force

List Item Operations

# Add an item
Add-PnPListItem -List "Project Tasks" -Values @{
    "Title" = "Complete documentation"
    "Status" = "Active"
    "Priority" = 10
}

# Get all items
Get-PnPListItem -List "Project Tasks"

# Get filtered items
Get-PnPListItem -List "Project Tasks" -Query @"
<View>
    <Query>
        <Where>
            <Eq>
                <FieldRef Name='Status' />
                <Value Type='Choice'>Active</Value>
            </Eq>
        </Where>
    </Query>
</View>
"@

# Update an item
Set-PnPListItem -List "Project Tasks" -Identity 1 -Values @{
    "Status" = "Completed"
}

# Delete an item
Remove-PnPListItem -List "Project Tasks" -Identity 1 -Force

File Operations

# Upload a file
Add-PnPFile -Path "C:\Documents\report.pdf" -Folder "Documents"

# Download a file
Get-PnPFile -Url "/Documents/report.pdf" -Path "C:\Downloads\report.pdf" -AsFile

# Get file properties
$file = Get-PnPFile -Url "/Documents/report.pdf"
$file | Select-Object Name, Length, TimeCreated

User and Group Operations

# Get current user
Get-PnPUser -Identity $web.CurrentUser.LoginName

# Ensure user
$user = New-PnPUser -LoginName "user@example.com"

# Get a group
Get-PnPGroup -Identity "Owners"

# Add user to group
Add-PnPUserToGroup -LoginName "user@example.com" -Identity "Members"

Known Limitations

Unsupported Features

The following PnP features are not fully supported in Cesivi Server:

  1. SharePoint Online-specific cmdlets (e.g., tenant administration, Microsoft 365 integration)
  2. Site provisioning with complex templates (use simplified templates)
  3. Some advanced search operations

Known Issues

  1. AsEnumerable() limitation - Calling .AsEnumerable() on CSOM collections may fail. Use foreach loops instead.
  2. Lambda expressions - Complex property selectors in Get-PnPProperty may not work. Load all properties or use simple selectors.

See: PNP_COMPATIBILITY.md for comprehensive compatibility matrix


Example Scripts

Complete Workflow

# Connect
Connect-PnPOnline -Url "http://localhost:5000/Default/RootSite" -Credentials (Get-Credential)

# Create list
New-PnPList -Title "Project Tasks" -Template GenericList
Write-Host "List created"

# Add items
1..5 | ForEach-Object {
    Add-PnPListItem -List "Project Tasks" -Values @{
        "Title" = "Task $_"
        "Priority" = $_ * 2
    }
}
Write-Host "5 items added"

# Query items
$items = Get-PnPListItem -List "Project Tasks"
Write-Host "Items:"
$items | ForEach-Object {
    Write-Host "  $($_["Title"]) - Priority: $($_["Priority"])"
}

# Update item
Set-PnPListItem -List "Project Tasks" -Identity 1 -Values @{ "Priority" = 20 }
Write-Host "Updated item 1"

# Delete item
Remove-PnPListItem -List "Project Tasks" -Identity 5 -Force
Write-Host "Deleted item 5"

# Verify count
$finalItems = Get-PnPListItem -List "Project Tasks"
Write-Host "Final count: $($finalItems.Count)"

# Cleanup
Remove-PnPList -Identity "Project Tasks" -Force
Write-Host "List deleted"

Best Practices

  1. Use -Force for non-interactive scripts to skip confirmation prompts
  2. Handle errors with try-catch for production scripts
  3. Disconnect when done using Disconnect-PnPOnline
  4. Avoid complex CAML queries - use simple filters when possible
  5. Test scripts in non-production environments first

Additional Resources

  • PNP_COMPATIBILITY.md - Detailed compatibility matrix (~88% cmdlet support)
  • API_REFERENCE.md - REST API reference
  • CSOM_GUIDE.md - CSOM programming guide
  • KNOWN_LIMITATIONS.md - Known limitations and workarounds

Last Updated: 2026-03-28 Version: 2.0 For Support: See README.md