Skip to content

Instantly share code, notes, and snippets.

Avatar

Bryan Vine bryanvine

View GitHub Profile
View Cleanup-windows-installer.ps1
<#
Cleanup-windows-installer.ps1
http://www.bryanvine.com/2015/06/powershell-script-cleaning-up.html
Bryan Vine
6/22/2015
www.bryanvine.com
This script uses Heath Stewart's VB script to identify which files need to be saved and then removes everything else.
@bryanvine
bryanvine / BV-Multithread.ps1
Last active Aug 29, 2015
Make any powershell script multithreaded with this powershell function wrapper (Invoke-Multithread)
View BV-Multithread.ps1
#Requires -Version 3.0
Function Invoke-Multithread{
<#
.SYNOPSIS
Wrapper function that lets you divide and conquer a server list to multithread it's execution.
.DESCRIPTION
Similar behavior to Invoke-Command -Asjob which lets you remotely start scriptblocks on target servers,
this function starts local jobs that are to be targeted at remote servers.
Great for multithreaded push deployments or report generation
@bryanvine
bryanvine / gist:ad340458dfcaf31756fe
Last active Aug 29, 2015
Exampe - Invoke-Multithread
View gist:ad340458dfcaf31756fe
#http://www.bryanvine.com/2015/06/powershell-script-invoke-multithread.html
#ScriptBlock: function declaration with function name on the last line without the -ComputerName parameter
$SB = {
Function Check-WindowsServer{
param(
[string[]]$ComputerName
)
foreach ($server in $ComputerName){
@bryanvine
bryanvine / BV-HTMLTableMaker.ps1
Last active Aug 29, 2015
ConvertTo-HtmlTabel - Make Pretty HTML formatted tables
View BV-HTMLTableMaker.ps1
#Requires -Version 3.0
Function ConvertTo-HtmlTable{
<#
.SYNOPSIS
Converts table objects into HTML text for web page conversion and/or emailing as html reports.
.DESCRIPTION
Will convert any object array into a formatted HTML string output for saving as a web page or for emailing.
Doesn't handle nested objects, please only provide a two-demensional table as input.
.PARAMETER Table
@bryanvine
bryanvine / BV-Uptime.ps1
Last active Aug 29, 2015
Function: Get-LastBootTime - remotely find out when your computers where last rebooted
View BV-Uptime.ps1
#Requires -Version 2.0
Function Get-LastBootTime{
<#
.SYNOPSIS
Uses WMI to query one or more computers and returns a sorted table of names and date/times of since last boot.
.DESCRIPTION
Works with any windows computer that can accept remote WMI queries
.PARAMETER ComputerName
Specifies one or more server names.
@bryanvine
bryanvine / TestIP_RDP.ps1
Last active Aug 29, 2015
Quick Script - Check if servers are pingable and have RDP port TCP 3389 open
View TestIP_RDP.ps1
Param(
[String] $Servers
)
$srvrs = gc $servers
$collection = @()
foreach ($srv in $srvrs){
$serverStatus = New-Object PSObject
$serverStatus |Add-Member NoteProperty ServerName $srv
@bryanvine
bryanvine / BV-Test_Ping-RDP
Last active Aug 29, 2015
Quick Script Function Test-PingRDP - make a report from a list of servers, testing if it responds to a ping and has RDP open
View BV-Test_Ping-RDP
Function Test-PingRDP {
Param(
[String]$ServerList,
[String]$CSVOutput = ".\ServerStatus.csv"
)
$collection = @()
Get-Content $serverList | ForEach-Object{
$serverStatus = New-Object PSObject
@bryanvine
bryanvine / BV-Compare_Source_Files.ps1
Last active Aug 29, 2015
Powershell Script - Compare Source Files - utility function to compare code between dev, prod, qa, bcp, etc.
View BV-Compare_Source_Files.ps1
#Requires -Version 2.0
Function Compare-SourceFiles {
<#
.SYNOPSIS
Compares two directories and calculates any differences in files between them using MD5 hash comparison.
.DESCRIPTION
Only looks at full file paths, empty directories aren't scanned.
.PARAMETER Source1
Full path (or UNC network share) to a directory to compare
@bryanvine
bryanvine / BV-Working_with_Parse.ps1
Last active Aug 29, 2015
Powershell Script - Get-Parse & Publish-Parse - upload and download data from Parse.com Core DB
View BV-Working_with_Parse.ps1
#Requires -Version 3.0
Function Get-Parse{
<#
.SYNOPSIS
Gets data from Parse.com's core DB.
.DESCRIPTION
Limitation: 10,000 entries per call. If your class is bigger, you'll need to break up your calls by objectIds.
@bryanvine
bryanvine / Get_ServerHDDinfoWMI.ps1
Last active Aug 29, 2015
BV-Get_RemoteHDDInfo_WMI
View Get_ServerHDDinfoWMI.ps1
#Requires -Version 2.0
Function Get-ServerHDDinfo{
<#
.SYNOPSIS
Gets all harddrive size info using WMI
.DESCRIPTION
Returns one object per drive: drive mount, label, total size, used size, used percent, free size.
WMI is slower than invoke-command so this is a fail back function for when PSRemoting isn't enabled.
You can’t perform that action at this time.