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 / Test-DomainUser.ps1
Last active November 14, 2017 03:23
Tests to verify that the script is running as a domain user or local user
<#
.Synopsis
Verifies if currently logged in user is a local user or domain user
.DESCRIPTION
This function will evaluate the users domain and determine if the current user is a domain user or local user. If true is returned the user is a domain user, if false is returned the user is a local user.
.EXAMPLE
Test-DomainUser
This will return a true/false indicating if the user is a domain user or not
.EXAMPLE
Test-DomainUser -Verbose
@techthoughts2
techthoughts2 / Pause.ps1
Last active December 28, 2015 16:07
Pause the script
Start-Sleep -s 55
@techthoughts2
techthoughts2 / Test-RegKey.ps1
Last active November 12, 2017 04:46
Tests to determine if specified registry key is present
<#
.Synopsis
Tests if specified registry key is present
.DESCRIPTION
Evaluates provided registry path and determines if key is present. True or false is returned.
.PARAMETER RegKeyPath
Registry key path - must be in PS shorthand. Ex: HKLM:\SECURITY
.EXAMPLE
Test-RegKey -RegKeyPath HKLM:\SECURITY
Verifies if the specified registry key exists
@techthoughts2
techthoughts2 / New-VHD.ps1
Created December 28, 2015 16:28
Create a New-VHD
#----------------------Variables Used----------------------------------------
[string]$vmName = $null
[string]$vhdName = $null
[string]$vhdType = $null
[string]$path = $null
[string]$vhdPath = $null
[int64]$vhdSize = $null
[string]$dynamic = $null
[string]$confirm = $null
#--------------------END Variables Used--------------------------------------
@techthoughts2
techthoughts2 / New-VM.ps1
Created December 28, 2015 16:31
Creates a new Hyper-V VM with user prompts
#----------------USER CREATION QUESTIONS-------------------
[string]$vmName= Read-Host ”Name of VM”
#__________________________________________________________
[int32]$generation = Read-Host "Generation Type"
#__________________________________________________________
[string]$dynamic = $null
while("yes","no" -notcontains $dynamic){
$dynamic = Read-Host "Will this VM use dyanmic memory? (yes/no)"
}
if($dynamic -eq "yes"){
@techthoughts2
techthoughts2 / Hyp_Lab_Setup.ps1
Created December 28, 2015 16:33
Quick Hyper-V Lab Setup
#------------------------------------------------------
#check currently installed roles
Get-WindowsFeature | where {$_.installed -eq "True"}
#------------------------------------------------------
#------------------------------------------------------
#install the Hyper-V Role
Install-WindowsFeature Hyper-V -IncludeManagementTools -Restart -Verbose
#------------------------------------------------------
@techthoughts2
techthoughts2 / AutomaticStopAction.ps1
Last active October 19, 2017 02:18
First part of script evaluates all Hyper-V VMs AutomaticStopAction setting to determine how much drive space is being wasted by the default Save setting. Second part of script enables you to mass change the setting to Shutdown on all VMs on the server.
#determine if current VM AutomaticStopAction settings is using up a lot of harddrive space
#---------------------------------------------------------
$vmMemory = 0
#---------------------------------------------------------
try {
$vms = Get-VM -ErrorAction Stop
foreach ($vm in $vms) {
if ($vm.AutomaticStopAction -eq "Save") {
$vmMemory += [math]::round($vm.MemoryAssigned / 1GB, 0)
}
@techthoughts2
techthoughts2 / Versioning.ps1
Created February 28, 2016 04:37
Version commands
#version info
$PSVersionTable
$PSVersionTable.PSVersion
$PSVersionTable.WSManStackVersion
$PSVersionTable.WSManStackVersion.Major
#WFM version
(host).Version
@techthoughts2
techthoughts2 / Gallery.ps1
Last active December 20, 2019 04:06
PowerShell Gallery Commands
@techthoughts2
techthoughts2 / FizzBuzz.ps1
Created February 29, 2016 05:13
FizzBuzz
for ($i = 1; $i -le 100; $i++) {
if ($i % 15 -eq 0) {
"FizzBuzz"
} elseif ($i % 5 -eq 0) {
"Buzz"
} elseif ($i % 3 -eq 0) {
"Fizz"
} else {
$i
}