Skip to main content

Office 365 With PNP PowerShell 2013: Base Cmdlets

This is my third blog post on the topic PnP-PowerShell 2013. In this post I am going to give clear understanding, how to make the connection and close the connection using PnP Base Cmdlets section. 


In the background the “Microsoft.SharePoint.Client.dll” is responsible for get the all results from the SharePoint. 

The value also increase of learning if you already have experience on client object Model.Basic tip from my side please read some information about the client side object model.  

As you may be know the client site object model you can’t get all the data from the server in single request. You need to identify which property you need and just use the load method to load that type of property also you can use the Get-PnpProperties Cmdlet. 

Implementation
The command that I am going to cover as mentioned below. 

These are the most common rest of others not much important in terms of PNP 2013 on premise. The numbers of command are 6.

Sr. No
Command Name
Description as PNP team
1.
Connects to a SharePoint site and creates a context that is required for the other PnP Cmdlets
2.
Returns a Client Side Object Model context
4.
Sets the Client Context to use by the cmdlets
3.
Will populate properties of an object and optionally, if needed, load the value from the server. If one property is specified its value will be returned to the output.
5.
Executes any queued actions / changes on the SharePoint Client Side Object Model Context
6.
Disconnects the context

Connect-PnPOnline: To connect with the SharePoint site there are many methods are available. I recommended, please do check the documentation first.  Depending upon your environment use that type of authentication parameters it could be window, form authentication, O365, app authentication and Azure authentication.'



In On Premise you can use the following two methods mostly.
Case 1 it will show the User name and password prompt. And case 2  the logged machine access to the site then you can use this method with CurrentCredentials switched.

Case 1: Connect-PnPOnline -Url https://contoso.sharepoint.com -Credentials (Get-Credential)
Case 2: Connect-PnPOnline -Url http://yourlocalserver CurrentCredentials
Get-PnPContext :  If you want to save the current context. This command is very handy and it returns the current context. Why you need context it might be the case you need to save the current context. By switch between two sites you need this.

$ctx = Get-PnPContext

Set-PnPContext: It is used to set the connection of the existing saved connection via Get-PnPContext command.
Set-PnPContext -Context <ClientContext>

Get‑PnPProperty:  Load the other properties of the object. By defaults these properties not included in the SharePoint Clinet Site object mode. We need to load the explicitly. Example as mentioned below.
PS:> $web = Get-PnPWeb
PS:> Get-PnPProperty -ClientObject $web -Property Id, Lists
PS:> $web.Lists

Execute-PnPQuery: This will execute the any queued actions/changes on the SharePoint Clint Object model. Also you can retry and wait parameter pass as an optional.
PS:> Execute-PnPQuery -RetryCount 5
PS:> Execute-PnPQuery -RetryWait 10

Disconnect-PnPOnline: Disconnects the context
Disconnect-PnPOnline

I am using all the above methods as we discussed/Covered.

Example Plan: I give you example to connect the site using “Connect‑PnPOnline” and save the context to using “Get‑PnPContext” command. Then use the existing context with the help of “Set‑PnPContext” command and read other properties. And use the  using this command “Execute‑PnPQuery” method to get the some of the important properties. At the end I am close the connect using “Disconnect‑PnPOnline” command. 


Here is the example 1



Here is the example 2


Here is the Example 3




Comments

Popular posts from this blog

SharePoint RPC Protocols Examples Using OWSSVR.DLL

What is SharePoint RPC Protocols? Part 1 This reference includes information about the methods and usage of SharePoint Foundation Remote Procedure Call (RPC) protocol. This protocol can be used in Win32-based applications or in ASPX applications to make HTTP POST requests to the server. Methods in this protocol that do not modify the contents of the database can also be used in URL protocol to make HTTP GET requests. Definition taken from http://msdn.microsoft.com/en-us/library/ms448359.aspx You will find the OWSSVR.DLL in SharePoint 2010 Server Physical Path: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI and MOSS C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI OWSSVR.DLL List of commands DialogView  Display ExportList GetProjSchema GetUsageBlob HitCounter RenderView To read more about the OWSSVR.DLL command Please read the URL Protocol from Microsoft Blog having a URL http://msdn.microsoft.com/en...

SharePoint 2013 Search Database Part 1

SharePoint 2013 Search architecture drastically change, as earlier in FS4SP 2010 we have 2 search applications “FASTContentSSA” and “FASTQuerySSA” and 7 total database in use. Following are the List of DB (FS4SP) FASTContentSSA Search Service Application DB Search Service Application Crawl Store DB Search Service Application Property Store DB FASTQuerySSA Search Service Application DB Search Service Application Crawl Store DB Search Service Application Property Store DB FASTSearchAdminDatabase : Fast Search Admin Database  In SharePoint 2013 search has only 1 Search Service application and 4 database in use. No property store database need any more, now the properties are directly stored inside the index component and all the index directly indexed to the physical system where FS4SP data comes from database as well as from the File system now data directly stored and indexed/ retried from the Physical disk because of this performance increase and search experien...

STS CryptographicException Error : Key set does not exist

Common mistakes Both SharePoint Site and SSO Site NOT running on the same application pool. Application pool identity user doesn’t have permission to access the certification.  Solution to this problem Set the same identity pool to  : 2. Be sure to grant rights to the certificate for the App Pool running the web service Start -> Run -> MMC File -> Add/Remove Snapin Add the Certificates Snap In Select Computer Account, then hit next Select Local Computer (the default), then click Finish On the left panel from Console Root, navigate to Certificates (Local Computer) -> Personal -> Certificates You're certificate will most likely be here. Right click on your certificate -> All Tasks -> Manage Private Keys Set you're private key settings here. Add app pool account Reset iis