Skip to content

Instantly share code, notes, and snippets.

function Update-MtLicenseCache {
[OutputType([System.Void])]
[CmdletBinding(
SupportsShouldProcess,
ConfirmImpact = "Low"
)]
param (
[Switch]$Force,
[String]$FileName="maesterLicenses.csv"
GraphActivity
| take 1000
| extend properties.timeGenerated, properties.appId, properties.roles, properties.scopes
| extend properties.requestUri, properties.requestMethod, properties.responseStatusCode
//
// Use to filter by App ID
//| where tostring(properties_appId) == "<AppId>"
//
// Use to summarize by app reg permissions used
//| where isnotempty(properties_roles)
function Connect-EntraIga {
[CmdletBinding()]
param (
[Parameter(ParameterSetName="All",Mandatory)]
[switch]$All,
[Parameter(ParameterSetName="Graph",Mandatory)]
[switch]$Graph,
[Parameter(ParameterSetName="All")]
[Parameter(ParameterSetName="Graph")]

Example SSH Server Initialization

The SSH server configuration requires GSSAPIAuthentication yes.

Ref: https://snozzberries.github.io/2023/08/29/powershell-ssh.html

$r=[System.Net.WebRequest]::Create("https://github.com/PowerShell/PowerShell/releases/latest")
$r.AllowAutoRedirect=$false
$r.Method="Head"
$remoteDomain=@(
"10.0.0.10",
"10.0.0.20",
"domain.local"
)
function New-Task([int]$index,[string]$target,[int]$port,[scriptblock]$ScriptBlock)
{
$ps = [Management.Automation.PowerShell]::Create()
$res = New-Object PSObject -Property @{
@soulemike
soulemike / gist:408bec0813561635fb54f156b99df794
Created May 11, 2023 21:01
Convert inline HEX characters to ASCII
$s='wind\x6f\x77["\x64oc\x75\x6den\x74"\x5d\x2ec\x72\x65a\x74\x65E\x6cemen\x74'
($s|Select-String -Pattern "([.\\][.x].{2})" -AllMatches).Matches.Value|select -Unique|%{$s=$s.Replace([string]$_,[char]([convert]::ToInt16($_.Substring(2,2),16)))}
#window["document"].createElement
@soulemike
soulemike / cleanContainers.sh
Created April 19, 2023 02:17
Clean stopped containers
#Clean up stopped containers
sudo docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm
@soulemike
soulemike / Update-StorageAccountDefaultPermissions.ps1
Created April 9, 2023 23:13
Set all Azure Files for default permissions
#https://learn.microsoft.com/en-us/azure/storage/files/storage-files-identity-ad-ds-assign-permissions?tabs=azure-powershell#share-level-permissions-for-all-authenticated-identities
Get-AzStorageAccount|%{
$x=$_;
$_.AzureFilesIdentityBasedAuth|?{$_.DefaultSharePermission -eq $null}|%{
Set-AzStorageAccount -DefaultSharePermission "StorageFileDataSmbShareContributor" -ResourceGroupName $x.ResourceGroupName -AccountName $x.StorageAccountName
}
}
@soulemike
soulemike / gist:a2d52b6224b5cf144cedfb880b334408
Last active February 12, 2023 03:08
Add entries to Internet Zones
# Add *.local.ad and 10.*.*.* to Intranet Zones
# Zones Enum https://learn.microsoft.com/en-us/troubleshoot/developer/browsers/security-privacy/ie-security-zones-registry-entries#zones
New-Item -Force -Path 'HKLM:\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains'
New-Item -Force -Path 'HKLM:\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\local.ad'
Set-ItemProperty -Force -Type DWord -Path 'HKLM:\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\local.ad' -Name * -Value 00000001
New-Item -Force -Path 'HKLM:\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges'
New-Item -Force -Path 'HKLM:\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1'
Set-ItemProperty -Force -Type DWord -Path 'HKLM:\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1' -Name * -Value 00000001
Set-ItemProperty -Force -Path 'HKLM:\D
Import-Module ActiveDirectory
Import-Module DnsServer
Import-Module PKI
Import-Module Microsoft.WSMan.Management
#######################
### Once Per Domain ###
#######################
#Generate a new self-signed wildcard certificate for the domain
$cert = New-SelfSignedCertificate -DnsName "*.$($env:USERDNSDOMAIN)","localhost" -CertStoreLocation Cert:\LocalMachine\My\ -NotAfter (Get-Date).AddYears(5)