Skip to content

Instantly share code, notes, and snippets.

View seanosullivanuk's full-sized avatar
I make stuff (up)

Sean O'Sullivan seanosullivanuk

I make stuff (up)
View GitHub Profile
@seanosullivanuk
seanosullivanuk / AZObjectID.ps1
Last active December 1, 2020 13:32
Get the Azure AD ObjectID of a specific UPN
Connect-AzureAD
Get-AzureADUser -ObjectId "example.user@contoso.com"
@seanosullivanuk
seanosullivanuk / DisableEXCHIMAPPop.ps1
Created December 3, 2020 11:48
Exchange Online - Disable IMAP and POP for current and future mailboxes
#Turn off IMAP and POP for future mailboxes
Get-CASMailboxPlan -Filter {ImapEnabled -eq "true" -or PopEnabled -eq "true" } | set-CASMailboxPlan -PopEnabled $false
#Turn it off on all existing mailboxes
Get-CASMailbox -Filter {ImapEnabled -eq "true" -or PopEnabled -eq "true" } | Select-Object @{n = "Identity"; e = {$_.primarysmtpaddress}} | Set-CASMailbox -ImapEnabled $false -PopEnabled $false
@seanosullivanuk
seanosullivanuk / ShareandNTFS.ps1
Created December 12, 2020 15:30
Create a folder, add a hidden share, set NTFS permissions and disable inheritance
#Install-Module -Name NTFSSecurity
$user = "test.user"
$domain = "contoso"
# Create the folder and share it
New-Item -Path D:\Employees\$user -ItemType directory
New-SmbShare -Name "$user$" -Path "D:\Employees\$user" -ChangeAccess "$domain\$user"
# Set file permissions (change to taste)
@seanosullivanuk
seanosullivanuk / rdusersessions.ps1
Created May 10, 2021 11:58
Export CSV of existing RDS User Sessions
Get-RDUserSession -ConnectionBroker "server.fqdn.example.com" | Export-Csv -Path c:\temp\connections.csv -NoTypeInformation
@seanosullivanuk
seanosullivanuk / log4jscanner-batchscript.bat
Created December 21, 2021 09:11
Qualys Log4JScanner, PDQ Deploy script
:: This is a script I've set up in PDQ Deploy. Be sure to run this as administrator.
:: Also, not my best work... but it does work.
:: Replace servername and hiddenshare$ with your own UNC path info
set host=%COMPUTERNAME%
copy "\\servername\hiddenshare$\Log4JResults\Log4jScanner.exe" "%userprofile%\AppData\Roaming\Log4jScanner.exe"
"%userprofile%\AppData\Roaming\Log4jScanner.exe" > "\\servername\hiddenshare$\Log4JResults\Results\%host%.txt"
del "%userprofile%\AppData\Roaming\Log4jScanner.exe"