Skip to content

Instantly share code, notes, and snippets.

View ServicePrincipal-CAFRover.sh
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
View azclimigration.ps1
$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]"'
View AzCopy.ps1
$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"
View Get-AllItemsMetadata.ps1
<#
.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
View Get-ListDataAsStream.ps1
function Get-ListDataAsStream {
param (
[Parameter(Mandatory)]
[string]
$SiteUrl,
[Parameter(Mandatory)]
[string]
$ListName,
[Parameter(Mandatory)]
[string]
@pmatthews05
pmatthews05 / Get-AllItems.ps1
Created Mar 2, 2021
Getting all Items from PNP.Powershell using version 1.2.0
View Get-AllItems.ps1
<#
.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
View Install-ServiceConnectionManagementGroup.ps1
<#
.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,
View Run-InstallServiceConnectionManagementGroup.ps1
$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 `
View management-group.json
{
"administratorsGroup": null,
"authorization": {
"scheme": "ServicePrincipal",
"parameters": {
"serviceprincipalid": "##ServicePrincipalId##",
"authenticationType": "spnKey",
"serviceprincipalkey": "##ServicePrincipalKey##",
"tenantid": "##TenantId##"
}
View cloudSettings
{"lastUpload":"2021-01-29T13:57:27.583Z","extensionVersion":"v3.4.3"}