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
# rev 0.2 added more comments, and made the regax a bit more precise. | |
function SplitEmUp { | |
param ( | |
$paramString | |
) | |
#This regex will isolate quoted blocks e.g. " -example )( $quote " | |
# and will identify matching open and close () {} and [] even if nested. | |
$opensAndCloses = @' | |
(?x) # Allow comments and ignore spaces and line breaks in the layaout. | |
^(?> # Start and make the repeating group ‘atomic’. |
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
<# | |
.synopsis | |
Remove Soft-deleted API Management service | |
.description | |
Re-deploying the API management service fails with a message | |
See https://aka.ms/apimsoftdelete | |
That says call the REST API. This does that. | |
#> | |
[cmdletbinding(SupportsShouldProcess=$true,confirmImpact='High' )] | |
param ( |
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
#### | |
#### Proxy function to restore Writing the URI to verbose when calling Invoke-RestMethod | |
#### When calling out of a module -Verbose isn't inherited so the function fiddles verbosepreference as a parameter. | |
Function Invoke-RestMethod { | |
[CmdletBinding(DefaultParameterSetName='StandardMethod', HelpUri='https://go.microsoft.com/fwlink/?LinkID=2096706')] | |
<# | |
.ForwardHelpTargetName Microsoft.PowerShell.Utility\Invoke-RestMethod | |
.ForwardHelpCategory Cmdlet | |
#> | |
param( |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
<?xml version="1.0" encoding="utf-8" ?> | |
<Configuration> | |
<SelectionSets><SelectionSet> | |
<Name>FileSystemTypes</Name> | |
<Types> | |
<TypeName>System.IO.DirectoryInfo</TypeName> | |
<TypeName>System.IO.FileInfo</TypeName> | |
</Types> | |
</SelectionSet></SelectionSets> |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<!-- ******************************************************************* | |
Copyright (c) James O'Neill 2022 - Shared under the MIT License https://mit-license.org/ | |
Allows [consoleColor] to be used like this | |
ps > [ConsoleColor]::Red.Foreground("This is red") | |
ps > [ConsoleColor]::DarkYellow.Background([ConsoleColor]::red.Foreground("This is red on darkyellow")) |
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
<Configuration><ViewDefinitions> | |
<View><Name>MatchInfo</Name> | |
<ViewSelectedBy><TypeName>Microsoft.PowerShell.Commands.MatchInfo</TypeName></ViewSelectedBy> | |
<CustomControl><CustomEntries><CustomEntry><CustomItem><ExpressionBinding><ScriptBlock> | |
#defaults are equivalent to $MatchInfoPreference =@{$Prefix='> '; $MatchVTSeq=$PSStyle.Reverse; $PathVTSeq=''; $NumberVTSeq=''; $ContextVTSeq=''} | |
$ResetVTSeq = $PSStyle.Reset | |
$Prefix = '> ' | |
if (-not $MatchInfoPreference) {$MatchVTSeq = $PSStyle.Reverse } | |
else { | |
$MatchVTSeq = $MatchInfoPreference.MatchVTSeq |
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-Error { | |
[cmdletbinding(DefaultParameterSetName='Newest')] | |
param ( | |
[Parameter(Position = 0, ValueFromPipeline=$true, ParameterSetName= "Error")] | |
[ValidateNotNullOrEmpty()] | |
$InputObject, | |
[Parameter(ParameterSetName = "Newest", ValueFromPipelineByPropertyName = $true)] | |
[Alias('Last')] | |
[ValidateRange(1, [int]::MaxValue)] |
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 binaryout { | |
<# | |
.SYNOPSIS | |
Workaround for PowerShell processing the output of all external programs as strings | |
.DESCRIPTION | |
PowerShell treats any output from an external program as string which should be | |
split whenever it sees LF or CR LF. As a workround this calls the program with | |
Start-Process and redirects standard output to a file - on completion the file | |
is read and sent as a bytestream to the next process. |
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 one {[cmdletbinding()]param() | |
begin {Write-Host "one begins"} end {Write-host "one ends"} | |
process {1,2,3} | |
} | |
function two {param ([parameter(ValueFromPipeline)]$p) | |
begin {Write-Host "two begins"} end {Write-host "two ends"} | |
process { | |
if ($p -eq 2) {$p / 0 } # cause a division by zero error | |
$p | |
} |