Skip to content

Instantly share code, notes, and snippets.

@joegasper
joegasper / Get-ShadowBox.ps1
Last active February 10, 2020 20:59
Remote Desktop Session Shadowing Mode in Windows 10
#Inspired by http://woshub.com/rdp-session-shadow-to-windows-10-user/
#You could feed ConvertFrom-String a template to have a perfect object from the qwinsta.exe command, but I didn't want to
#have to keep the template file around.
#This is quicker than walking someone through Quick Assist, but QA will work over the internet.
#This command will shadow a user's Windows 10 system and you will have control (after remote user's consent if you are proper - see GPO in the link).
$PC=(Read-Host -Prompt "PC Name");$ID = (qwinsta.exe /server:$PC | ConvertFrom-String | Where-Object P2 -eq console | select P4).P4;mstsc.exe /shadow:$ID /v:$PC /control
@joegasper
joegasper / Get-LoremName.ps1
Last active September 2, 2021 04:02
Generate random names and accounts based on Lorem Ipsum
<#
.Synopsis
Return a name based on Lorem Ipsum.
.DESCRIPTION
Calls public Loren Ipsum API and returns name and account name if requested.
.EXAMPLE
Get-LoremName
FirstName LastName
--------- --------
Plane Gloriosam
@joegasper
joegasper / Set-DnsClient2CloudFlareDnsService
Created April 2, 2018 01:03
Set Windows client to use CloudFlare DNS Service 1.1.1.1
#See: https://1.1.1.1/ and https://www.cnet.com/news/cloudfare-new-1111-dns-privacy-tool-would-speed-your-internet-too/
#Run in elevated PowerShell command shell
#Store current DNS servers
Get-NetAdapter -Physical | Where-Object {$_.Status -eq 'Up'} | Get-DnsClientServerAddress | Select ServerAddresses -expand ServerAddresses | Set-Content -Path $env:USERPROFILE\OriginalDNSservers.txt
$Display current DNS servers
Get-NetAdapter -Physical | Where-Object {$_.Status -eq 'Up'} | Get-DnsClientServerAddress
#Specifiy CloudFlare 1.1.1.1 service IP addresses (IPv4/IPv6)
$DNSservers = ('1.1.1.1','1.0.0.1','2606:4700:4700::1111','2606:4700:4700::1001')
#Set client DNS servers to CloudFlare DNS servers
Get-NetAdapter -Physical | Where-Object {$_.Status -eq 'Up'} | Set-DnsClientServerAddress -ServerAddresses $DNSservers
@joegasper
joegasper / Robocopy-WithPS.ps1
Created December 1, 2017 20:24
Run Robocopy with PowerShell
$site = 'mysite01'
$source = "\\my-web1\e$\websites\$site\"
$destination = "E:\websites\$site\"
#List only first
$logfile = "E:\$site-robo-test.txt"
$switches = "/E /L /R:2 /W:3 /NP /FFT /DST /LOG:$logfile /XF "".DS_Store"" ""thumbs.db"""
& robocopy.exe $source $destination $switches.Split(' ')
#Check Log File
Get-Content -Path $logfile -First 17
@joegasper
joegasper / Get-PingSweep.ps1
Last active May 27, 2024 15:52
Get-PingSweep - super fast (~500ms) subnet ping sweep with option to resolve IP address
# Inspiration from https://twitter.com/mrhvid/status/929717169130176512 @mrhvid @Lee_Holmes
function ResolveIp($IpAddress) {
try {
(Resolve-DnsName $IpAddress -QuickTimeout -ErrorAction SilentlyContinue).NameHost
} catch {
$null
}
}
@joegasper
joegasper / proofpoint-decoder.html
Last active March 23, 2020 19:37
ProofPoint URL Defense (TAP) Decoder
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ProofPoint URLdefense Decoder</title>
<style type="text/css">
#decoded
{
width:515px;
height:400px;
@joegasper
joegasper / ConvertFrom-DN
Last active June 5, 2024 02:37
Convert between DistinguishedName and CanonicalName
#Updated ConvertFrom-DN to support container objects
function ConvertFrom-DN {
[cmdletbinding()]
param(
[Parameter(Mandatory, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
[ValidateNotNullOrEmpty()]
[string[]]$DistinguishedName
)
process {
@joegasper
joegasper / Get-WordPressVersion.ps1
Created April 28, 2017 14:32
Get WordPress Version
#Simple check on a generic WordPress site
$page = Invoke-WebRequest -Uri http://mywordpress03.site
$WPver = ($page.Scripts.src).where({$_ -match 'wp-embed.min'}).Split('=')[1]
@joegasper
joegasper / Fibonacci-Sequence
Last active February 26, 2017 20:19
Calculating Fibonacci Sequence to n values or calculating a specific nth value
#Show all values in sequence up to number $seqnum
[int]$seqnum = 10
$fibseq = @()
for($i = 0; $i -lt $seqnum; $i++) {
if ($i -eq 0 ) {
$fibseq = $fibseq + 0
}
if ($i -eq 1 ) {
$fibseq = $fibseq + $i
}

Keybase proof

I hereby claim:

  • I am joegasper on github.
  • I am joegasper (https://keybase.io/joegasper) on keybase.
  • I have a public key ASDCmG_QehgIwQJf6B46RTYvKYONihcYoWYJFBjgf5AZdwo

To claim this, I am signing this object: