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
View StringManipulation.ps1
if($vDisk -contains " "){
$vDisk = $vDisk -replace(" ",",")
#remove last character
#extract a specific string set from a long string
View UserChoices.ps1
#will we disable NICs in the team to determine if each NIC connection is good?
while("yes","no" -notcontains $Script:nicCheckSetting){
$Script:nicCheckSetting = Read-Host "Would you like to run the NIC Team connectivty check to check each NIC in the team? (yes/no)"
#for standalone Hyps - which drive will the VMs be stored on?
while("c:","d:","e:","f:","g:","h:","i:","j:","k:","l:","m:","n:","o:","p:","q:","r:","s:","t:","u:","v:","w:","x:","y:","z:" -notcontains $Script:vmVHDLocation){
$Script:vmVHDLocation = Read-Host "What drive letter will the VMs and VHDs be stored? (Ex. D: or S:)"
techthoughts2 / NewDirCheck.ps1
Last active Nov 14, 2018
Evaluates if a directory is present. if not found, the specified directory will be created.
View NewDirCheck.ps1
$TARGETDIR = 'C:\images'
try {
if(!(Test-Path -Path $TARGETDIR -ErrorAction Stop )){
Write-Verbose -Message "Output directory not found. Creating..."
New-Item -ItemType Directory -Path $TARGETDIR -ErrorAction Stop
Write-Verbose -Message "Created."
Write-Verbose -Message "Output directory verified."
techthoughts2 / Test-Connectivity.ps1
Last active Nov 26, 2017
Evaluates if device is capable of establishing a connection to a specified server
View Test-Connectivity.ps1
#test connection example
$server = "Server01"
if (Test-Connection $server -Count 1 -ErrorAction SilentlyContinue) {
#connection successful
else {
#connection not successful
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
$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
Write-Host "An error was encountered getting WMI info from $node" -ForegroundColor Red
Write-Error $_
techthoughts2 / Test-Path.ps1
Last active Nov 14, 2017
Test if specified path actually exists
View Test-Path.ps1
$path = "C:\Windows"
try {
if (Test-Path $path -ErrorAction Stop) {
Write-Output "Path exits"
else {
Write-Output "Path not found"
catch {
techthoughts2 / Get-FileSizes.ps1
Last active Jan 4, 2019
Contains a simple example for retrieving total directory size for all files within a directory. Also contains a more in depth example for retrieving file size as well as other related file information from a directory path.
View Get-FileSizes.ps1
#how to get files and ignore directories
$sizes = Get-ChildItem -Path C:\dell\suu -Recurse -ErrorAction Stop | Where-Object { ! $_.PSIsContainer } | Select-Object -ExpandProperty Length
#simple example
$path = "C:\Test"
$size = (Get-ChildItem -Path $path -Force -Recurse -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum
"Folder Size: $size Bytes"
'Folder Size: {0:n2} MB' -f ($size/1MB)
techthoughts2 / Expand-ZipFile.ps1
Last active Oct 18, 2017
The PowerShell Expand-ZipFile will extract zip files to the specified location.
View Expand-ZipFile.ps1
Expand-ZipFile will extract zip files to the specified location
Expand-ZipFile will extract a zip file and put the extracted contents in the specified location.
This is the second code block that I have not hand-written
function Expand-ZipFile {
# Expand a zip file, ensuring it's contents go to a single folder ...
techthoughts2 / Get-GeneralInfo.ps1
Created Dec 28, 2015
Get general device information loaded up
View Get-GeneralInfo.ps1
Get-GeneralInfo gathers general info about the device to provide in the output
Get-GeneralInfo gathers general info about the device including hostname, model to display in the final output
function Get-GeneralInfo {
#Getting the host name with error control
techthoughts2 / Test-WinRM
Last active Nov 14, 2017
Verifies if remote WinRM Powershell commands can be run against another device by verifying WinRM connectivity to the specified computer name over both HTTP and HTTPS. Returns a customer PSObject containing boolean value for both HTTP and HTTPS results.
View Test-WinRM
Tests WinRm connectivity to specified computername via HTTP and HTTPS
Evaluates both HTTP and HTTPS connectivity over WinRM to specified computername. Returns PSObject with Boolean value for HTTP and HTTPS based on results.
.PARAMETER ComputerName
Hostname of device you wish to test WinRM connection to
Test-WinRM -ComputerName HYP1
You can’t perform that action at this time.