Last active
January 25, 2021 09:18
-
-
Save BasantPandey/7a138044cfd4007d6ec1cc03b80a2d0c to your computer and use it in GitHub Desktop.
Simple How to use the Get-PnPContext and other commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Please make sure you have installed all the powershell package. | |
Import-Module 'C:\Users\basantp\Documents\PNP Blog Section\Code\SharePointPnPPowerShell2013\SharePointPnP.PowerShell.2013.Commands.dll'; | |
try { | |
Set-PnPTraceLog -On -LogFile 'C:\Users\basantp\Documents\PNP Blog Section\Code\traceoutput.txt' -Level Error -Delimiter "," | |
$Url1 = "https://sharepoint-xxx.com/xx/xxx" | |
Connect-PnPOnline -Url $Url1 -CurrentCredentials -ErrorAction Stop | |
Write-host "Site connected". | |
$Context= Get-PnPContext # Connect and store the context | |
$Web = $Context.Site.RootWeb | |
$Context.Load($Web) | |
$Web.Title #You will not find any output in your console. | |
Execute-PnPQuery #Once you use Execute-PnpQuery you will find the properties. | |
$Web.Title #Title Will be Print | |
} | |
catch { | |
Write-Host "Site not found" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment