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 name | |
comment based help | |
etc | |
etc | |
#> | |
param( | |
[parameter(position = 1, | |
parametersetname = 'id')] | |
[string]$Identity, |
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-VideoPlayBackTime { | |
<# | |
comment based help | |
#> | |
[Alias('video')] # <-- This guy! | |
[CmdletBinding()] | |
[OutputType([PSCustomObject])] | |
param ( | |
# Minutes of the video only | |
[Parameter(Position = 0)] |
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 ConvertTo-Parameters { | |
$Path = (Read-Host -Prompt 'Enter the location of the folder') | |
$Number = (Read-Host -Prompt 'Enter a number from 1 to 10') | |
$Set = (Read-Host -Prompt 'Choose a set of Set1, Set2, or Set3') | |
Test-Parameters -Path $Path -Number $Number -Set $Set | |
} |
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-DefaultParameters { | |
[cmdletbinding()] | |
param( | |
[parameter(Position = 0)] | |
[ValidateScript({ Test-Path -Path $_ })] | |
[Alias('PSPath')] | |
[string] | |
$Path = (Read-Host -Prompt 'Enter the location of the folder'), | |
[parameter(Position = 1)] |
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-ParametersAndPrompts { | |
[cmdletbinding()] | |
param( | |
[parameter(Position = 0, HelpMessage = 'Enter the location of the folder.')] | |
[ValidateScript({ Test-Path -Path $_ })] | |
[Alias('PSPath')] | |
[string] | |
$Path, | |
[parameter(Position = 1, HelpMessage = 'Enter a number from 1 to 10.')] |
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-Parameters { | |
[cmdletbinding()] | |
param( | |
[parameter(Mandatory, Position = 0, HelpMessage = 'Enter the location of the folder.')] | |
[ValidateScript({ Test-Path -Path $_ })] | |
[Alias('PSPath')] | |
[string] | |
$Path, | |
[parameter(Mandatory, Position = 1, HelpMessage = 'Enter a number from 1 to 10.')] |
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-Prompts { | |
do { | |
[string]$Path = Read-Host -Prompt 'Enter the location of the folder.' | |
} until (Test-Path -Path $Path) | |
do { | |
[int]$Number = Read-Host -Prompt 'Enter a number from 1 to 10.' | |
} until ($Number -ge 1 -and $Number -le 10) |
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-Prompts { | |
do { | |
[string]$Path = Read-Host -Prompt 'Enter the location of the folder.' | |
} until (Test-Path -Path $Path) | |
do { | |
[int]$Number = Read-Host -Prompt 'Enter a number from 1 to 10.' | |
} until ($Number -ge 1 -and $Number -le 10) |
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
-- region Server Trigger | |
IF EXISTS (SELECT * FROM sys.server_triggers WHERE name = N'NewDatabase') DROP TRIGGER NewDatabase ON ALL SERVER; | |
GO | |
CREATE TRIGGER NewDatabase | |
ON ALL SERVER | |
FOR CREATE_DATABASE | |
AS | |
SELECT EVENTDATA().value('(/EVENT_INSTANCE/ServerName)[1]', 'nvarchar(256)') AS ServerName, | |
EVENTDATA().value('(/EVENT_INSTANCE/DatabaseName)[1]', 'nvarchar(128)') AS DatabaseName, | |
EVENTDATA().value('(/EVENT_INSTANCE/PostTime)[1]', 'datetime') AS CreateTime, |
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
#region Test-EditedConfirm | |
function Test-EditedConfirm { | |
[CmdletBinding(SupportsShouldProcess, | |
ConfirmImpact = 'High')] | |
param( | |
[int[]]$Numbers | |
) | |
process { | |
foreach ($num in $Numbers) { | |
if ($PSCmdlet.ShouldProcess("Guess what this does? [$num]", |