Skip to content

Instantly share code, notes, and snippets.

<#
IsReady is the option of an internal determination of whether an operation needs to execute or is safe to execute.
A switch of -WhatIf will override anything else.
A switch of -Force can override an unsafe operation. It is not prompted.
A prompt for confirmation only occurs if needed, and this will show on interactive sessions, while being denied on
noninteractive sessions.
#>
function Test-ShouldProcess {
[CmdletBinding(SupportsShouldProcess)]
@codykonior
codykonior / gist:29bdaa04eb8aaa7e0d740f78ecd2a777
Last active April 16, 2019 06:20
Download all of the historic Infocom source code from git
(ConvertFrom-Json (Invoke-WebRequest "https://api.github.com/users/historicalsource/repos?page=1&per_page=100").Content).clone_url | ForEach-Object { &git clone $_ }
$ErrorActionPreference = "Stop"
Set-StrictMode -Version "Latest"
function Create-Login {
$loginSetup = "
IF EXISTS (SELECT * FROM sys.server_principals WHERE name = 'LAB\CHWK01$') DROP LOGIN [LAB\CHWK01$];
CREATE LOGIN [LAB\CHWK01$] FROM WINDOWS;
GRANT CONTROL SERVER TO [LAB\CHWK01$];
"
"SEC1N1", "SEC1N2", "SEC1N3", "DAC1N1", "DAC1N2" | New-DbConnection | New-DbCommand $loginSetup | Get-DbData
@codykonior
codykonior / Find-ModuleUpdate.ps1
Last active February 21, 2018 04:13
Find-ModuleUpdate
# Faster to get them all at once than look up a few dozen individually
$galleryModules = Find-Module -Verbose:$false
# If you only want to update modules sourced from the PowerShell Gallery, you can add a filter by:
# Where-Object { $_.RepositorySourceLocation -eq "https://www.powershellgallery.com/api/v2/" }
Get-Module -ListAvailable -Verbose:$false | Group-Object Name | ForEach-Object {
if (($_.Group | ForEach-Object Version | Select-Object -Unique | Measure-Object).Count -gt 1) {
Write-Verbose "$($_.Name) has multiple versions installed, I will only check the highest version"
}
$module = $_.Group | Sort-Object Version -Descending | Select-Object -First 1