Skip to content

Instantly share code, notes, and snippets.

View PSingletary's full-sized avatar
🔍
Search

PSingletary PSingletary

🔍
Search
View GitHub Profile
@PSingletary
PSingletary / Get-PingSweep.ps1
Last active April 23, 2018 13:46 — forked from joegasper/Get-PingSweep.ps1
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
}
}
@PSingletary
PSingletary / Ping-Segment.ps1
Created April 23, 2018 13:42
IP scan subnet (@lee_holmes @PSHSummit 2015)
$ips = 1..255 | % {"172.20.1.$_"}
$t=$ips|%{(New-Object Net.NetworkInformation.Ping).SendPingAsync($_,250)};[Threading.Tasks.Task]::WaitAll($t);$t.Result | select Address, Status, RoundtripTime | %{ if($_.Status -eq "Success"){$_}}
<#
Measure-Command -Expression {
$ips = 1..255 | % {"172.20.1.$_"}
$t=$ips|%{(New-Object Net.NetworkInformation.Ping).SendPingAsync($_,250)};[Threading.Tasks.Task]::WaitAQll($t);$t.Result | select Address, Status, RoundtripTime | %{ if($_.Status -eq "Success"){$_}}
} | Select Milliseconds
#>
## This can be a remote PC name as well
$pc = '.'
$cert_store = 'My'
$store = New-Object system.security.cryptography.X509Certificates.X509Store ("\$pcMy"),'LocalMachine' #LocalMachine could also be LocalUser
$store.Open('ReadWrite')
## Find all certs that have an Issuer of my old CA
$certs = $store.Certificates | ? {$_.Issuer -eq 'CN=HOST.DOMAIN.COM, DC=DOMAIN, DC=EXT'}
## Remove all the certs it finds
$certs | % {$store.Remove($_)}
Start a service on remote computer:
Start-Service -InputObject $(Get-Service -Computer COMPUTER1 -Name spooler)
Stop a service on remote computer:
Stop-Service -InputObject $(Get-Service -Computer COMPUTER1 -Name spooler)
Restart a service on remote computer:
Restart-Service -InputObject $(Get-Service -Computer COMPUTER1 -Name spooler)
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
choco install 7zip /y
choco install adobereader /y
choco install anaconda3 /y
choco install azure-cli /y
choco install docker-for-windows /y
choco install firefox /y
choco install garmin-express /y
choco install git /y
#Prep
Update-ExecutionPolicy Unrestricted
Disable-UAC
#Win Config
Set-TaskbarOptions -Size Small -Lock -Dock Top
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Disable-InternetExplorerESC
@PSingletary
PSingletary / uptime.ps1
Created May 24, 2018 12:05
System Uptime (via Common Information Model {CIM})
gcim Win32_OperatingSystem | select csname, lastbootuptime
## This Script has been written for converting a Dell Service Tag into Express service Tag
## Author : Prakash Kumar ([email protected]) May 22th 2018
## www.adminthing.blogspot.com
## Please use this script at your own risk.
##
## Usage:
## Since this has a function so it needs to be loaded into the memory of PS console by dot sourcing it: **
## PS C:\> . ./ConvertTo-ExpressServiceTag.ps1
## PS C:\> Convertto-ExpressServiceTag A1B2C3D
@PSingletary
PSingletary / Find-ADComputerObject.ps1
Created May 30, 2018 14:26
Script to compare a list of computers against Active Directory computer objects - https://gallery.technet.microsoft.com/scriptcenter/Script-to-compare-a-list-abbba793
<#
.NOTES
<Additional information about the function or script.>
Version: 1.0
Author: Pratik Pudage ([email protected])
Creation Date: 5/28/2018
.LINK
https://gallery.technet.microsoft.com/scriptcenter/Script-to-compare-a-list-abbba793
<#
.NOTES
Version: 2.0
Author: Pratik Pudage ([email protected])
Creation Date: 5/28/2018
Purpose/Change:
- Included HTML Email Reporting.
- Included exclusion criteria.
.LINK