Skip to content

Instantly share code, notes, and snippets.

Basant Pandey BasantPandey

Block or report user

Report or block BasantPandey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@BasantPandey
BasantPandey / Connect.ps1
Created Sep 23, 2018
Connect SharePoint Using Username and password
View Connect.ps1
$ProgressPreference = "SilentlyContinue"
$WarningPreference = "SilentlyContinue"
#Import Modudle
Import-Module $PSScriptRoot\SharePointPnPPowerShellOnline\SharePointPnPPowerShellOnline.psd1 -ErrorAction SilentlyContinue
#Uncomment to run the same script to your local
#$env:APPSETTING_PWord="<Passowrd>"
#$env:APPSETTING_User="<userName>"
@BasantPandey
BasantPandey / AppPermissionRequests.xml
Created Sep 23, 2018
SharePoint App Permission request file for tenant full control
View AppPermissionRequests.xml
<AppPermissionRequests AllowAppOnlyPolicy="true">
<AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />
<AppPermissionRequest Scope="http://sharepoint/social/tenant" Right="Read" />
<AppPermissionRequest Scope="http://sharepoint/taxonomy " Right="Read" />
</AppPermissionRequests>
View ConnectViaApp.ps1
function Connect([string]$Url) {
if ($Url -eq $Global:lastContextUrl) {
return
}
if ($appId -ne $null -and $appSecret -ne $null) {
Connect-PnPOnline -Url $Url -AppId $appId -AppSecret $appSecret
}
else {
Connect-PnPOnline -Url $Url
}
View Fields.ps1
#Dev Import
$Path = "C:\SharePointPnPPowerShell2013\"
Import-Module '$Path\SharePointPnP.PowerShell.2013.Commands.dll';
#-----Function to create Site Columns----#
function CreateSiteColumns($csvPath, $SiteURL) {
$Cred = $global:GlobalCred
$newUtfFile = "SiteCollectionSiteColumns_utf8.csv";
@BasantPandey
BasantPandey / RemoveContentType.csv
Last active Jul 23, 2017
Remove-PnPContentType using CSV
View RemoveContentType.csv
ContentTypeName
MyContentType
MyContentType2
MyContentType3
MyContentType4
MyContentType5
@BasantPandey
BasantPandey / Set-PnPHomePage.ps1
Last active Jul 18, 2017
CSV file for Set multiple sites home page in single loop
View Set-PnPHomePage.ps1
Import-Module 'C:\Users\basantp\Documents\PNP Blog Section\Code\SharePointPnPPowerShell2013\SharePointPnP.PowerShell.2013.Commands.dll';
try {
$path = 'C:\Users\basantp\Documents\PNP Blog Section\Code\Branding'
$inputFile = $path + "\SetHomePage.csv"
$MyFile = Import-Csv $inputFile
foreach ($myRow in $MyFile) {
if ($myRow.SiteURL -ne "") {
@BasantPandey
BasantPandey / Add‑PnPJavaScriptBlock.ps1
Last active Jul 18, 2017
Add‑PnPJavaScriptBlock, Add‑PnPJavaScriptLink, Get‑PnPJavaScriptLink and Remove‑PnPJavaScriptLink Methods with Example
View Add‑PnPJavaScriptBlock.ps1
Import-Module 'C:\Users\basantp\Documents\PNP Blog Section\Code\SharePointPnPPowerShell2013\SharePointPnP.PowerShell.2013.Commands.dll';
try {
$URL='<Please enter your url>'
Connect-PnPOnline -Url $URL -CurrentCredentials -ErrorAction Stop
Write-host "Site $URL connected"
#Working code
Add-PnPJavaScriptBlock -Name "myAction" -script ' var ABC = alert("This is my Script block");' -Sequence 20000 -Scope Site
@BasantPandey
BasantPandey / BrandingConfig_Add.csv
Last active Jul 17, 2017
Branding Add Custom Action CSV file
View BrandingConfig_Add.csv
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 2.
URL,Action,Name,Title,Description,Group,LocationRibbon,Location,ButtonID,Alt,Sequence,Command,LabelText,TemplateAlias,Image32by32,Image16by16,CommandAction,EnabledScript,CAML1,CAML2,CAML3,CAML4,CAML5,CAML6,CAML7,CAML8,CAML9,CAML10,CAML11,CAML12,CAML13,CAML14
http://yahoo.com,Add,GetItemsCount,Invoke GetItemsCount Action,Adds custom action to custom list ribbon,SiteActions,CommandUI.Ribbon,Ribbon.List.Share.Controls._children,Ribbon.List.Share.GetItemsCountButton,Get list items count,11,Invoke_GetItemsCountButtonRequest,Get Items Count,o1,_layouts/15/images/placeholder32x32.png,_layouts/15/images/placeholder16x16.png,javascript: alert('Total items in this list: '+ ctx.TotalListItems);,javascript: function checkEnable() { return (true);} checkEnable();,"<CommandUIExtension><CommandUIDefinitions><CommandUIDefinition Location=""","""><Button Id=""",""" Alt=""",""" Sequence=""",""" Command=""",""" LabelText=""",""" TemplateAlias=""",""" Image32by32=""",""" Image16by16=""",""" /></CommandUIDefinition></CommandUIDef
@BasantPandey
BasantPandey / BaseCmdlets-Part2.ps1
Created Jul 14, 2017
The Get-PnPProperty is same as Load method just add the properties to the context
View BaseCmdlets-Part2.ps1
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 = "<URL>"
Connect-PnPOnline -Url $Url1 -CurrentCredentials -ErrorAction Stop
Write-host "Site $Url1 connected".
$web =Get-PnPWeb
Get-PnPProperty -ClientObject $web -Property Id
"Only print the ID : $($web.Id)"
@BasantPandey
BasantPandey / BaseCmdlets-Part1.ps1
Created Jul 14, 2017
Introduction to PNP Basic Command Part1
View BaseCmdlets-Part1.ps1
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 = "<SiteURL>"
$Url2 = "<SiteURL>"
Connect-PnPOnline -Url $Url1 -CurrentCredentials -ErrorAction Stop
Write-host "Site $Url1 connected".
$Context1= Get-PnPContext
You can’t perform that action at this time.