Skip to content

Instantly share code, notes, and snippets.

🕵
Investigating a better artifact workflow

Jake Morrison techthoughts2

🕵
Investigating a better artifact workflow
Block or report user

Report or block techthoughts2

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@techthoughts2
techthoughts2 / Format-Prefix.ps1
Last active Sep 22, 2015
Converts between PrefixLength and subnet mask.
View Format-Prefix.ps1
#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 Sep 22, 2015
Import settings from an XML file
View Get-Config.ps1
<#
.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 / Custom-Label
Created Sep 29, 2015
Custom label with division
View Custom-Label
@{Label=”Length”;Expression={'{0:N0}’ –F ($_.Length/1GB)}} | sort Length -Descending | ft -AutoSize
View Invoke-Command.ps1
Invoke-Command $dedicatedserversession - filepath C:\path\test2.ps1
Invoke-Command $nodes -ScriptBlock ${function:get-thename}
@techthoughts2
techthoughts2 / ConvertToGB.ps1
Last active Oct 6, 2015
Rounding and converting to GB
View ConvertToGB.ps1
$freeMemory = [math]::round($w32OSInfo.FreePhysicalMemory /1MB, 0)
$intSize = [math]::round($intSize / 1GB, 0)
@techthoughts2
techthoughts2 / Hyper-V_Misc.ps1
Created Oct 6, 2015
Various Hyper-V Related PowerShell
View Hyper-V_Misc.ps1
#------------------------------------------------------
#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 Oct 6, 2015
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 (*).
View Get-NetworkStatistics.ps1
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.
View Get-VolumeGUID.ps1
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 Oct 8, 2015
Base Template for PowerShell GUI
View PSGUI.ps1
#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">
@techthoughts2
techthoughts2 / Get-WMIObject.ps1
Last active Dec 28, 2015
Get WMI data from local and remote devices
View Get-WMIObject.ps1
#---------------------------------------------------------------------
#get WMI data loaded up
#--------------------------------------------------------------------
try{
$w32ProcInfo = Get-WmiObject -Namespace "root\cimv2" -Class win32_processor -Impersonation 3 -ComputerName $node
$w32OSInfo = Get-WmiObject -Namespace "root\cimv2" -Class Win32_OperatingSystem -Impersonation 3 -ComputerName $node
}
catch{
Write-Host "An error was encountered getting WMI info from $node" -ForegroundColor Red
Write-Error $_
You can’t perform that action at this time.