Skip to content

Instantly share code, notes, and snippets.

Avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / isLocked.ps1
Created Aug 2, 2020
Check if domain user is locked out
View isLocked.ps1
[bool]$isLocked = (Get-ADUser 'username' -Properties LockedOut).LockedOut
if ($isLocked -eq $True) {
Write-Host "Account is locked"
} else {
Write-Host "Account is not locked"
}
@jcefoli
jcefoli / github-auth.ps1
Created Aug 2, 2020
Authenticate with token to Download File from Raw Githubusercontent
View github-auth.ps1
$headers = @{'Accept' = 'application/json'}
$tokenString = "REPLACE-GITHUB-TOKEN-HERE" + ":x-oauth-basic"
$base64Auth = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(($tokenString)))
$headers.Add('Authorization',"Basic $base64Auth")
$content = Invoke-RestMethod -Uri "https://raw.githubusercontent.com/ORG/Repo/master/something.ps1" -Headers $headers
@jcefoli
jcefoli / pause-locally.ps1
Created Feb 4, 2020
Pause Script When Run Locally But not Remotely
View pause-locally.ps1
#Add to end of script
if ($PSSenderInfo) {
#Script was launched remotely. Do Not Pause
}
else {
#Script is running locally, pause
[void](Read-Host 'Press Enter to continue')
}
@jcefoli
jcefoli / zoom_mute_global_hotkey.ahk
Last active Nov 4, 2019
[AutoHotKey] Set Ctrl-M Global Hotkey to Mute/Unmute Zoom Calls
View zoom_mute_global_hotkey.ahk
^m::
IfWinExist, ahk_class ZPContentViewWndClass
WinActivate
Send, !a
Exit
IfWinExist, ahk_class ZPFloatVideoWndClass
WinActivate
Send, !a
@jcefoli
jcefoli / fizzbuzz.ps1
Created Oct 24, 2019
[Powershell Interview Question] The FizzBuzz Problem: Write a program that prints the numbers 1 to 100. For multiples of 3, print "Fizz". For multiples of 5, print "Buzz". FOr multiples of both 3 and 5, print "FizzBuzz".
View fizzbuzz.ps1
for ($x = 1; $x -le 100; $x++) {
$Output = ""
if ($x % 3 -eq 0) { $Output += "Fizz" }
if ($x % 5 -eq 0) { $Output += "Buzz" }
if ($Output -eq "") { $Output = $x }
Write-Output $Output
}
@jcefoli
jcefoli / isLocked.ps1
Created Oct 15, 2019
Conditionally Check for AD Locked Out User Account
View isLocked.ps1
[bool]$isLocked = (Get-ADUser 'username' -Properties LockedOut).LockedOut
if ($isLocked -eq $True) {
Write-Host "Account is locked"
} else {
Write-Host "Account is not locked"
}
@jcefoli
jcefoli / sendmail.ps1
Created Oct 14, 2019
Send Email in Powershell via .NET Net.Mail.SmtpClient & Net.Mail.MailMessage
View sendmail.ps1
$message = new-object Net.Mail.MailMessage;
$message.From = "YourName@gmail.com";
$message.To.Add('dev07-promotional@booker.local');
$message.Subject = "Test by Joe";
$message.Body = "Message body here";
$smtp = new-object Net.Mail.SmtpClient("smtp.server.local", "25");
$smtp.send($message);
@jcefoli
jcefoli / kickjenkins.ps1
Created Sep 24, 2019
Kick Jenkins Job With CSRF Protection Enabled [Powershell REST Request]
View kickjenkins.ps1
# Force TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# Basic Auth Credentials
$user = 'changeme'
$pass = 'insecure-password'
# Handle Basic Auth (Hacky in Powershell)
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
View keybase.md

Keybase proof

I hereby claim:

  • I am jcefoli on github.
  • I am jcefoli (https://keybase.io/jcefoli) on keybase.
  • I have a public key whose fingerprint is 1EEF B0D8 3F20 F83B 086B 888C CE34 4425 E18C 50B4

To claim this, I am signing this object:

@jcefoli
jcefoli / Disable-AeroShake.ps1
Created Sep 3, 2019
Disable Aero Shake (Idiotic Windows feature that minimizes all windows if you shake one window with the mouse. I do this when I'm thinking sometimes inadvertently and it annoys the hell out of me)
View Disable-AeroShake.ps1
#Run as Admin
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisallowShaking" -Value "0" -PropertyType "DWord"
You can’t perform that action at this time.