Skip to content

Instantly share code, notes, and snippets.

@soulemike
soulemike / Microsoft.ManagedService.bicep
Created April 28, 2021 21:46
Utilize the ManagedServices resource provider to perform an offer registration for an Azure Marketplace Offer (aka Lighthouse)
targetScope = 'subscription'
param name string = guid(utcNow())
@description('Long Name of your Partner Center Offering')
param definitionName string
param definitionDescription string = ''
@description('The Service Provider\'s Azure AD Tenant GUID')
param managedByTenantId string
@description('The AdminAgents, or other, Azure AD Group GUID')
param adminAgents string
param authorizations array = [
function installer
{
Try
{
$logs=Get-EventLog -List
$source="SMB Monitoring"
if(-not ($logs.Log -contains "Sentinel"))
{
New-EventLog -LogName Sentinel -Source $source
Limit-EventLog -LogName "Sentinel" -OverflowAction OverwriteAsNeeded -MaximumSize 20MB
SELECT
s.session_id,
c.connect_time,
s.login_time,
s.login_name,
c.protocol_type,
c.auth_scheme,
s.HOST_NAME,
s.program_name
FROM sys.dm_exec_sessions s
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}
@soulemike
soulemike / 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 @{
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)
@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
@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 / 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 / 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