Skip to content

Instantly share code, notes, and snippets.

View realslacker's full-sized avatar

Shannon Graybrook realslacker

View GitHub Profile
@realslacker
realslacker / Get-ServerCertificate.ps1
Last active March 4, 2024 18:39
Return the server certificate a server is using on a specified port
<#
.SYNOPSIS
Return the server certificate a server is using on a specified port
.PARAMETER ComputerName
The remote computer to query
.PARAMETER Port
The remote TCP port to query
.PARAMETER SubjectNameIdentifier
The Subject Name Identifier to send to the server, defaults to the computer name
.PARAMETER SkipCertificateCheck
@realslacker
realslacker / authentication.ps1
Created March 1, 2024 09:39
PowerShell Universal Authentication Example Supporting Multiple Domains
Set-PSUAuthenticationMethod -Type "Form" -ScriptBlock {
param(
[PSCredential]$Credential
)
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
# is this a UPN?
if ( $Credential.UserName.IndexOf('@') -gt -1 ) {
@realslacker
realslacker / JavaUninstall.cmd
Created January 31, 2024 21:29
Java Seek and Destroy - Remove Oracle JRE 6-8
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
GOTO :RUN
:UNINSTALL
ECHO -------------------------------------------------------
ECHO UNISTALL 32-Bit java matching "%~1"
ECHO -------------------------------------------------------
@realslacker
realslacker / ScreenConnectReInstall.cmd
Last active January 31, 2024 21:24
ScreenConnect Re-Install BATCH File
@ECHO OFF
REM If you ever need to re-install ScreenConnect on a client machine using
REM automation like Tanium or Automate and PowerShell is BROKEN on the
REM machine... never fear, this script will help you get it done.
REM
REM Note that this script expects to be able to be packaged with wget see:
REM https://eternallybored.org/misc/wget/
REM If wget is not present it will fallback to bitsadmin, however on Windows 7
REM bitsadmin is missing the /dynamic switch and downloads will fail.
@realslacker
realslacker / Convert-VMwareGuestUUIDtoMDTUUID.ps1
Created March 27, 2023 20:33
Convert VMware Guest UUID to MDT UUID
param($VM)
# VMware Guest UUIDs are big edian, MDT expects middle edian
# here we reverse the byte order of the first three sections of the guid and then cast back to a guid
[guid][byte[]]([guid]$VM.ExtensionData.Config.Uuid).ToByteArray()[3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15,16,17]
@realslacker
realslacker / Reset-ADUserAdminCount.ps1
Created May 19, 2022 17:03
Reset a user account adminCount and restore the default ACL.
#requires -Modules ActiveDirectory
[CmdletBinding(
SupportsShouldProcess=$true,
ConfirmImpact='High'
)]
param(
[Parameter(
Mandatory=$true,
@realslacker
realslacker / Regular Expressions.ps1
Created December 10, 2021 20:37
Useful Regular Expressions
# Relative OU Path
$RelativeOU = '^(?:(?:CN|OU)=(?:(?<=\\),|[^,])+(?:,(?=(?:CN|OU)=(?:(?<=\\),|[^,])+)|$))+$'
# Full OU
$OU = '^(?:(?:CN|OU)=(?:(?<=\\),|[^,])+,)+(?:DC=(?:(?<=\\),|[^,])+(?:,(?=DC=(?:(?<=\\),|[^,])+)|$))+$'
[CmdletBinding()]
param(
[Parameter( Mandatory, Position = 1, ValueFromPipelineByPropertyName, ValueFromPipeline )]
[Alias( 'HostName', 'Server' )]
[string[]]
$ComputerName,
[System.DirectoryServices.ActiveDirectory.SyncFromAllServersOptions]
$SyncOptions = @( 'CrossSite', 'PushChangeOutward', 'SkipInitialCheck' ),
<#
.SYNOPSIS
Update your desktop wallpaper from Windows Spotlight using PowerShell
.NOTES
Author: Shannon Graybrook
Github: github.com/realslacker
#>
#requires -version 5.1
@realslacker
realslacker / Add-WindowsCapability.ps1
Last active October 30, 2019 14:50
Module with Add-WindowsCapability proxy function to which allows bypassing WSUS for Add-WindowsCapability.
# iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/realslacker/fc8784324eea99e7aea48e54d8847704/raw'))
#Requires -Modules DISM
function Add-WindowsCapability {
[CmdletBinding()]
param(
[Parameter(ParameterSetName='Online', ValueFromPipelineByPropertyName=$true)]
[Parameter(ParameterSetName='Offline', ValueFromPipelineByPropertyName=$true)]
[ValidateNotNullOrEmpty()]