Skip to content

Instantly share code, notes, and snippets.

@jamiechalmerzlp
jamiechalmerzlp / GlobalSPOAdminSet.ps1
Last active October 20, 2022 20:47
Provides the ability to set an admin to every site in your SharePoint list.
Connect-PnPOnline -Url *sharepointadminurl* -Interactive
$Sites = Get-PnPTenantSite
for($x = 0; $x -lt $Sites.Count; $x++) {
Set-PnPTenantSite -Url $Sites[$x].Url -Owners "*adminemailaddress*"
Write-Host "Updating $($Sites[$x].Title), Site $($x)"
}
@jamiechalmerzlp
jamiechalmerzlp / ConvertCSV-ExcelOnline
Created January 29, 2024 09:26
ConvertCSV to XLSX Script
/**
* Adds CSV data to a specified worksheet in the workbook.
*
* @param {ExcelScript.Workbook} workbook - The target workbook.
* @param {string} csv - The CSV data as a string.
*/
function main(workbook: ExcelScript.Workbook, csv: string): void {
// Access the target worksheet.
let targetSheet = workbook.getWorksheet("Sheet1");
@jamiechalmerzlp
jamiechalmerzlp / AddTableRenameHeadersEtc-ExcelOnline
Created January 29, 2024 09:33
Add Table Rename Headers Etc
/**
* Replace all speech marks with blanks in the active sheet of Excel Online.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the currently active worksheet in the workbook
let activeSheet = workbook.getActiveWorksheet();
// Get the used range of the active sheet
let usedRange = activeSheet.getUsedRange();
## DEFINE THE DIRECTORY PATH
$directoryPath = "C:\temp"
## CHECK IF THE DIRECTORY EXISTS
if (-Not (Test-Path -Path $directoryPath)) {
## IF THE DIRECTORY DOES NOT EXIST, CREATE IT
New-Item -Path $directoryPath -ItemType Directory
Write-Output "Directory $directoryPath created."
} else {
Write-Output "Directory $directoryPath already exists."
## CONNECT TO EXCHANGE ONLINE POWERSHELL OR USE EXCHANGE MANAGEMENT SHELL FOR ON-PREMISES EXCHANGE
if (-not (Get-Module -ListAvailable -Name ExchangeOnlineManagement)) {
Write-Host "ExchangeOnlineManagement module is not installed. Installing it..."
## INSTALL THE EXCHANGEONLINEMANAGEMENT MODULE FROM THE POWERSHELL GALLERY
Install-Module -Name ExchangeOnlineManagement -Force -Scope CurrentUser
if ($?) {
Write-Host "ExchangeOnlineManagement module has been successfully installed." -ForegroundColor Green
} else {
# Check if ExchangeOnlineManagement module is installed
if (-not (Get-Module -ListAvailable -Name ExchangeOnlineManagement)) {
Write-Host "ExchangeOnlineManagement module is not installed. Installing it..."
# Install the ExchangeOnlineManagement module from the PowerShell Gallery
Install-Module -Name ExchangeOnlineManagement -Force -Scope CurrentUser
if ($?) {
Write-Host "ExchangeOnlineManagement module has been successfully installed." -ForegroundColor Green
} else {
@jamiechalmerzlp
jamiechalmerzlp / EnableTLS123.ps1
Created September 18, 2024 10:28
Enable TLS 1.1 1.2 and 1.3 on Server 2022
# Enable TLS 1.1
New-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1' -Force
New-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server' -Force
New-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client' -Force
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server' -Name 'Enabled' -Value 1
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Server' -Name 'DisabledByDefault' -Value 0
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client' -Name 'Enabled' -Value 1
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client' -Name 'DisabledByDefault' -Value 0
# Enable TLS 1.2
@jamiechalmerzlp
jamiechalmerzlp / BulkProvisionOneDrive.ps1
Created March 14, 2025 20:00
This script automates the provisioning of OneDrive for licensed users in a SharePoint Online environment. It connects to Microsoft Graph and SharePoint Online, retrieves licensed users, and provisions their OneDrive accounts in batches.
<#
Author: Jamie Chalmers of Agilico - 3rd Line Tech & Telco Engineer
Description: This script automates the provisioning of OneDrive for licensed users in a SharePoint Online environment.
It connects to Microsoft Graph and SharePoint Online, retrieves licensed users, and provisions their OneDrive accounts in batches.
#>
Param(
[Parameter(Mandatory = $True)]
[String]
$SharepointURL,