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){ |
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 |
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 |
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. |
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 |
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 |
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 |
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. |
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. |
View Get_ServerHDDinfoPSRemoting.ps1
#Requires -Version 3.0 | |
Function Get-ServerHDDinfo{ | |
<# | |
.SYNOPSIS | |
Gets all harddrive size info using Invoke-Command (PS Remoting) | |
.DESCRIPTION | |
Returns one object per drive: drive mount, label, total size, used size, used percent, free size. | |
.PARAMETER ComputerName |
OlderNewer