🕵️♂️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#replace | |
if($vDisk -contains " "){ | |
$vDisk = $vDisk -replace(" ",",") | |
} | |
#remove last character | |
$string.Substring(0,$string.Length-1) | |
#extract a specific string set from a long string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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:)" | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (-not(Test-Path -Path $TargetDir -ErrorAction Stop )) { | |
Write-Verbose -Message ('Output directory {0} not found. Creating...' -f $TargetDir) | |
$newItemSplat = @{ | |
ItemType = 'Directory' | |
Path = $TargetDir | |
ErrorAction = 'Stop' | |
} | |
try { | |
New-Item @newItemSplat | |
Write-Verbose -Message 'Created.' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#test connection example | |
$server = "Server01" | |
if (Test-Connection $server -Count 1 -ErrorAction SilentlyContinue) { | |
#connection successful | |
} | |
else { | |
#connection not successful | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#--------------------------------------------------------------------- | |
#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 $_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$path = "C:\Windows" | |
try { | |
if (Test-Path $path -ErrorAction Stop) { | |
Write-Output "Path exits" | |
} | |
else { | |
Write-Output "Path not found" | |
} | |
} | |
catch { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Expand-ZipFile will extract zip files to the specified location | |
.DESCRIPTION | |
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 { | |
#.Synopsis | |
# Expand a zip file, ensuring it's contents go to a single folder ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Get-GeneralInfo gathers general info about the device to provide in the output | |
.DESCRIPTION | |
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 | |
try{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Tests WinRm connectivity to specified computername via HTTP and HTTPS | |
.DESCRIPTION | |
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 | |
.EXAMPLE | |
Test-WinRM -ComputerName HYP1 | |