[Important changes] PnP.Powershell – Are you using PnP.Powershell (or considering to update) to manage your Microsoft 365 environments and products such as SharePoint Online, Microsoft Teams, Microsoft Planner, OneDrive, Microsoft Flow and more.
You should note the changes introduced in v.2.1.0 in the change-log
https://github.com/pnp/powershell/blob/dev/CHANGELOG.md
v2.1.0:
- Removed support for PowerShell 5, only PowerShell 7.2 and later will be supported from here onwards
- Added support for .NET 6.0 since .NET Core 3.1 support is getting deprecated. We have removed support for .NET Core 3.1, so users will have to update from PowerShell 7.0.x to PowerShell 7.2.x or later
PnP PowerShell is a cross-platform PowerShell Module providing over 650 cmdlets that work with Microsoft 365 environments and products such as SharePoint Online, Microsoft Teams, Microsoft Planner, Microsoft Flow and more. It runs on Windows, Linux and MacOS
https://pnp.github.io/powershell/
Example – how you can call PnP.Powershell cmdlets using PS 7.x PWSH from PS 5.1
# Since v2.1.0 of PnP.Powershell, Cmdlets only support PS 7.2+
# There we are calling PWSH with a script-block
pwsh -Command {
param($Parameter1, $Parameter2, $Parameter3, $Parameter4, $Parameter5, $Parameter6, $Parameter7)
Write-Output "Connecting to Sharepoint Online / OneDrive using High Privilege Account using Modern method (certificate)"
$Connection1 = Connect-PnPOnline -Url $Parameter1 -ClientId $Parameter2 -Tenant $Parameter3 -Thumbprint $Parameter4 -ReturnConnection
Write-host "Checking OneDrive settings for $($Parameter5)"
$OneDriveUrl = Get-PnPUserProfileProperty -Account $Parameter5 -Connection $Connection1
If ($OneDriveUrl.PersonalUrl)
{
Write-host "Adding manager $($Parameter7) with full control permissions to OneDrive"
$Connection2 = Connect-PnPOnline -Url $OneDriveUrl.PersonalUrl -ClientId $Parameter2 -Tenant $Parameter3 -Thumbprint $Parameter4 -ReturnConnection
$AddOwner = Add-PnPSiteCollectionAdmin -Owners $Parameter6 -Connection $Connection2
$VerifyOneDriveAdmins = Get-PnPSiteCollectionAdmin -Connection $Connection2
If ( ($Parameter6 -in $VerifyOneDriveAdmins.Email) -or ($Parameter6 -eq $VerifyOneDriveAdmins.Email) )
{
Write-host "Manager added to OneDrive"
}
Else
{
Write-host "Manager WAS NOT added to OneDrive"
}
}
} -Args $SharepointUrl,` #$Parameter1
$HighPriv_Modern_ApplicationID_O365,` #$Parameter2
$AzureTenantId,` #$Parameter3
$HighPriv_Modern_CertificateThumbprint_O365,` #$Parameter4
$Username,` #$Parameter5
$Manager.userPrincipalName,` #$Parameter6
$Manager.displayName #$Parameter7
This is a great module. However I think cannot make it run in Visual Studio Code UI along with Microsoft Graph.
As of current I have to use the legacy version (using -UseWindowsPowerShell switch), but some of the commands does not work anymore.
All my scripts run fine when started from the shell.
Do you know if there is a solution to this?