Skip to content

Instantly share code, notes, and snippets.

@pmatthews05
pmatthews05 / projectJsonString.cs
Last active May 5, 2022 16:38
Uploading Json String to Cosmos DB
using System;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Azure.Cosmos;
public class Program
{
public static async Task Main()
{
@pmatthews05
pmatthews05 / MSGraphSitePermission.ps1
Created January 12, 2022 16:28
Using AZ CLI and REST commands, a simple way setting the App Registration Selected Site for MS Graph.
function Get-TenantDefaultName {
<#
.SYNOPSIS
Returns the Default and Root Tenant name.
.DESCRIPTION
Returns the Default and Root Tenant name.
.EXAMPLE
export ARM_SUBSCRIPTION="[SUBSCRIPTION_ID]"
export ARM_CLIENT_SECRET="[CLIENT_SECRET]"
export ARM_CLIENT_ID="[CLIENT_ID"
export ARM_TENANT_ID="[TENANT_ID]"
echo $ARM_SUBSCRIPTION
echo $ARM_CLIENT_ID
echo $ARM_CLIENT_SECRET
echo $ARM_TENANT_ID
@pmatthews05
pmatthews05 / azclimigration.ps1
Last active April 8, 2021 15:22
azcli Migration
$SourceAccountName = "[SOURCEACCOUNTNAME]"
$SourceContainer = "[SOURCECONTAINERNAME]"
#Read and List
#Ensure SourceBlobSAS is in single and double quotes for PowerShell
$SourceBlobSAS = '"[SOURCESAS]"'
$DestinationAccountName = "[DESTINATIONACCOUNTNAME]"
$DestinationContainer = "[DESTINATIONCONTAINERNAME]"
#Full Access
#Ensure DestinationBlobSAS is in single and double quotes for PowerShell
$DestinationBlobSAS = '"[DESTINATIONSAS]"'
@pmatthews05
pmatthews05 / AzCopy.ps1
Created April 8, 2021 15:03
AzCopy Migration
$SourceAccountName = "[SOURCEACCOUNTNAME]"
$SourceContainerName = "[SOURCECONTAINERNAME]"
$SourceBlobSAS = "[SOURCESAS]"
$DestinationAccountName = "[DESTINATIONACCOUNTNAME]"
$DestinationContainerName = "[DESTINATIONCONTAINERNAME]"
$DestinationBlobSAS = "[DESTINATIONSAS]"
$SourceContainerURL = "https://$SourceAccountName.blob.core.windows.net/$SourceContainerName"
$DestinationContainerURL = "https://$DestinationAccountName.blob.core.windows.net/$DestinationContainerName"
<#
.SYNOPSIS
Need to use PowerShell version 7.1
PNP needs to be above version 1.4
Need to use the new PNP.PowerShell "Install-Module PnP.Powershell"
Loops through Library obtaining all items that were modified either before or after a given date.
You need to connect to the site first using PNP
Connect-PnPOnline -url:https://[tenant].sharepoint.com/sites/[siteURL] -PnPManagementShell
function Get-ListDataAsStream {
param (
[Parameter(Mandatory)]
[string]
$SiteUrl,
[Parameter(Mandatory)]
[string]
$ListName,
[Parameter(Mandatory)]
[string]
@pmatthews05
pmatthews05 / Get-AllItems.ps1
Created March 2, 2021 09:21
Getting all Items from PNP.Powershell using version 1.2.0
<#
.SYNOPSIS
Need to use PowerShell version 7.1
Need to use the new PNP.PowerShell "Install-Module PnP.Powershell -MaximumVersion 1.2.0 -Scope:CurrentUser -Force"
Loops through Library obtaining all items.
You need to connect to the site first using PNP
Connect-PnPOnline -url:https://beisgov.sharepoint.com/sites/[siteURL] -PnPManagementShell
<#
.SYNOPSIS
Creates a service connection for a ManagementGroup
Please ensure you are already logged to azure using az login
#>
param(
# Azure DevOps Personal Access Token (PAT) for the 'https://dev.azure.com/[ORG]' Azure DevOps tenancy
[Parameter(Mandatory)]
[string]
$PersonalAccessToken,
$PersonalAccessToken = "<PAT TOKEN>"
$TeamProject = '<PROJECT NAME>'
$TeamFoundationCollectionUri = 'https://dev.azure.com/<organizationName >'
$AppRegistrationName = '<Service Principal Name>'
$AppPassword = '<Service Principal Secret>'
$AppSecurePassword = ConvertTo-SecureString -String:$AppPassword -AsPlainText -Force
.\Install-ServiceConnectionManagementGroup.ps1 -PersonalAccessToken $PersonalAccessToken `
-TeamFoundationCollectionUri:$TeamFoundationCollectionUri `
-TeamProject:$TeamProject `