This file contains 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
function Test-SqlConnectionString { | |
<# | |
.SYNOPSIS | |
Tests establishing a connection to SQL instance usese provided ConnectionString | |
.DESCRIPTION | |
Long description | |
.PARAMETER ConnectionString | |
The ConnectionString attempting to make a connection |
This file contains 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
function New-UserPrompt { | |
<# | |
.SYNOPSIS | |
Generate a simple user prompt | |
.DESCRIPTION | |
Long description | |
.PARAMETER Options | |
An array of choices a user can select from |
This file contains 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
class SteviecoasterException : System.Exception { # create a new exception called SteviecoasterException that inherits all of its magic from System.Exception | |
SteviecoaserException([string]$message) : base($message) {} # message is the text you wish to display as your exception | |
} | |
# Use your new class | |
throw [SteviecoasterException]::new('Welp, I ded') |
This file contains 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
function Convert-GitRemote { | |
<# | |
.SYNOPSIS | |
Converts the output of 'git remote -v' to a PowerShell object | |
.EXAMPLE | |
Convert-GitRemote | |
#> | |
[CmdletBinding()] |
This file contains 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
$var = @{A = 10; B = 'abc'} | |
foreach ($key in $var.Keys) { | |
switch ($var[$key].GetType()) { | |
{ $_ -eq [int32] } { "$key + 10 = $($var[$key] + 10)" } | |
{ $_ -eq [string] } { "$key = $($var[$key])" } | |
} | |
} | |
# Output |
This file contains 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
#Download the sample_script.ps1 contents included in this gist | |
$url = 'https://gist.githubusercontent.com/steviecoaster/027d2e53b79e200ffb2455f74e2f1308/raw//sample_script.ps1' | |
$scriptData = [System.Net.WebClient]::new().DownloadString($url) | |
<# | |
The above uses the [System.Net.WebClient] .Net class directly, however you can use New-Object if you are more comfortable: | |
(New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/steviecoaster/027d2e53b79e200ffb2455f74e2f1308/raw/3bc513de7c664915691b6bbd78c49649069f52c5/sample_script.ps1') | |
#> | |
# Next, we create our script block, and fill it with our $scriptData |
This file contains 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 | |
Creates the `ChocolateyInstall` IIS fileshare site. | |
.DESCRIPTION | |
Creates a new IIS website named `RtpsugDemo` which hosts the | |
a collection of scripts for onboarding clients to retrieve and run during their | |
setup. | |
If you have a need to re-create this for any reason, ensure the existing |
This file contains 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
function Write-ReverseOuput { | |
[Alias('Write-Output')] | |
[CmdletBinding()] | |
Param( | |
[Parameter(Mandatory)] | |
[String] | |
$InputObject | |
) | |
end { |
This file contains 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
Function Get-AllBoundParameters { | |
[CmdletBinding()] | |
Param( | |
# A simple string parameter that is mandatory | |
[Parameter(Mandatory)] | |
[String] | |
$Name, | |
# A simple switch | |
[Parameter()] |
This file contains 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
#Requires -RunAsAdministrator | |
#Set our execution policy for the process | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
#Store our packages.config from the gist here temporarily | |
$tempFile = Join-Path $env:TEMP -ChildPath 'packages.config' | |
#Write our config file contents | |
$configFile = 'https://gist.githubusercontent.com/steviecoaster/798bb1046b8fc3275b5a4801cb6f46e4/raw/6e68dbca121276af44ff540c4b6e26df42ee6832/packages.config' |
NewerOlder