Skip to content

Instantly share code, notes, and snippets.

View AsishP's full-sized avatar

Asish Padhy AsishP

  • Sydney, Australia
View GitHub Profile
Get-PnPProvisioningTemplate -Out "<Folder location in drive>"
-ExcludeHandlers ApplicationLifecycleManagement, SiteSecurity
-ExcludeContentTypesFromSyndication
$cred = Get-Credential
Connect-SPOService -Url "https://<tenant>-admin.sharepoint.com" -Credential $cred
# get a reference to the site collection where the
# site collection app catalog should be created
$site = Get-SPOSite https://contoso.sharepoint.com/sites/marketing
# create site collection app catalog
Add-SPOSiteCollectionAppCatalog -Site $site
public SecureString GetSecret()
{
try
{
// Get the Secret Uri from Key Vault
string SecretUri = System.Environment.GetEnvironmentVariable("<KeyValutSecretUri>");
var kvToken = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(GetToken));
var kvSecret = kvToken.GetSecretAsync(SecretUri).Result;
SecureString secpass = new SecureString();
foreach (char charpass in kvSecret.Value)
$userPass = $env:EncryptedPass
$keyPath = 'D:\home\site\wwwroot\<FunctionName>\bin\<PasswordFileName>.key'
$secPass = $userPass | ConvertTo-SecureString -Key (Get-Content $keyPath)
## Create an Encrypted Password ##
$AESKey = New-Object Byte[] 32
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($AESKey)
Set-Content C:\Temp\<PasswordFileName>.key $AESKey
## Run the above code first, then upload the above file to the Function App##
Function Get-EncryptedPassword
{
param (
using (var context = new ClientContext(<SiteUrl>))
{
context.Credentials = new SharePointOnlineCredentials(UserName, SecurePass);
Web web = contextAsset.Web;
contextAsset.Load(web);
contextAsset.ExecuteQuery();
// Updating Permissions to an existing Permission Level. Eg. Removing Manage Permissions from Edit Permission level
log.Info("Removing Manage Permissions from Edit Permissions of Site ");
context.Load(web.RoleDefinitions);
$credentials = Get-Credential
Connect-PnPOnline "https://<your-tenant>.sharepoint.com/sites/<target-site>" -Credentials $credentials
## You can use the following PnP cmdlet
## ClientSideComponentId from Manifest.Json of the extension
Add-PnPCustomAction -Name "<CommandSetName>" -Title "<CommandSetTitle>" -Description "<Text>" -RegistrationId "101" -RegistrationType List -ClientSideComponentId "<Id from Manifest.json>" -Location "ClientSideExtension.ListViewCommandSet"
private string appJsonInfo;
private AppDeclaration Apps;
// A class to hold JSON converted objects for Apps
private class AppDeclaration
{
public string appName;
public string appId;
public string clientsideId;
}
private string appJsonInfo;
private AppDeclaration Apps;
// A class to hold JSON converted objects for Apps
private class AppDeclaration
{
public string appName;
public string appId;
public string clientsideId;
}
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core.ALM;
using OfficeDevPnP.Core.Pages;
using OfficeDevPnP;
public void DeploySingleApp(Guid appId)
{
using (ClientContext context = new ClientContext(<SiteUrl>))
{
context.Credentials = new SharePointOnlineCredentials(UserName, SecurePass);