Skip to content

Instantly share code, notes, and snippets.

@tech-zombie
tech-zombie / quickwanacrypatch
Last active May 17, 2017
quick dirty wannacry patch checker
View quickwanacrypatch
$fix = (Get-HotFix | findstr "KB3205409 KB3210720 KB3210721 KB3212646 KB3213986 KB4012212 KB4012213 KB4012214 KB4012215 KB4012216 KB4012217 KB4012218 KB4012220 KB4012598 KB4012606 KB4013198 KB4013389 KB4013429 KB4015217 KB4015438 KB4015546 KB4015547 KB4015548 KB4015549 KB4015550 KB4015551 KB4015552 KB4015553 KB4015554 KB4016635 KB4019213 KB4019214 KB4019215 KB4019216 KB4019263 KB4019264 KB4019472")
if([string]::IsNullOrEmpty($fix))
{Write-Host -ForegroundColor Yellow -backgroundcolor red "************** UNSAFE patch me! ****************"
Write-Host -ForegroundColor yellow -backgroundcolor black "************** UNSAFE patch me! ****************"
Write-Host -ForegroundColor yellow -backgroundcolor red "************** UNSAFE patch me! ****************"} else {write-host -ForegroundColor Green "----------- SAFE :-) ---------------"
$fix}
View service win image
dism /online /cleanup-image /startcomponentcleanup /resetbase
@tech-zombie
tech-zombie / stale ad computers
Last active May 22, 2017
polls ad for computer objects that have not called home for a period of time, can either report or delete them.
View stale ad computers
import-module activedirectory
#finddomain or enter manually
#$domain = (Get-WmiObject Win32_ComputerSystem).Domain
#domain = my.domain.com
#edit for number of days to go back
$DaysInactive = 90
$time = (Get-Date).Adddays(-($DaysInactive))
View gist:ebf2b66a156420b02f69ba0a06b49879
Get-VM | Get-Snapshot | Select VM,Name,@{N="SizeGB";E={@([math]::Round($_.SizeGB))}},Created
View gist:c5d29d1509cdfde8e92326dacb1adf0e
USE [msdb]
GO
BEGIN TRANSACTION
DECLARE @ReturnCode INT
SELECT @ReturnCode = 0
IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'[Uncategorized (Local)]'
AND category_class=1)
BEGIN
EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL',
View gist:eca27cd6ad53614c111d0d989fe6f1ab
Get-VM | Get-NetworkAdapter | Where-object {$_.Type -ne "Vmxnet3"} | Select @{N="VM";E={$_.Parent.Name}},Name,type
@tech-zombie
tech-zombie / gist:3e2d894526a2043b550b16ca4dfd336e
Created Jul 3, 2018
first 4 configured IP address in vcenter
View gist:3e2d894526a2043b550b16ca4dfd336e
get-vm | select Name, @{N="IP1";E={@($_.guest.IPAddress[0])}}, @{N="IP2";E={@($_.guest.IPAddress[1])}}, @{N="IP3";E={@($_.guest.IPAddress[2])}}, @{N="IP4";E={@($_.guest.IPAddress[3])}}
@tech-zombie
tech-zombie / gist:751acfbf52282a7253d8e207507f8674
Last active Jul 24, 2018
Mass create DFSR folders in group
View gist:751acfbf52282a7253d8e207507f8674
$folders =
$groupname =
$rootpath =
foreach ($folder in $folders)
{
$path = $rootpath + $folder
New-DfsReplicatedFolder -GroupName $groupname -FolderName $folder
Set-DfsrMembership -GroupName $groupname -FolderName $folder -ComputerName WEB1 -ContentPath $path -PrimaryMember $true -force
@tech-zombie
tech-zombie / get-newestfile.ps1
Last active Jan 9, 2019
Powershell to get newest file in folder
View get-newestfile.ps1
function Get-NewestFile
{
param($PathToDirectory)
$NewestFile = Get-ChildItem $PathToDirectory | sort LastWriteTime | select -last 1
$PathToNewestFile = $PathToDirectory + "\" + $NewestFile
$PathToNewestFile
}
@tech-zombie
tech-zombie / connect-to-webiste.ps1
Created Jan 9, 2019
Quick and stupid traffic generator, will show chrome on site so you can see how it deals with traffic, has a hard dependency on chrome.
View connect-to-webiste.ps1
Function connect-towebsite
{
Param($siteURL)
cd "C:\Program Files (x86)\Google\Chrome\Application\"
for ($i=0; $i -lt 100; $i++)
{
.\chrome.exe -incognito $siteURL
start-sleep 5
get-process "*chrome*" | Stop-Process