Skip to content

Instantly share code, notes, and snippets.

View techthoughts2's full-sized avatar
🕵️‍♂️
Investigating a better artifact workflow

Jake Morrison techthoughts2

🕵️‍♂️
Investigating a better artifact workflow
View GitHub Profile
@techthoughts2
techthoughts2 / Format-Prefix.ps1
Last active September 22, 2015 18:59
Converts between PrefixLength and subnet mask.
#obatined from: https://gallery.technet.microsoft.com/scriptcenter/Convert-SubnetMask-80401493
<#
.SYNOPSIS
Converts between PrefixLength and subnet mask.
.DESCRIPTION
This script converts between PrefixLength and subnet mask parameters, these parameters define the size of a subnet for IPv4 addresses.
This script assumes valid subnet mask input and does not support scenarios such as non-contiguous subnet masks.
.INPUTS
None
.OUTPUTS
@techthoughts2
techthoughts2 / Get-Config.ps1
Created September 22, 2015 19:08
Import settings from an XML file
<#
.Synopsis
Get-Config function will pull in needed data from config file
.DESCRIPTION
Get-Config function will pull in needed data from config file.
#>
function Get-Config {
#specify the location of the config file
$csv = Import-Clixml -Path "C:\HypQC_Config.xml"
#Read the XML config file and load data into variables
@techthoughts2
techthoughts2 / Invoke-Command.ps1
Created September 29, 2015 06:44
Invoke-Command
Invoke-Command $dedicatedserversession - filepath C:\path\test2.ps1
Invoke-Command $nodes -ScriptBlock ${function:get-thename}
@techthoughts2
techthoughts2 / Custom-Label
Created September 29, 2015 07:25
Custom label with division
@{Label=”Length”;Expression={'{0:N0}’ –F ($_.Length/1GB)}} | sort Length -Descending | ft -AutoSize
@techthoughts2
techthoughts2 / ConvertToGB.ps1
Last active October 6, 2015 02:25
Rounding and converting to GB
$freeMemory = [math]::round($w32OSInfo.FreePhysicalMemory /1MB, 0)
$intSize = [math]::round($intSize / 1GB, 0)
@techthoughts2
techthoughts2 / ClusterDetect.ps1
Last active November 27, 2017 03:27
Tests / evaluates if local device is a member of a cluster or a standalone server
<#
.Synopsis
Evaluates if local device is a member of a cluster or a standalone server
.DESCRIPTION
Evaluates several factors to determine if device is a member of a cluster or acting as a standalone server. The cluster service is evaluated, and if present the cluster nodes will be tested to determine if the local device is a member. If the cluster service is not running the cluster registry location is evaluated to determine if the server's cluster membership status.
.EXAMPLE
Test-IsACluster
Returns boolean if local device is part of a cluster
.OUTPUTS
@techthoughts2
techthoughts2 / Hyper-V_Misc.ps1
Created October 6, 2015 22:21
Various Hyper-V Related PowerShell
#------------------------------------------------------
#check currently installed roles
Get-WindowsFeature | where {$_.installed -eq "True"}
#------------------------------------------------------
#------------------------------------------------------
#install the Hyper-V Role
Install-WindowsFeature Hyper-V -IncludeManagementTools -Restart -Verbose
#------------------------------------------------------
@techthoughts2
techthoughts2 / Get-NetworkStatistics.ps1
Created October 6, 2015 22:29
Display current TCP/IP connections for local or remote system. Includes the process ID (PID) and process name for each connection. If the port is not yet established, the port number is shown as an asterisk (*).
function Get-NetworkStatistics {
<#
.SYNOPSIS
Display current TCP/IP connections for local or remote system
.FUNCTIONALITY
Computers
.DESCRIPTION
Display current TCP/IP connections for local or remote system. Includes the process ID (PID) and process name for each connection.
@techthoughts2
techthoughts2 / Get-VolumeGUID.ps1
Created October 7, 2015 03:53
Volume GUID resolution
Get-WmiObject -class Win32_Volume -computername localhost | where-object {$_.name -like "\\?\*"} | select-object Label,DriveLetter,DeviceID,SystemVolume,name,Capacity,Freespace | format-list
#also
mountvol.exe
@techthoughts2
techthoughts2 / PSGUI.ps1
Created October 8, 2015 00:01
Base Template for PowerShell GUI
#ERASE ALL THIS AND PUT XAML BELOW between the @" "@
$inputXML = @"
<Window x:Name="Diag_V" x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Diag_V"
mc:Ignorable="d"
Title="Diag-V" Height="350" Width="525">