Skip to content

Instantly share code, notes, and snippets.

View shaneis's full-sized avatar
🎯
The mind isn't a cup to fill but a fire to feed...my whiskey cup is empty tho...

Shane O'Neill shaneis

🎯
The mind isn't a cup to fill but a fire to feed...my whiskey cup is empty tho...
View GitHub Profile
@shaneis
shaneis / Test-Confirm.ps1
Last active August 27, 2018 22:16
Finally confirm
#region Test-Confirm
function Test-Confirm {
[CmdletBinding(SupportsShouldProcess,
ConfirmImpact = 'High')]
param(
[int[]]$Numbers
)
process {
foreach ($num in $Numbers) {
if ($PSCmdlet.ShouldProcess($num)) {
#region Test-YesAllConfirm
function Test-YesAllConfirm {
[CmdletBinding()]
param(
[int[]]$Numbers
)
process {
foreach ($num in $Numbers) {
if (-not $doAll) {
$keepGoing = Read-Host "Are you sure you want to process: [$num] (Yes, No, All (default), Exit)"
#region Test-ListeningConfirm
function Test-ListeningConfirm {
[CmdletBinding()]
param(
[int[]]$Numbers
)
process {
foreach ($num in $Numbers) {
$keepGoing = Read-Host "Are you sure you want to process: [$num] (Y/N)"
if ($keepGoing -eq 'Y') {
#region Test-ManualConfirm
function Test-ManualConfirm {
[CmdletBinding()]
param(
[int[]]$Numbers
)
process {
foreach ($num in $Numbers) {
Read-Host -Prompt "Are you sure you want to process: [$num]"
"Current number: [$num]"
#region Test-ManualPause
function Test-ManualPause {
[CmdletBinding()]
param(
[int[]]$Numbers
)
process {
foreach ($num in $Numbers) {
Pause
"Current number: [$num]"
@shaneis
shaneis / AllTheConfirms.ps1
Last active August 27, 2018 21:04
All the confirms cause I ain't making multiple gists...
$Numbers = 1..10
#region Test-ManualPause
function Test-ManualPause {
[CmdletBinding()]
param(
[int[]]$Numbers
)
process {
foreach ($num in $Numbers) {
@shaneis
shaneis / DifferentTypes.ps1
Created July 18, 2018 14:09
I like the formatting
[PSCustomObject]@{
    Name = '$Stmt'
    Type = $Stmt.GetType().FullName
}, [PSCustomObject]@{
    Name = '$ActualStmt'
    Type = $ActualStmt.GetType().FullName
}
$propertyPathProperties | ForEach-Object -Begin {
$Stmt = "Get-Content -Path .\BasicJson.json |`n`tConvertFrom-Json"
} -Process {
$Stmt += " |`n`tSelect-Object -ExpandProperty $_"
} -End {
$Stmt
}
$propertyPath = 'Database.Table.Fruit'
($propertyPathProperties = $propertyPath -split '\.')
@shaneis
shaneis / CannotDoThis.ps1
Last active July 5, 2018 19:09
There's no property called "Database.View.IsYAVowel"
Get-Content -Path .\BasicJson.json |
ConvertFrom-Json |
Select-Object -ExpandProperty Database.View.IsYAVowel
Get-Content -Path .\BasicJson.json |
ConvertFrom-Json |
Select-Object -Property Database.View.IsYAVowel