Skip to content

Instantly share code, notes, and snippets.

View McAndersDK's full-sized avatar

Anders Andersson McAndersDK

View GitHub Profile
@McAndersDK
McAndersDK / WeirdBehavior.ps1
Created April 8, 2022 20:58
Variable Weird Behavior
function GenerateRainbowTable {
param(
[int]$size,
[char[]]$Charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
foreach($char in $Charset) {
if($size -eq 1) {
$char
} else {
@McAndersDK
McAndersDK / UD-ClaimDebug
Created January 13, 2020 10:42
Universal Dashboard Claim debug page
new-udpage -Url '/ClaimDebug' -Icon cogs -Id 'ClaimDebugPage' -Title 'Claim Debug' -Endpoint {
new-udcard -Title 'Authorization Policy' -Content {
New-UDElement -Tag ul -Attributes @{className="collection"} -Content {
Get-UDAuthorizationPolicy | ForEach-Object { New-UDElement -Attributes @{className="collection-item"} -Content {$_} -Tag 'li'}
}
}
New-UDCard -Title 'Claims' -Endpoint {
New-UDTable -Content {
New-UDPage -Id 'TestCookie' -Url "/TestCookie" -Endpoint {
$CookieOptions = New-Object -TypeName Microsoft.AspNetCore.Http.CookieOptions
$CookieOptions.Expires = (Get-Date).AddYears(1)
$CookieOptions.MaxAge = New-TimeSpan -days 365
$cookieCriticalPopup = (Get-UDCookie -Name CriticalPopup).value
Show-UDToast -Message "page Load session:CriticalPopup is $session:CriticalPopup" -Duration 5000
if ("$cookieCriticalPopup" -eq "") {
Show-UDToast -Message "cookieCriticalPopup is NULL" -Duration 5000
set-UDCookie -Name CriticalPopup -Value $true -CookieOptions $CookieOptions
$Cache:groupNames = Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -SearchBase 'OU=OU1,OU=Groups,DC=domain,DC=domain,DC=local' -SearchScope OneLevel | Select-Object -ExpandProperty name
Add-Type -TypeDefinition @"
// very simple enum type
public enum Departments
{
`n $(foreach ($Group in ($Cache:groupNames)){"`t$($Group.replace(" ","_"))`,"}
) `n
}
"@
<#
.SYNOPSIS
Get-Exchange2016AVExclusions.ps1 - Generate list of exclusions for antivirus software.
.DESCRIPTION
This PowerShell script generates a list of file, folder, process file extension exclusions
for configuring antivirus software that will be running on an Exchange 2016 server. The
correct exclusions are recommended to prevent antivirus software from interfering with
the operation of Exchange.
@McAndersDK
McAndersDK / NetBlock.ps1
Created February 15, 2016 10:41
.net Framework Update Blocking
function Get-NETBlock {
<#
.SYNOPSIS
Get-NETBlock checks if the computer is blocked from receiving the .net framework update via windows update.
.DESCRIPTION
Get-NETBlock uses remote registry to query the value discribed in https://support.microsoft.com/en-us/kb/3133990
.PARAMETER ComputerName
The Computer name to query. Default: Localhost.