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 / PS-BGInfo.ps1
Created September 26, 2019 13:51 — forked from dieseltravis/PS-BGInfo.ps1
update wallpaper background image with powershell (like Sysinternals BGInfo)
# PS-BGInfo
# Powershell script that updates the background image with a random image from a folder and writes out system info text to it.
# run as a lower priority task
[System.Threading.Thread]::CurrentThread.Priority = 'BelowNormal'
# Configuration:
# Font Family name
$font="Input"
@mardahl
mardahl / ps_map_drives.ps1
Created April 5, 2019 10:10
Network drive mapping via Intune
<#
.SYNOPSIS
This script will map network drives to a specified fileserver (ment to be used as an Intune PowerShell script)
.DESCRIPTION
The script will test the connection to the domain (via FQDN), in case it fails, there is an option to make it retry again one minute later.
If all fails, it will skip the mapping of the drives.
.EXAMPLE
Just run this script without any parameters in the logged in users context (as an Intune Extensions Powershell script).
.NOTES
NAME: ps_map_drives.ps1
@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 / 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 / Outlk16.admx
Created October 28, 2018 21:02
Outlook 2016 ADMX Group Policy
<?xml version="1.0" encoding="utf-16"?>
<policyDefinitions revision="1.0" schemaVersion="1.0">
<policyNamespaces>
<target prefix="outlk16" namespace="outlk16.Office.Microsoft.Policies.Windows" />
<using prefix="windows" namespace="Microsoft.Policies.Windows" />
</policyNamespaces>
<supersededAdm fileName="outlk16" />
<resources minRequiredRevision="1.0" />
<categories>
<category name="L_MicrosoftOfficeOutlook" displayName="$(string.L_MicrosoftOfficeOutlook)" />
@mardahl
mardahl / restrict_Office365Groups_creation.ps1
Last active May 27, 2020 19:00
Script to restrict creation of Office365 Groups
<#
.DESCRIPTION
Quick and dirty script to limit the creation of Office 365 Group or Microsoft Teams (Teams) to a specific security group in Azure AD (or One Synced form on-prem AD)
#>
#security group that is allowed to create Office 365 Groups
$secGroup = "Teams Creation Administrators"
#importing AzureAD Module (should be installed!)
try {
Import-module AzureADPreview
@mardahl
mardahl / anon-redelegateDK
Created September 11, 2018 06:25
Script to send redelegation requests for multiple .dk domains to dkhostmaster - saving time typing them in manually.
$DomainNames = @(
'domA.dk',
'domB.dk'
)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Foreach ($Domain IN $DomainNames) {
#Simple script to change all Unified Groups (Office 365 Groups) Primaty SMTP email address to a new domain.
#It's recomended to have a diferent email domain for Office 365 Groups, so they dont conflict with regular user and system mailboxes.
$groups = get-unifiedgroup | select-object name,alias
Foreach ($group in $groups) {
Set-UnifiedGroup –Identity "$($group.name)" –PrimarySmtpAddress "$($group.alias)@groups.contoso.com"
}
@mardahl
mardahl / SudoFunction.ps1
Created August 5, 2018 23:55
Example of a SUDO function for powershell
function sudo
{
$file, [string]$arguments = $args;
$psi = new-object System.Diagnostics.ProcessStartInfo $file;
$psi.Arguments = $arguments;
$psi.Verb = "runas";
$psi.WorkingDirectory = get-location;
[System.Diagnostics.Process]::Start($psi);
}
@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