Skip to content

Instantly share code, notes, and snippets.

View mintsoft's full-sized avatar
💭
Probably alive.

Rob Emery mintsoft

💭
Probably alive.
  • UK
View GitHub Profile
@mintsoft
mintsoft / AllResolutions.ps1
Created April 13, 2015 12:30
Powershell for getting all resolutions from all monitors
$pinvokeCode = @"
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
namespace Resolution
{
[StructLayout(LayoutKind.Sequential)]
public struct DEVMODE1
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
@mintsoft
mintsoft / recurse_delete_older_than.ps1
Last active January 2, 2016 14:58
Recurse 1 deep in a directory and delete directories older than X
gci *\* | where {$_.PSIsContainer -and $_.CreationTime -lt '2013-01-01T00:00:00'} | %{ write-host $_.FullName; remove-item -recurse $_;}
@mintsoft
mintsoft / Forkinator.ps1
Last active May 24, 2023 17:50
Powershell to run a bunch of commands in new processes, wait until they're all done and output all the stdout/stderr. If one of the commands returns non-0 exit code then entire script returns 1
#To add more commands, hack them into the $commands array:
$commands = @(
@{"cmd" = "D:\Documents\Powershell\battwo.bat"; "args" = "yo"},
@{"cmd" = "D:\Documents\Powershell\batone.bat"; "args" = "yo2"}
);
$jobs = @();
foreach($cmd in $commands) {
$startinfo = new-object System.Diagnostics.ProcessStartInfo
$startinfo.FileName = $cmd.cmd;
@mintsoft
mintsoft / DellServiceTag.vbs
Created July 10, 2013 15:59
Report on a DELL's service tag remotely
on error resume next
strComputer=InputBox ("Enter the computer name of the server you'd like to query for the Service Tag:")
Set objWMIservice = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colitems = objWMIservice.ExecQuery("Select * from Win32_BIOS",,48)
For each objitem in colitems
Wscript.echo "Dell Service Tag: " & objitem.serialnumber
Next
@mintsoft
mintsoft / inspect.sh
Created July 10, 2013 10:29
Inspect Remote SSL Certificate using openssl
#!/bin/bash
[[ -n "${1}" ]] && openssl x509 -in <( echo "GET /" | openssl s_client -connect ${1}:443 2>&1 | grep -A 65535 'Server certificate' | tail -n+2 | grep -B 65535 'END CERTIFICATE' ) -noout -text -purpose
@mintsoft
mintsoft / ExportSQLTasks.ps1
Created July 3, 2013 11:08
Dumps the content of SQL Tasks in SSIS dtsx packages to files for easier diff-ing in source control.
import-module SSIS
$ssis_package = "D:\MyFile.dtsx";
$package = Get-ISPackage -path $ssis_package;
$package.Executables | Where-Object { $_.InnerObject -like 'Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ExecuteSQLTask' } | %{ $fn = $_.Name+".sql"; $_.InnerObject.SqlStatementSource > $fn }
@mintsoft
mintsoft / xml.nanorc
Created July 2, 2013 21:29
Nano XML Highlighting
syntax "ml" ".*\.(xml|xul|rdf|rss|xbl|sgml?)$"
color white "^.+$"
# Attribute names
color brightblue start="<" end=">"
# Attribute text
color brightgreen ""[^"]+""
# Tag names
color brightcyan "<[^> ]+"
# Alligators
color cyan "<"
@mintsoft
mintsoft / captureHTTPTraffic.sh
Created June 24, 2013 15:13
Capture HTTP Traffic on a linux box from the kernel
#!/bin/bash
sudo tcpdump -i eth1 -c 100000 -w $(date '+%F_%H-%M-%S').pcap 'tcp port 80'
@mintsoft
mintsoft / analyze_8.4.sh
Created June 17, 2013 14:07
Iterate over tables in public schema and run analyze
#!/bin/bash
db="postgres"
psql -qAt -c "SELECT tablename FROM pg_tables WHERE schemaname='public';" $db | while read line; do
psql -qAt -c "ANALYZE $line;" $db;
done
@mintsoft
mintsoft / TSQL_Query.ps1
Created June 14, 2013 10:03
Execute TSQL against a SQL Server from Powershell without SQL Server Management Studio modules installed
$connectionString = "Data Source=cidbsql.cwserverfarm.local;Initial Catalog=workdb;Integrated Security=True;Application Name=PowerSheQL";
$SQL = "SELECT TOP 5 * FROM dbo.RE_Trace;";
$dbc = New-Object System.Data.SqlClient.SqlConnection($connectionString);
$dbc.Open();
$sqlcmd = $dbc.CreateCommand();
$sqlcmd.CommandTimeout = 1;
$sqlcmd.CommandText = $SQL;
$sqlcmd.Prepare();