You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the CSOM method CreateAnonymousLink in Powerhsell 5.1 with credentials(username/ps) was the way we used until the recent major update of PnP Module which obviously also upgraded the CSOM assemblies it includes. Now PnP 2.x needs to run in Powershell 7.2.x or later and it did not have Microsoft.SharePoint.Client.SharePointOnlineCredentials anymore. So we can't use Microsoft.SharePoint.Client.ClientContext to create anonymous link without a credential (Using PsCredential object as a replacement returns 403 Forbidden). Still trying to find an alternative way to do it in powershell 7 through PnP Module.
Attempt
I do not find any new PnP cmd that can create anonymous share link for an item. So we still need to use CSOM Assemblies like Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll in PnP 2.x which are probably .net standard20 version. And my current assumption is that we need to use another authentication way like Azure AD OAuth based approach here: https://www.c-sharpcorner.com/article/sharepoint-csom-for-net-standard/
Update and Solution
It turns out we can still use the old way to create anonymous link. We just don't need to create a new Microsoft.SharePoint.Client.ClientContext after Connect-PnPOnline, so we don't need Microsoft.SharePoint.Client.SharePointOnlineCredentials or any other way to pass Credentials into this new client context. Instead using Get-PnPContext gives us the context that already has the credentials.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Issue
Using the CSOM method CreateAnonymousLink in Powerhsell 5.1 with credentials(username/ps) was the way we used until the recent major update of PnP Module which obviously also upgraded the CSOM assemblies it includes. Now PnP 2.x needs to run in Powershell 7.2.x or later and it did not have Microsoft.SharePoint.Client.SharePointOnlineCredentials anymore. So we can't use Microsoft.SharePoint.Client.ClientContext to create anonymous link without a credential (Using PsCredential object as a replacement returns 403 Forbidden). Still trying to find an alternative way to do it in powershell 7 through PnP Module.
Attempt
I do not find any new PnP cmd that can create anonymous share link for an item. So we still need to use CSOM Assemblies like Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll in PnP 2.x which are probably .net standard20 version. And my current assumption is that we need to use another authentication way like Azure AD OAuth based approach here: https://www.c-sharpcorner.com/article/sharepoint-csom-for-net-standard/
Update and Solution
It turns out we can still use the old way to create anonymous link. We just don't need to create a new Microsoft.SharePoint.Client.ClientContext after Connect-PnPOnline, so we don't need Microsoft.SharePoint.Client.SharePointOnlineCredentials or any other way to pass Credentials into this new client context. Instead using Get-PnPContext gives us the context that already has the credentials.
What we had:
What we use now:
Beta Was this translation helpful? Give feedback.
All reactions