Skip to content

Instantly share code, notes, and snippets.

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 @{
@Snozzberries
Snozzberries / 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
@Snozzberries
Snozzberries / 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
@Snozzberries
Snozzberries / 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
}
}
@Snozzberries
Snozzberries / 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)
@Snozzberries
Snozzberries / gist:747416677c4e50b80e6d4c376e7f6db1
Created October 24, 2022 14:32
Concurrent Test-NetConnection Port Scan
$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 @{
gci Cert:\LocalMachine\My\ | Select Thumbprint, Subject, @{N="Template";E={($_.Extensions|?{$_.Oid.FriendlyName -eq "Certificate Template Information"}).Format(0)}}|?{$_.Template -like "*RDP NLA*"}|%{& certutil -delstore my $_.Thumbprint}