Skip to content

Instantly share code, notes, and snippets.

View tech-zombie's full-sized avatar

Ade Roberts tech-zombie

View GitHub Profile
dism /online /cleanup-image /startcomponentcleanup /resetbase
@tech-zombie
tech-zombie / quickwanacrypatch
Last active May 17, 2017 08:58
quick dirty wannacry patch checker
$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}
@tech-zombie
tech-zombie / stale ad computers
Last active May 22, 2017 11:25
polls ad for computer objects that have not called home for a period of time, can either report or delete them.
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))
Get-VM | Get-Snapshot | Select VM,Name,@{N="SizeGB";E={@([math]::Round($_.SizeGB))}},Created
@tech-zombie
tech-zombie / gist:c5d29d1509cdfde8e92326dacb1adf0e
Created March 2, 2018 12:47
weekly sql error log rotation
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',
Get-VM | Get-NetworkAdapter | Where-object {$_.Type -ne "Vmxnet3"} | Select @{N="VM";E={$_.Parent.Name}},Name,type
@tech-zombie
tech-zombie / gist:3e2d894526a2043b550b16ca4dfd336e
Created July 3, 2018 08:18
first 4 configured IP address in vcenter
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 July 24, 2018 09:34
Mass create DFSR folders in group
$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 / connect-to-webiste.ps1
Created January 9, 2019 11:36
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.
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
@tech-zombie
tech-zombie / get-newestfile.ps1
Last active January 9, 2019 11:38
Powershell to get newest file in folder
function Get-NewestFile
{
param($PathToDirectory)
$NewestFile = Get-ChildItem $PathToDirectory | sort LastWriteTime | select -last 1
$PathToNewestFile = $PathToDirectory + "\" + $NewestFile
$PathToNewestFile
}