Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Andreas Dieckmann diecknet

👋
View GitHub Profile
View CheckProfileStoragePermissions.ps1
<#
.SYNOPSIS
I used this to find inconsistent file/folder ACL for FSLogix Profile Container folders in Azure Files (Azure Storage). It's not perfect but did a good enough job. This script is highly specific for my use-case. Feel free to change it for your needs.
.DESCRIPTION
This script scans the specified folder for subfolders. It checks if the Owner of the subfolder has exactly "Modify, Synchronize" rights for the folder. It then checks if the subfolder-owner also has these rights for files inside that subfolder. If there is more than one (1) file in the subfolder, it throws a warning but continues.
.NOTES
@diecknet
diecknet / Apply-DNS-Workaround-CVE-2020-1350.ps1
Created July 15, 2020 10:34
Apply CVE-2020-1350 (SIG-RED) Workaround for Windows DC/DNS with PowerShell
View Apply-DNS-Workaround-CVE-2020-1350.ps1
<# by diecknet
# This script is mostly based on code by reddit users /u/bernys and /u/Lanathell
# I added checks to see if DNS service is running again.
# Also see:
# - https://support.microsoft.com/en-us/help/4569509/windows-dns-server-remote-code-execution-vulnerability
# - https://www.reddit.com/r/sysadmin/comments/hr5dfe/keep_your_eyes_out_for_a_critical/
#>
Import-Module ActiveDirectory
$AllDomainControllers = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }
@diecknet
diecknet / Copy2Clipboard.ps1
Created July 6, 2021 06:41
Copy last PowerShell command into clipboard
View Copy2Clipboard.ps1
<#
I initially used this code:
history | Select-Object -Last 1 -ExpandProperty CommandLine | clip
But recently found this shorter version at https://powershellmagazine.com/post/2012-11-06-pstip-send-the-last-command-executed-to-clipboard/
#>
(Get-History)[-1].commandline | clip
@diecknet
diecknet / ActiveDirectory-Snippets.ps1
Created July 6, 2021 14:12
Windows Server Active Directory - Snippets
View ActiveDirectory-Snippets.ps1
########################################################################################
# Add DNS Host A entry with PowerShell
# Forward / Host A
Add-DnsServerResourceRecordA -Name "test123" -ZoneName "myzone.local" -IPv4Address "10.0.0.1" -ComputerName mydnsserver
# Add PTR:
Add-DnsServerResourceRecordPtr -ZoneName 00.10.in-addr.arpa -Name 1.0 -PtrDomainName myhost.myzone.local -ComputerName mydnsserver
########################################################################################
@diecknet
diecknet / Convert-SPOTimezoneToString.ps1
Created July 9, 2021 15:46
Sharepoint Online Timezone of a Site
View Convert-SPOTimezoneToString.ps1
function Convert-SPOTimezoneToString(
# ID of a SPO Timezone
[int]$ID
) {
<#
.SYNOPSIS
Convert a Sharepoint Online Time zone ID to a human readable string.
.NOTES
By Andreas Dieckmann - https://diecknet.de
@diecknet
diecknet / Hashtable-Access-Performance-Test.ps1
Created October 27, 2022 12:40
PowerShell Hashtable Performance Tests
View Hashtable-Access-Performance-Test.ps1
<#
Hashtable Access Performance Test
Settings:
$maxentries = Number of entries to put into the hashtable
$iterations = Number of access test per method
#>
$maxentries = 100000
$iterations = 5000
$meineHashtable = @{}