This file contains hidden or 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-IanaPortNumberRegistry { | |
| [CmdLetBinding()] | |
| param( | |
| [ValidateSet('TCP','UDP','SCTP','DCCP')] | |
| [string[]]$Protocol, | |
| [ValidateRange(0,65535)] | |
| [int[]]$PortNumber, | |
| [string]$ServiceName, | |
| [switch]$RefreshCache, | |
| [string]$AlternatePath |
This file contains hidden or 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-EventSource { | |
| [CmdLetBinding()] | |
| param( | |
| [string]$EventLog, | |
| [string]$Source | |
| ) | |
| if ([System.Diagnostics.EventLog]::SourceExists($Source) -eq $false) { | |
| try { | |
| [System.Diagnostics.EventLog]::CreateEventSource($Source, $EventLog) |
This file contains hidden or 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-WPSite { | |
| [CmdLetBinding()] | |
| param( | |
| [Parameter(Mandatory)] | |
| [uri]$Url | |
| ) | |
| if ($Url.AbsoluteUri -notmatch 'wp-json') { | |
| [uri]$Url = $Url.AbsoluteUri,'wp-json' -join '/' | |
| } |
This file contains hidden or 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-MarkdownFileLinks{ | |
| [CmdLetBinding()] | |
| param( | |
| [ValidateScript({Test-Path -Path $_})] | |
| [string[]]$MarkdownFile, | |
| [uri[]]$SkipUri, | |
| [switch]$ShowProgress | |
| ) | |
| begin { |
This file contains hidden or 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
| @{ | |
| RootModule = 'DemoModule.psm1' | |
| ModuleVersion = '0.7.0' | |
| CompatiblePSEditions = 'Core' | |
| GUID = 'a007643e-c876-4806-b6cb-367963716e98' | |
| Author = 'Dave' | |
| CompanyName = 'thedavecarroll' |
This file contains hidden or 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
| { | |
| // insert markdown links | |
| "Insert Link" : { | |
| "prefix": "link", | |
| "body": [ | |
| "[text][text]{:target=\"_blank\"}" | |
| ] | |
| }, | |
| "Insert Reference" : { | |
| "prefix": "ref", |
This file contains hidden or 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
| # Intermediate Challenge | |
| # Create a PowerShell function to get the sum and average of every X number between 1 and a user specified maximum | |
| function Get-IntermediateCountingChallenge { | |
| param( | |
| [int]$Step, | |
| [int]$Max | |
| ) | |
| $NumberArray = for ($i = 1; $i -le $Max; $i = $i + $Step) { $i } |
This file contains hidden or 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-NetworkUsage { | |
| [CmdletBinding(DefaultParameterSetName='Default')] | |
| param( | |
| [string]$ComputerName = $env:COMPUTERNAME, | |
| [int]$WarnSentBytes = 10000, | |
| [Parameter(ParameterSetName='Default')] | |
| [int]$MaxSamples = 5, | |
| [Parameter(ParameterSetName='Default')] | |
| [int]$SampleInterval = 1, | |
| [Parameter(ParameterSetName='Default')] |
This file contains hidden or 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
| $TwoLetterISORegionNames = Get-Culture -ListAvailable | | |
| Foreach-Object { | |
| try { [System.Globalization.RegionInfo]::new($_.Name) } | |
| catch {} | |
| } | | |
| Select-Object -ExpandProperty TwoLetterISORegionName | Sort-Object -Unique | |
| 'US','CA','UK' | % { $_ -in $TwoLetterISORegionNames ? '{0} is valid' -f $_ : '{0} is not valid' -f $_ } |
This file contains hidden or 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 -version 7.0 | |
| class OAuthParameters { | |
| [string]$HttpMethod | |
| [String]$BaseUri | |
| [hashtable]$Query | |
| [System.UriBuilder]$UriBuilder | |
| [string]$UnescapedQueryString | |
| [string]$EscapedQueryString | |
| [object]$Body |