Skip to content

Instantly share code, notes, and snippets.

foreach ($volume in $VolumeList){
$volumeUri = "$VMSettingsUrl/volumes/$($volume.volumeIdentifier)"
$currentVolume = Invoke-RestMethod -Uri $volumeUri -Method GET -TimeoutSec 100 -Headers $ZertosessionHeader -ContentType $TypeJSON
$currentVolume.Datastore.DatastoreIdentifier = $newVMDS.DatastoreIdentifier
$body = $currentVolume | Convertto-Json -depth 10
$ChangeVolumeLocationRequest = Invoke-RestMethod -Uri $volumeUri -Method PUT -TimeoutSec 100 -Headers $ZertosessionHeader -ContentType $TypeJSON -Body $body
} #Close Volume Loop
@wcarroll
wcarroll / profile.ps1
Created September 21, 2019 16:57
My PowerShell Profile
Function Get-LastCommandExecutionTime {
<#
.SYNOPSIS
Gets the execution time of the last command used.
.EXAMPLE
Get-LastCommandExecutionTime
Description
-----------
Gets the last execution time of the last command run.
@wcarroll
wcarroll / AoCD1P1.ps1
Last active December 1, 2019 23:52
Advent of Code 2019 - Day 1 - Problem 1 Solution
Function Get-Fuel ($PayloadMass) {
[Math]::Floor($PayloadMass / 3) - 2
}
$PayloadMasses = Get-Content .\PayloadMasses.txt
$TotalRequiredFuel = 0
foreach ($PayloadMass in $PayloadMasses) {
$TotalRequiredFuel += Get-Fuel($PayloadMass)
}
Write-Output "Total Required Fuel: $TotalRequiredFuel"
@wcarroll
wcarroll / AoCD1P2.ps1
Last active December 1, 2019 23:55
Advent of Code 2019 - Day 1 - Problem 2 Solution
Function Get-Fuel ($PayloadMass) {
$RequiredFuel = [Math]::Floor($PayloadMass / 3) - 2
if ($RequiredFuel -le 0) {
return 0
} else {
return $($RequiredFuel + $(Get-Fuel($RequiredFuel)))
}
}
$PayloadMasses = Get-Content .\PayloadMasses.txt
@wcarroll
wcarroll / MyProfile.ps1
Last active December 15, 2019 23:18
PowerShell Profile
Function Get-MyIp {
Invoke-RestMethod -Uri "https://ipinfo.io/json"
}
Function Get-LastCommandExecutionTime {
<#
.SYNOPSIS
Gets the execution time of the last command used.
.EXAMPLE
Get-LastCommandExecutionTime
@wcarroll
wcarroll / Windows10-Setup.ps1
Created November 20, 2020 20:28 — forked from NickCraver/Windows10-Setup.ps1
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0