Skip to content

Instantly share code, notes, and snippets.

View mardahl's full-sized avatar
🤓
not afraid to commit!

Michael Mardahl mardahl

🤓
not afraid to commit!
View GitHub Profile
@mardahl
mardahl / invoke-BulkAddCloudFlareZones.ps1
Last active April 10, 2024 14:19
CloudFlare powershell to bulk add new DNS Zones
#region declarations
$apikey = 'axxxxxxxxxxxxxxxxx6a4f5bxxxxxxxxxxxxx'
$email = 'xxxxxxxxx@xxxxxxxxx.xxx'
$accountid = 'b6xxxxxxxxxxxxxxxxx8e57xxxx'
$domains = $(Get-Content .\domains.txt) #text file with 1 domain per line
#endregion declarations
#region execute
foreach ($domain in $domains){
$headers = @{
@mardahl
mardahl / Set Room Mailbox Calendar permissions and Processing defaults
Created February 21, 2019 13:41
Set Office 365 Room Mailbox Calendar permissions and processing defaults, so subject and meeting organizer is visible.
#Connect to Office 365 Exchange (wont work if MFA is required.
#Use conditional access or whitelisting to allow the connection without MFA
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange-ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
#Get list fo All Room type mailboxes
$rooms = Get-MailBox | where {$_.ResourceType -eq "Room"}
@mardahl
mardahl / updateSfBGAL.ps1
Last active January 2, 2023 17:03
Script to force update Skype for Business Clients Global Address List
<#
.SYNOPSIS
Script to force update Skype for Business Clients Global Address List Written by Michael Mardahl (iphase.dk)
(Provided AS-IS! I will not be held liable for any negative consequences)
.DESCRIPTION
This script will shutdown the SfB client, update the registry and delete the GAL DB, then start the client again. It should be run in the users context as it does user specific things.
.EXAMPLE
Just run the script without parameters
@mardahl
mardahl / retry-intune-enrollment.ps1
Last active August 5, 2022 17:07
Intune Enrollment problem solver script thingy
# Clean out MDM registration info from machine, in attempt to fix Intune enrollment problems with Windows 10
# after a user reboots, the enrollment process should kick off again.
# This special edition, also disables workplace join, as an attempt to mitigate issues with devices previously AAD Registered.
# This script has fixed Error codes 0x80180023 and 0x8018002b at some of my customers sites, even without reboot in some cases.
# By Michael Mardahl @ Apento.com - @michael_mardahl
# Should be run as system user
#Disable workplace join if that is happening beyond your control.
#Get-ScheduledTask -TaskName "Automatic-Device-Join" | Disable-ScheduledTask
@mardahl
mardahl / invoke-GenerateRandomBitlockerKeys.ps1
Created March 14, 2022 09:07
Generate random bitlocker recovery keys
#Generates 100 random bitlocker recovery key ID and keys
#By Michael Mardahl github.com/mardahl
#Use it for whatever...
$hash = @{}
for($i = 0;$i -lt 100;$i++) {
$id = "$(Get-Random -minimum 100 -maximum 999)$((97..102) | Get-Random -Count 1 | % {[char]$_})$(Get-Random -minimum 100 -maximum 999)$((97..102) | Get-Random -Count 1 | % {[char]$_})-$(Get-Random -minimum 100 -maximum 999)$((97..102) | Get-Random -Count 1 | % {[char]$_})-$(Get-Random -minimum 100 -maximum 999)$((97..102) | Get-Random -Count 1 | % {[char]$_})-$(Get-Random -minimum 100 -maximum 999)$((97..102) | Get-Random -Count 1 | % {[char]$_})-$(Get-Random -minimum 100 -maximum 999)$((97..102) | Get-Random -Count 1 | % {[char]$_})$(Get-Random -minimum 100 -maximum 999)$((97..102) | Get-Random -Count 1 | % {[char]$_})$((97..102) | Get-Random -Count 1 | % {[char]$_})$(Get-Random -minimum 10 -maximum 99)$((97..102) | Get-Random -Count 1 | % {[char]$_})"
$key = "$(Get-Random -minimum 100000 -maximum 999999)-$(Get-Random -minimum 100000 -maximu
@echo off
REM Description: Small helper script to quickly start an AADSync but just double clicking on this script file.
REM Author: Michael Mardahl - github.com/mardahl
echo Starting AD Sync (Delta)...
powershell.exe -ex bypass -command "ipmo adsync;Start-ADSyncSyncCycle delta;"
echo Finished script execution.
pause
@mardahl
mardahl / invoke-BulkDeleteCloudFlareZones.ps1
Last active October 7, 2021 11:46
CloudFlare PowerShell to bulk delete DNS Zones
#license MIT
#Author Michael Mardahl github.com/mardahl
#region declarations
$env:CF_API_KEY = 'axxxxxxxxxxxxxxxxxxxx'
$env:CF_API_EMAIL= 'xxxxxxx@xxxxxx.xxx'
$domains = $(Get-Content .\domains.txt) #text file with 1 domain per line
#endregion declarations
#region execute
@mardahl
mardahl / export-OutlookProfilesListToCSV.ps1
Created December 18, 2020 16:23
Script to export a list of all Outlook profiles attached to a user in Windows - can be run as login script
#Define central storage for the log files to be collected.
#Make sure all users that run this script have write permissions on this share
$logFile = "\\fileserver.domain.local\share\$($env:USERNAME)_OutlookAccounts.csv"
#Testing for Outlook 2013 and newer
If (Test-Path 'hkcu:\Software\Microsoft\Office\15.0\Outlook\Profiles') {
$regPath = 'hkcu:\Software\Microsoft\Office\15.0\Outlook\Profiles\*\9375CFF0413111d3B88A00104B2A6676\*'
}elseif(Test-Path 'hkcu:\Software\Microsoft\Office\16.0\Outlook\Profiles'){
@mardahl
mardahl / Invoke-O365DKIMEnable.ps1
Last active December 2, 2020 16:40
Enable 2048-bit DKIM in Office 365 script
try{
Connect-ExchangeOnline -ErrorAction Stop
} catch {
Throw "Failed to logon to Exchange Online"
}
$dkim = Get-DkimSigningConfig
foreach($obj in $dkim){
Write-Host "Enabling 2048-bit DKIM for $($obj.Domain)" -ForegroundColor Green
@mardahl
mardahl / Get-O365DKIMDNS.ps1
Created December 2, 2020 11:37
Office 365 DKIM DNS records
#requires -RunAsAdministrator
Set-ExecutionPolicy Bypass -Confirm:$false -Force
Install-Module ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement
try{
Connect-ExchangeOnline -ErrorAction Stop
} catch {
Throw "Failed to logon to Exchange Online"
}