Skip to content

Instantly share code, notes, and snippets.

@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();
@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 / 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)"
}
# Parameters for source and destination for the Image file
# Current script is edited to put the same image on LockScreen and Wallpaper
$WallpaperURL = "bloburl from azure" # Change to your fitting
$LockscreenUrl = "bloburl from azure" # Change to your fitting
$ImageDestinationFolder = "c:\temp" # Change to your fitting - this is the folder for the wallpaper image
$WallpaperDestinationFile = "$ImageDestinationFolder\wallpaper.png" # Change to your fitting - this is the Wallpaper image
$LockScreenDestinationFile = "$ImageDestinationFolder\LockScreen.png" # Change to your fitting - this is the Lockscreen image
$members = net localgroup administrators |
where {$_ -AND $_ -notmatch "command completed successfully"} |
select -skip 4
$members += $(Get-Date -format 'd')
write-host $members
#Only keep this line if you are using Datto RMM for a UDF.
#New-ItemProperty -PropertyType String "HKLM:\SOFTWARE\CentraStage" -Name "Custom5" -Value $members
#Needs ExchangeOnline and MSOLService
$SharedMailboxes = Get-EXOMailbox -Filter {(recipienttypedetails -eq "SharedMailbox") -or (recipienttypedetails -eq "EquipmentMailbox") -or (recipienttypedetails -eq "RoomMailbox")} | get-MsolUser | Select-Object UserPrincipalName,blockcredential,recipienttypedetails
$SignInEnabledSharedMailboxes = $SharedMailboxes | Where-Object {$_.BlockCredential -eq $False}
$SignInEnabledSharedMailboxes | Export-CSV C:\temp\report.csv -NoTypeInformation
If ($SignInEnabledSharedMailboxes) {
Write-Host "[BAD] $($SignInEnabledSharedMailboxes.Count) shared mailboxes were found with signin enabled."
Do {
$Answer = Read-Host -Prompt 'Do you want to disable signin for all shared mailboxes? (y/n)'
If (!($Answer -match 'y' -or $Answer -match 'n')) {Write-Host 'Please answer "y" for Yes or "n" for No.'}
}
#Function to Download All Files from a SharePoint Online Folder - Recursively
$FolderName = "Name the folder you are downloading"
#The transcript will capture the process to ensure you have a log of the download/transfer - ALWAYS KEEP LOGS
Start-Transcript -Path "C:\temp\$FolderName.txt"
Function Download-SPOFolder([Microsoft.SharePoint.Client.Folder]$Folder, $DestinationFolder)
{
#Get the Folder's Site Relative URL
$FolderURL = $Folder.ServerRelativeUrl.Substring($Folder.Context.Web.ServerRelativeUrl.Length)
$LocalFolder = $DestinationFolder + ($FolderURL -replace "/","\")
#Create Local Folder, if it doesn't exist
$Files = Get-ChildItem -Path "your\directory\here" -File -Recurse -Name -Force -ErrorAction SilentlyContinue | Measure-Object | Select-Object @{Name='File(s) Count';Expression={$_.count}}
$Folders = Get-ChildItem -Path "your\directory\here" -Directory -Recurse -Name -Force -ErrorAction SilentlyContinue | Measure-Object | Select-Object @{Name='Folder Count';Expression={$_.count}}
write-host "Files: $Files"
write-host "Folders: $Folders"
$TPMPRESENT = (Get-Tpm).TpmPresent
$TPMENABLED = (Get-Tpm).TpmEnabled
$TPMREADY = (Get-Tpm).TpmReady
$tpmVersion = Get-WmiObject -Class Win32_Tpm -Namespace root\CIMV2\Security\MicrosoftTpm | Select-Object -Property SpecVersion
$tpmVersionOut = $tpmVersion.SpecVersion.Split(",")[0] -as [string]
Write-Host "TPM Present: ${TPMPRESENT}, TPM Enabled: ${TPMENABLED}, TPM Ready ${TPMREADY}, TPM Version: ${tpmVersionOut}"
New-ItemProperty "HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" -Name "SystemDefaultTlsVersions" -Value 1 -PropertyType "DWord"
New-ItemProperty "HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" -Name "SystemDefaultTlsVersions" -Value 1 -PropertyType "DWord"
New-ItemProperty "HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319" -Name "SystemDefaultTlsVersions" -Value 1 -PropertyType "DWord"
New-ItemProperty "HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319" -Name "SystemDefaultTlsVersions" -Value 1 -PropertyType "DWord"