From f5c3cfb9b0e990125fa8e159edcad2fbe4ba7469 Mon Sep 17 00:00:00 2001 From: Brian Lalonde Date: Sun, 26 Apr 2026 21:40:33 -0700 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=94=A5=20Remove=20ModernConveniences?= =?UTF-8?q?=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Add-Counter.ps1 | 46 ------- Add-DynamicParam.ps1 | 122 ------------------- Add-NoteProperty.ps1 | 112 ----------------- Add-NugetPackage.ps1 | 59 --------- Add-ParameterDefault.ps1 | 72 ----------- Compare-Properties.ps1 | 111 ----------------- ConvertTo-SafeEntities.ps1 | 63 ---------- Copy-Html.ps1 | 49 -------- ForEach-Progress.ps1 | 53 -------- Format-ByteUnits.ps1 | 65 ---------- Format-HtmlDataTable.ps1 | 77 ------------ Format-Permutations.ps1 | 73 ----------- Get-EnumValues.ps1 | 123 ------------------- Get-ModuleScope.ps1 | 54 -------- Get-RandomBytes.ps1 | 33 ----- Get-TypeAccelerators.ps1 | 169 -------------------------- Import-Variables.ps1 | 66 ---------- Invoke-WindowsPowerShell.ps1 | 106 ---------------- Merge-PSObject.ps1 | 88 -------------- Read-Choice.ps1 | 75 ------------ Remove-ParameterDefault.ps1 | 62 ---------- Set-ParameterDefault.ps1 | 83 ------------- Stop-ThrowError.ps1 | 133 -------------------- Test-Administrator.ps1 | 20 --- Test-NoteProperty.ps1 | 31 ----- Test-Range.ps1 | 56 --------- Test-Variable.ps1 | 83 ------------- Uninstall-OldModules.ps1 | 47 ------- Update-Modules.ps1 | 20 --- Use-ProgressView.ps1 | 22 ---- Use-ReasonableDefaults.ps1 | 105 ---------------- Write-CallInfo.ps1 | 9 -- Write-Info.ps1 | 41 ------- Write-VisibleString.ps1 | 78 ------------ test/Add-Counter.Tests.ps1 | 35 ------ test/Add-DynamicParam.Tests.ps1 | 68 ----------- test/Add-NoteProperty.Tests.ps1 | 33 ----- test/Add-ParameterDefault.Tests.ps1 | 30 ----- test/Add-ScopeLevel.Tests.ps1 | 26 ---- test/Compare-Properties.Tests.ps1 | 28 ----- test/ConvertTo-SafeEntities.Tests.ps1 | 32 ----- test/Copy-Html.Tests.ps1 | 36 ------ test/Format-ByteUnits.Tests.ps1 | 63 ---------- 43 files changed, 2757 deletions(-) delete mode 100644 Add-Counter.ps1 delete mode 100644 Add-DynamicParam.ps1 delete mode 100644 Add-NoteProperty.ps1 delete mode 100644 Add-NugetPackage.ps1 delete mode 100644 Add-ParameterDefault.ps1 delete mode 100644 Compare-Properties.ps1 delete mode 100644 ConvertTo-SafeEntities.ps1 delete mode 100644 Copy-Html.ps1 delete mode 100644 ForEach-Progress.ps1 delete mode 100644 Format-ByteUnits.ps1 delete mode 100644 Format-HtmlDataTable.ps1 delete mode 100644 Format-Permutations.ps1 delete mode 100644 Get-EnumValues.ps1 delete mode 100644 Get-ModuleScope.ps1 delete mode 100644 Get-RandomBytes.ps1 delete mode 100644 Get-TypeAccelerators.ps1 delete mode 100644 Import-Variables.ps1 delete mode 100644 Invoke-WindowsPowerShell.ps1 delete mode 100644 Merge-PSObject.ps1 delete mode 100644 Read-Choice.ps1 delete mode 100644 Remove-ParameterDefault.ps1 delete mode 100644 Set-ParameterDefault.ps1 delete mode 100644 Stop-ThrowError.ps1 delete mode 100644 Test-Administrator.ps1 delete mode 100644 Test-NoteProperty.ps1 delete mode 100644 Test-Range.ps1 delete mode 100644 Test-Variable.ps1 delete mode 100644 Uninstall-OldModules.ps1 delete mode 100644 Update-Modules.ps1 delete mode 100644 Use-ProgressView.ps1 delete mode 100644 Use-ReasonableDefaults.ps1 delete mode 100644 Write-CallInfo.ps1 delete mode 100644 Write-Info.ps1 delete mode 100644 Write-VisibleString.ps1 delete mode 100644 test/Add-Counter.Tests.ps1 delete mode 100644 test/Add-DynamicParam.Tests.ps1 delete mode 100644 test/Add-NoteProperty.Tests.ps1 delete mode 100644 test/Add-ParameterDefault.Tests.ps1 delete mode 100644 test/Add-ScopeLevel.Tests.ps1 delete mode 100644 test/Compare-Properties.Tests.ps1 delete mode 100644 test/ConvertTo-SafeEntities.Tests.ps1 delete mode 100644 test/Copy-Html.Tests.ps1 delete mode 100644 test/Format-ByteUnits.Tests.ps1 diff --git a/Add-Counter.ps1 b/Add-Counter.ps1 deleted file mode 100644 index 86e94409..00000000 --- a/Add-Counter.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -<# -.SYNOPSIS -Adds an incrementing integer property to each pipeline object. - -.DESCRIPTION -If you want to add a quick index property to objects in a pipeline, this does that. - -.INPUTS -System.Management.Automation.PSObject item to add an index property to. - -.OUTPUTS -System.Management.Automation.PSObject with the added index property. - -.FUNCTIONALITY -PowerShell - -.LINK -Add-Member - -.EXAMPLE -Get-PSProvider |Add-Counter Position |select Name,Position - -Name Position ----- -------- -Registry 1 -Alias 2 -Environment 3 -FileSystem 4 -Function 5 -Variable 6 -Certificate 7 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([psobject])] Param( -# The name of the property to add. -[Parameter(Position=0)][string] $PropertyName = 'Counter', -# The starting number to count from. -[Parameter(Position=1)][int] $InitialValue = 1, -# The object to add the property to. -[Parameter(Mandatory=$true,ValueFromPipeline=$true)][psobject] $InputObject, -# Overwrites a property if one with the same name already exists. -[switch] $Force -) -Begin { $i = $InitialValue } -Process { Add-Member $PropertyName ($i++) -InputObject $InputObject -PassThru -Force:$Force } diff --git a/Add-DynamicParam.ps1 b/Add-DynamicParam.ps1 deleted file mode 100644 index 05595add..00000000 --- a/Add-DynamicParam.ps1 +++ /dev/null @@ -1,122 +0,0 @@ -<# -.SYNOPSIS -Adds a dynamic parameter to a script, within a DynamicParam block. - -.DESCRIPTION -Adding dynamic parameters is a complex process, this attempts to simplify that. - -.INPUTS -System.Object[] a list of possible values for this parameter to validate against. - -.FUNCTIONALITY -PowerShell - -.EXAMPLE -DynamicParam { Add-DynamicParam.ps1 Path string -Mandatory; $DynamicParams } Process { Import-Variables.ps1 $PSBoundParameters; ... } -#> - -#Requires -Version 3 -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseProcessBlockForPipelineCommand','', -Justification='This script uses $input within an End block.')] -[CmdletBinding()][OutputType([void])] Param( -# The name of the parameter. -[Parameter(Position=0,Mandatory=$true)][string] $Name, -# The data type of the parameter. -[Parameter(Position=1)][type] $Type, -# The position of the parameter when not specifying the parameter names. -[int] $Position = -2147483648, -# The name of the set of parameters this parameter belongs to. -[string[]] $ParameterSetName = '__AllParameterSets', -# Alternate names for the parameter. -[string[]] $Alias, -<# -The valid number of values for a parameter that accepts a collection. -A range can be specified with a list of two integers. -#> -[Alias('Count')][ValidateCount(1,2)][int[]] $ValidateCount, -# Valid root drive(s) for parameters that accept paths. -[string[]] $ValidateDrive, -<# -The valid length for a string parameter. -A range can be specified with a list of two integers. -#> -[Alias('Length')][ValidateCount(1,2)][int[]] $ValidateLength, -# The valid regular expression pattern to match for a string parameter. -[Alias('Match','Pattern')][string] $ValidatePattern, -# The valid range of values for a numeric parameter. -[Alias('Range')][ValidateCount(2,2)][int[]] $ValidateRange, -<# -A script block to validate a parameter's value. -Any true result will validate the value, any false result will reject it. -#> -[ScriptBlock] $ValidateScript, -<# -A set of valid values for the parameter. -This will enable tab-completion. -#> -[Parameter(ValueFromPipeline=$true)][Alias('Values')][object[]] $ValidateSet, -# Requires parameter to be non-null. -[switch] $NotNull, -# Requires parameter to be non-null and non-empty. -[switch] $NotNullOrEmpty, -# Requires the parameter value to be Trusted data. -[switch] $TrustedData, -# Requires a path parameter to be on a User drive. -[switch] $UserDrive, -# Indicates a required parameter. -[Alias('Required')][switch] $Mandatory, -# Indicates a parameter that can accept values from the pipeline. -[Alias('Pipeline')][switch] $ValueFromPipeline, -<# -Indicates a parameter that can accept values from the pipeline by matching the property name of pipeline objects to the -parameter name or alias. -#> -[Alias('PipelineProperties','PipeName')][switch] $ValueFromPipelineByPropertyName, -# Indicates that the parameter will include any following positional parameters. -[Alias('RemainingArgs')][switch] $ValueFromRemainingArguments -) -End -{ - $DynamicParams = Get-Variable DynamicParams -Scope 1 -ErrorAction Ignore - if($null -eq $DynamicParams) - { - $DynamicParams = New-Object Management.Automation.RuntimeDefinedParameterDictionary - $DynamicParams = New-Variable DynamicParams $DynamicParams -Scope 1 -PassThru - } - $atts = New-Object Collections.ObjectModel.Collection[System.Attribute] - foreach($set in $ParameterSetName) - { - $att = New-Object Management.Automation.ParameterAttribute -Property @{ - Position = $Position - ParameterSetName = $ParameterSetName - Mandatory = $Mandatory - ValueFromPipeline = $ValueFromPipeline - ValueFromPipelineByPropertyName = $ValueFromPipelineByPropertyName - ValueFromRemainingArguments = $ValueFromRemainingArguments - } - $atts.Add($att) - } - if($Alias) {$atts.Add((New-Object Management.Automation.AliasAttribute $Alias))} - if($NotNull) {$atts.Add((New-Object Management.Automation.ValidateNotNullAttribute))} - if($NotNullOrEmpty) {$atts.Add((New-Object Management.Automation.ValidateNotNullOrEmptyAttribute))} - if($ValidateCount) - { - if($ValidateCount.Length -eq 1) {$ValidateCount += $ValidateCount[0]} - $atts.Add((New-Object Management.Automation.ValidateCountAttribute $ValidateCount)) - } - if($ValidateDrive) {$atts.Add((New-Object Management.Automation.ValidateDriveAttribute $ValidateDrive))} - if($ValidateLength) - { - if($ValidateLength.Length -eq 1) {$ValidateLength += $ValidateLength[0]} - $atts.Add((New-Object Management.Automation.ValidateLengthAttribute $ValidateLength)) - } - if($ValidatePattern) {$atts.Add((New-Object Management.Automation.ValidatePatternAttribute $ValidatePattern))} - if($ValidateRange) {$atts.Add((New-Object Management.Automation.ValidateRangeAttribute $ValidateRange))} - if($ValidateScript) {$atts.Add((New-Object Management.Automation.ValidateScriptAttribute $ValidateScript))} - if($input) {$ValidateSet = $input} - if($ValidateSet) {$atts.Add((New-Object Management.Automation.ValidateSetAttribute $ValidateSet))} - if($TrustedData) {$atts.Add((New-Object Management.Automation.ValidateTrustedDataAttribute))} - if($UserDrive) {$atts.Add((New-Object Management.Automation.ValidateUserDriveAttribute))} - $param = New-Object Management.Automation.RuntimeDefinedParameter ($Name,$Type,$atts) - $DynamicParams.Value.Add($Name,$param) -} diff --git a/Add-NoteProperty.ps1 b/Add-NoteProperty.ps1 deleted file mode 100644 index aa813f7d..00000000 --- a/Add-NoteProperty.ps1 +++ /dev/null @@ -1,112 +0,0 @@ -<# -.SYNOPSIS -Adds a NoteProperty to a PSObject, calculating the value with the object in context. - -.DESCRIPTION -The Add-Member cmdlet can either add a property with a single static value to objects -in the pipeline, or add a script property to objects which executes each time it's used. - -This adds a static value to each object, but calculated from each object. - -.INPUTS -System.Management.Automation.PSObject item to add a note property to. - -.OUTPUTS -System.Management.Automation.PSObject with the added note property. - -.FUNCTIONALITY -Properties - -.LINK -Add-Member - -.EXAMPLE -Get-ChildItem Get-*.ps1 |Add-NoteProperty.ps1 Size {Format-ByteUnits.ps1 $Length -Precision 1} -Properties Length -PassThru |Format-Table Size,Name -AutoSize - -| Size Name -| ---- ---- -| 8.1KB Get-AspNetEvents.ps1 -| 840 Get-AssemblyFramework.ps1 -|38.3KB Get-CharacterDetails.ps1 -| 1.1KB Get-ClassicAspEvents.ps1 -| 1.3KB Get-CommandPath.ps1 -| 1.2KB Get-ConfigConnectionStringBuilders.ps1 -| 4.9KB Get-ConsoleColors.ps1 -| 1.4KB Get-ContentSecurityPolicy.ps1 -| 617 Get-Dns.ps1 -| 2.4KB Get-EnumValues.ps1 -| 6KB Get-IisLog.ps1 -| 1.9KB Get-LibraryVulnerabilityInfo.ps1 -| 2.7KB Get-DotNetFrameworkVersions.ps1 -| 969 Get-RepoName.ps1 -| 3.3KB Get-SslDetails.ps1 -| 4.2KB Get-SystemDetails.ps1 -| 6.8KB Get-TypeAccelerators.ps1 -| 1.2KB Get-XmlNamespaces.ps1 - -.EXAMPLE -Get-ChildItem Get-*.ps1 |Add-NoteProperty.ps1 @{Size={Format-ByteUnits.ps1 $_.Length -Precision 1};Ext={$_ |Split-Path -Extension};Hat='Y'} -PassThru |Format-Table Size,Name,Ext,Hat -AutoSize - -| Size Name Ext Hat -| ---- ---- --- --- -| 928 Get-ADServiceAccountInfo.ps1 .ps1 Y -| 1.9KB Get-ADUserStatus.ps1 .ps1 Y -| 8.1KB Get-AspNetEvents.ps1 .ps1 Y -| 1.1KB Get-AssemblyFramework.ps1 .ps1 Y -| 2.9KB Get-CachedCredential.ps1 .ps1 Y -|34.5KB Get-CharacterDetails.ps1 .ps1 Y -#> - -[CmdletBinding()][OutputType([psobject])] Param( -# The name of the NoteProperty to add to the object. -[Parameter(ParameterSetName='NameValue',Position=0,Mandatory=$true)][string] $Name, -# The expression to use to set the value of the NoteProperty. -[Parameter(ParameterSetName='NameValue',Position=1,Mandatory=$true)][ScriptBlock] $Value, -# A hashtable mapping names of new properties to script blocks generating the values of those properties. -[Parameter(ParameterSetName='NewProperties',Position=0,Mandatory=$true)][hashtable] $NewProperties, -# Properties of the input object to include as variables in the script block scope. -[Alias('Import')][string[]] $Properties = @(), -# The object to add the NoteProperty to. -[Parameter(ValueFromPipeline=$true,Mandatory=$true)][PSObject] $InputObject, -# Returns the object with the NoteProperty added. Normally there is no output. -[switch] $PassThru, -# Overwrite an existing property. -[switch] $Force -) -Process -{ - [psvariable[]] $context = New-Object psvariable _,$InputObject - if($Properties -and $Properties.Length) - { - if($Properties[0] -eq '*') - { - $context += $InputObject.PSObject.Properties | - ForEach-Object {New-Object psvariable $_.Name,$_.Value} - } - else - { - $context += $InputObject.PSObject.Properties | - Where-Object Name -in $Properties | - ForEach-Object {New-Object psvariable $_.Name,$_.Value} - } - } - switch($PSCmdlet.ParameterSetName) - { - NameValue - { - $v = $Value.InvokeWithContext($null,$context,$null) |Select-Object -First 1 - Add-Member -InputObject $InputObject -MemberType NoteProperty -Name $Name ` - -Value $v -PassThru:$PassThru -Force:$Force - } - NewProperties - { - $NewProperties.Keys |ForEach-Object { - $v = $NewProperties[$_] - if($v -is [scriptblock]) {$v = $v.InvokeWithContext($null,$context,$null) |Select-Object -First 1} - Add-Member -InputObject $InputObject -MemberType NoteProperty -Name $_ -Value $v -Force:$Force - } - if($PassThru) {Write-Output $InputObject} - } - default {Stop-ThrowError.ps1 'Unknown parameter set' -TargetObject $PSBoundParameters} - } -} diff --git a/Add-NugetPackage.ps1 b/Add-NugetPackage.ps1 deleted file mode 100644 index 8348b567..00000000 --- a/Add-NugetPackage.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -<# -.SYNOPSIS -Loads a NuGet package DLL, downloading as needed. - -.NOTES -Install-Package isn't working for arbitrary NuGet packages, so this allows us access the main DLL -assembly and types within the package. - -.FUNCTIONALITY -PowerShell - -.LINK -https://www.nuget.org/ - -.EXAMPLE -Add-NugetPackage.ps1 Serilog ; [Serilog.Core.Logger]::None -is [Serilog.ILogger] - -True -#> - -#Requires -Version 7 -[CmdletBinding()] Param( -# The name of the NuGet package to load. -[Parameter(Position=0,Mandatory=$true)][string] $PackageName, -# Use this type name to test whether the package was loaded. -[Parameter(Position=1)][string] $TypeName -) -Begin -{ - $Script:BaseDir = Join-Path ($IsWindows ? $env:LOCALAPPDATA : ($env:XDG_CACHE_HOME ?? "$(Resolve-Path ~/.cache)")) PSNuget - $Script:BinDir = Join-Path $BaseDir bin - $Script:LibDir = Join-Path $BaseDir lib - if(!(Test-Path $BinDir -Type Container)) {New-Item $BinDir -Type Directory |Out-Null} - if(!(Test-Path $LibDir -Type Container)) {New-Item $LibDir -Type Directory |Out-Null} -} -Process -{ - try {[void][type]$TypeName; return} catch {} - $dll = Join-Path $BinDir "$PackageName.dll" - if(([System.AppDomain]::CurrentDomain.GetAssemblies() |Where-Object Location -eq $dll)) - { - try {[void][type]$TypeName} catch {Write-Warning "'$PackageName' was loaded, but type '$TypeName' was not found: $_"} - return - } - if(Test-Path $dll -Type Leaf) - { - Add-Type -Path $dll - try {[void][type]$TypeName} catch {Write-Warning "'$PackageName' was found and loaded, but type '$TypeName' was not found: $_"} - return - } - $nuget = Join-Path $LibDir "$PackageName.nuget" - if(!(Test-Path $nuget -Type Leaf)) {Invoke-WebRequest "https://www.nuget.org/api/v2/package/$PackageName" -OutFile $nuget} - $dir = Join-Path $LibDir $PackageName - if(!(Test-Path $dir -Type Container)) {Expand-Archive -Path $nuget -DestinationPath $dir} - $libdll = Get-ChildItem $dir -Filter *.dll -Recurse |Select-Object -Last 1 - New-Item -Type HardLink -Path $dll -Value $libdll |Out-Null - Add-Type -Path $dll - try {[void][type]$TypeName} catch {Write-Warning "Unable to find type '$TypeName': $_"} -} diff --git a/Add-ParameterDefault.ps1 b/Add-ParameterDefault.ps1 deleted file mode 100644 index 18a0d3e3..00000000 --- a/Add-ParameterDefault.ps1 +++ /dev/null @@ -1,72 +0,0 @@ -<# -.SYNOPSIS -Appends or creates a value to use for the specified cmdlet parameter to use when one is not specified. - -.DESCRIPTION -This conveniently sets cmdlet defaults. - -.FUNCTIONALITY -Parameters - -.INPUTS -System.Object containing a default value to include. - -.LINK -Add-ScopeLevel.ps1 - -.LINK -Stop-ThrowError.ps1 - -.LINK -Get-Command - -.LINK -about_Scopes - -.EXAMPLE -Add-ParameterDefault.ps1 epcsv nti $true -Scope Global - -Establishes that the -NoTypeInformation param of the Export-Csv cmdlet will be true if not otherwise specified, -globally for the PowerShell session. - -.EXAMPLE -Add-ParameterDefault.ps1 Select-Xml Namespace @{svg = 'http://www.w3.org/2000/svg'} - -Adds the SVG namespace to any existing namespaces used by Select-Xml when none are given explicitly. -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([void])] Param( -# The name of a cmdlet, function, script, or alias to include a default parameter value for. -[Parameter(Position=0,Mandatory=$true)][ValidateNotNullOrEmpty()][Alias('CmdletName')][string] $CommandName, -# The name or alias of the parameter to include a default value for. -[Parameter(Position=1,Mandatory=$true)][ValidateNotNullOrEmpty()][string] $ParameterName, -# The value to include as a default. -[Parameter(Position=2,Mandatory=$true,ValueFromPipeline=$true)] $Value, -# The scope of this default. -[string] $Scope = 'Local' -) -Begin -{ - $Scope = Add-ScopeLevel.ps1 $Scope - $cmd = Get-Command $CommandName -ErrorAction Ignore - if(!$cmd) {Stop-ThrowError.ps1 "Could not find command '$CommandName'" -Argument CommandName} - if($cmd.CommandType -eq 'Alias') {$cmd = Get-Command $cmd.ResolvedCommandName} - if($cmd.CommandType -notin 'Cmdlet','ExternalScript','Function','Script') - {Stop-ThrowError.ps1 "Command '$CommandName' ($($cmd.CommandType)) not supported" -Argument CommandName} - $name = - try {"$($cmd.Name):$($cmd.ResolveParameter($ParameterName).Name)"} - catch {Stop-ThrowError.ps1 "Could not find parameter '$ParameterName' for cmdlet '$CommandName'" -Argument ParameterName} - $defaults = Get-Variable PSDefaultParameterValues -Scope $Scope -ErrorAction Ignore - if(!$defaults) - { - Set-Variable PSDefaultParameterValues @{} -Scope $Scope - $defaults = Get-Variable PSDefaultParameterValues -Scope $Scope -ErrorAction Ignore - } -} -Process -{ - Write-Verbose "Setting default parameter '$name' to '$Value'" - if($defaults.Value.ContainsKey($name)) {$defaults.Value[$name] += $Value} - else {$defaults.Value[$name] = $Value} -} diff --git a/Compare-Properties.ps1 b/Compare-Properties.ps1 deleted file mode 100644 index f3a90d0e..00000000 --- a/Compare-Properties.ps1 +++ /dev/null @@ -1,111 +0,0 @@ -<# -.SYNOPSIS -Compares the properties of two objects. - -.INPUTS -System.Management.Automation.PSObject with properties to compare. - -.OUTPUTS -System.Management.Automation.PSCustomObject for each relevant property comparison, -with these fields: - -* PropertyName -* Reference -* Value -* Difference -* DifferentValue - -.FUNCTIONALITY -Properties - -.LINK -https://docs.microsoft.com/dotnet/api/system.management.automation.psmemberset - -.EXAMPLE -Compare-Properties.ps1 (Get-PSProvider variable) (Get-PSProvider alias) - -PropertyName : ImplementingType -Reference : True -Value : Microsoft.PowerShell.Commands.VariableProvider -Difference : True -DifferentValue : Microsoft.PowerShell.Commands.AliasProvider - -PropertyName : Name -Reference : True -Value : Variable -Difference : True -DifferentValue : Alias - -PropertyName : Drives -Reference : True -Value : {Variable} -Difference : True -DifferentValue : {Alias} -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([Management.Automation.PSCustomObject])] Param( -# The base object to compare properties to. -[Parameter(Position=0)][PSObject] $ReferenceObject, -# The second object to compare the properties of. -[Parameter(Position=1,ValueFromPipeline=$true)][PSObject] $DifferenceObject, -# Indicates different values should be suppressed. -[switch] $ExcludeDifferent, -# Indicates equal values should be included. -[switch] $IncludeEqual -) - -Begin -{ - [string[]] $referenceProperties = @() - $referenceProperties += $ReferenceObject.PSObject.Properties.Match('*','Properties') |Select-Object -ExpandProperty Name -} -Process -{ - [string[]] $differenceProperties = @() - $differenceProperties += $DifferenceObject.PSObject.Properties.Match('*','Properties') |Select-Object -ExpandProperty Name - foreach($property in $referenceProperties) - { - $referenceValue = $ReferenceObject.$property - if(!$DifferenceObject.PSObject.Properties.Match($property,'Properties').Count) - { - if(!$ExcludeDifferent) - { - [pscustomobject]@{ - PropertyName = $property - Reference = $true - Value = $referenceValue - Difference = $false - DifferentValue = $null - } - } - } - else - { - $differentValue = $DifferenceObject.$property - $comparison = [pscustomobject]@{ - PropertyName = $property - Reference = $true - Value = $referenceValue - Difference = $true - DifferentValue = $differentValue - } - if($referenceValue -eq $differentValue) {if($IncludeEqual) {$comparison}} - elseif(!$ExcludeDifferent) {$comparison} - } - } - if(!$ExcludeDifferent) - { - foreach($property in $differenceProperties | - Where-Object {!$ReferenceObject.PSObject.Properties.Match($_,'Properties').Count}) - { - [pscustomobject]@{ - PropertyName = $property - Reference = $false - Value = $null - Difference = $true - DifferentValue = $DifferenceObject.$property - } - } - } -} diff --git a/ConvertTo-SafeEntities.ps1 b/ConvertTo-SafeEntities.ps1 deleted file mode 100644 index f410e9c3..00000000 --- a/ConvertTo-SafeEntities.ps1 +++ /dev/null @@ -1,63 +0,0 @@ -<# -.SYNOPSIS -Encode text as XML/HTML, escaping all characters outside 7-bit ASCII. - -.INPUTS -System.String of HTML or XML data to encode. - -.OUTPUTS -System.String of HTML or XML data, encoded. - -.FUNCTIONALITY -Unicode - -.LINK -https://docs.microsoft.com/dotnet/api/system.char.issurrogatepair - -.LINK -https://docs.microsoft.com/dotnet/api/system.char.converttoutf32 - -.EXAMPLE -"$([char]0xD83D)$([char]0xDCA1) File $([char]0x2192) Save" |ConvertTo-SafeEntities.ps1 - -💡 File → Save - -This shows a UTF-16 surrogate pair, used internally by .NET strings, which is combined -into a single entity reference. - -.EXAMPLE -"ETA: $([char]0xBD) hour" |ConvertTo-SafeEntities.ps1 - -ETA: ½ hour -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string])] Param( -<# -An HTML or XML string that may include emoji or other Unicode characters outside -the 7-bit ASCII range. -#> -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][string] $InputObject, -# Indicates that markdown characters should also be escaped. -[switch] $IncludeMarkupChars -) -Process -{ - if($IncludeMarkupChars) {return [Text.Encodings.Web.HtmlEncoder]::Default.Encode($InputObject)} - else - { - [char[]] $chars = - for ($i = 0; $i -lt $InputObject.Length; $i++) - { - [int] $c = [char]$InputObject[$i] - Write-Verbose "$i : $c" - if([char]::IsSurrogatePair($InputObject,$i)) - { ('&#x{0:X};' -f [char]::ConvertToUtf32($InputObject,$i++)).GetEnumerator() } - elseif(0x7F -lt $c) - { ('&#x{0:X};' -f $c).GetEnumerator() } - else - { [char]$c } - } - return New-Object String $chars,0,$chars.Length - } -} diff --git a/Copy-Html.ps1 b/Copy-Html.ps1 deleted file mode 100644 index ff3e38b9..00000000 --- a/Copy-Html.ps1 +++ /dev/null @@ -1,49 +0,0 @@ -<# -.SYNOPSIS -Copies objects as an HTML table. - -.INPUTS -System.Management.Automation.PSObject to be turned into a table row. - -.LINK -Format-HtmlDataTable.ps1 - -.LINK -ConvertTo-SafeEntities.ps1 - -.LINK -Invoke-WindowsPowerShell.ps1 - -.EXAMPLE -Get-PSDrive |Copy-Html.ps1 Name,Description - -Copies an HTML table with two columns to the clipboard as formatted text -that can be pasted into emails or other formatted documents. -#> - -#Requires -Version 7 -[CmdletBinding()][OutputType([void])] Param( -# Columns to include in the copied table. -[Parameter(Position=0)][array] $Property, -# The objects to turn into table rows. -[Parameter(ValueFromPipeline=$true)][psobject] $InputObject -) -Begin -{ - $data = @() -} -Process -{ - $data += $InputObject -} -End -{ - $data | - Select-Object -Property $Property | - ConvertTo-Html -Fragment | - Format-HtmlDataTable.ps1 | - ConvertTo-SafeEntities.ps1 | - Out-String | - Set-Clipboard - Invoke-WindowsPowerShell.ps1 { Get-Clipboard |Set-Clipboard -AsHtml } -} diff --git a/ForEach-Progress.ps1 b/ForEach-Progress.ps1 deleted file mode 100644 index 3bf8b52c..00000000 --- a/ForEach-Progress.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -<# -.SYNOPSIS -Performs an operation against each item in a collection of input objects, with a progress bar. - -.INPUTS -System.Management.Automation.PSObject to process. - -.FUNCTIONALITY -PowerShell - -.EXAMPLE -1..10 |ForEach-Progress.ps1 -Activity 'Processing' {"$_"} {Write-Host "item: $_"; sleep 2} - -Provides a progress indicator for a script block. - -.EXAMPLE -1..10 |ForEach-Progress.ps1 |foreach {Write-Host "item: $_"; sleep 2} - -Same as previous example, but adds a progress indicator within an existing pipeline. -#> - -#Requires -Version 3 -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseProcessBlockForPipelineCommand','', -Justification='This script uses $input within an End block.')] -[CmdletBinding()] Param( -# The progress title text to display. -[Parameter(Position=0)][string] $Activity = 'Processing', -# A script block to generate status text from each $PSItem ($_). -[Parameter(Position=1)][scriptblock] $Status = {$_ |ConvertTo-Json -Compress}, -# A script block to execute for each $PSItem ($_). -[Parameter(Position=2)][scriptblock] $Process = {$_}, -# An item to process. -[Parameter(Mandatory=$true,ValueFromPipeline=$true)][psobject] $InputObject -) -End -{ - [psobject[]] $values = $input - if(!$values) {$values = @($InputObject)} - $i,$max,$id = 0,($values.Length/100),(Get-Random) - try - { - foreach($value in $values) - { - [Collections.Generic.List[psvariable]] $ctx = New-Object PSVariable _,$value - $itemstatus = $Status.InvokeWithContext($null,$ctx,$value) |Select-Object -First 1 - if(!$itemstatus) {$itemstatus = '?'} - Write-Progress $Activity $itemstatus -Id $id -PercentComplete ($i++/$max) - [Collections.Generic.List[psvariable]] $ctx = New-Object PSVariable _,$value - $Process.InvokeWithContext($null,$ctx,$value) - } - } - finally {Write-Progress $Activity -Id $id -Completed} -} diff --git a/Format-ByteUnits.ps1 b/Format-ByteUnits.ps1 deleted file mode 100644 index dce14a97..00000000 --- a/Format-ByteUnits.ps1 +++ /dev/null @@ -1,65 +0,0 @@ -<# -.SYNOPSIS -Converts bytes to largest possible units, to improve readability. - -.INPUTS -System.Numerics.BigInteger representing a number of bytes. - -.OUTPUTS -System.String containing the number of bytes scaled to fit the appropriate units. - -.FUNCTIONALITY -PowerShell - -.LINK -http://en.wikipedia.org/wiki/Binary_prefix - -.LINK -http://physics.nist.gov/cuu/Units/binary.html - -.EXAMPLE -Format-ByteUnits 65536 - -64KB - -.EXAMPLE -Format-ByteUnits 9685059 -dot 1 -si - -9.2 MiB - -.EXAMPLE -ls *.log |measure -sum Length |select -exp Sum |Format-ByteUnits -dot 2 -si - -302.39 MiB -#> - -#Requires -Version 2 -[CmdletBinding()][OutputType([string])] Param( -# The number of bytes to express in larger units. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][bigint]$Bytes, -<# -The maximum number of digits after the decimal to keep. -The default is 16 (the maximum). -#> -[Alias('Digits','dot')][ValidateRange(0,16)][byte]$Precision = 16, -<# -Displays unambiguous SI units (with a space). -By default, native PowerShell units are used -(without a space, to allow round-tripping the value, -though there may be significant rounding loss depending on precision). -#> -[Alias('si')][switch]$UseSI -) -Process -{ - $units = - if($UseSI) {[ordered]@{1073741824PB=' YiB'; 1048576PB=' ZiB'; 1024PB=' EiB'; - 1PB=' PiB';1TB=' TiB';1GB=' GiB';1MB=' MiB';1KB=' KiB';1=' B'}} - else {[ordered]@{1PB= 'PB'; 1TB= 'TB'; 1GB= 'GB'; 1MB= 'MB'; 1KB= 'KB'}} - $pfmt = '#'*$Precision - foreach($magnitude in $units.Keys) - { - if($Bytes -ge $magnitude) {return "{0:0.$pfmt}{1}" -f ([double]$Bytes / $magnitude),$units.$magnitude} - } - return $Bytes -} diff --git a/Format-HtmlDataTable.ps1 b/Format-HtmlDataTable.ps1 deleted file mode 100644 index 95b4692b..00000000 --- a/Format-HtmlDataTable.ps1 +++ /dev/null @@ -1,77 +0,0 @@ -<# -.SYNOPSIS -Right-aligns numeric data in an HTML table for emailing, and optionally zebra-stripes &c. - -.INPUTS -System.String containing an HTML table, as produced by ConvertTo-Html. - -.OUTPUTS -System.String containing the data-formatted HTML table. - -.NOTES -Assumes only one element per string piped in, as produced by ConvertTo-Html. - -.LINK -ConvertTo-Html - -.LINK -https://www.w3.org/Bugs/Public/show_bug.cgi?id=18026 - -.EXAMPLE -Invoke-Sqlcmd "..." |ConvertFrom-DataRow.ps1 |ConvertTo-Html |Format-HtmlDataTable.ps1 - -Runs the query, parses each row into an HTML row, then fixes the alignment of numeric cells. - -.EXAMPLE -$rows |ConvertTo-Html -Fragment |Format-HtmlDataTable.ps1 'Products' '#F99' '#FFF' - -Renders DataRows as an HTML table, right-aligns numeric cells, then adds a caption ("Products"), -and alternates the rows between pale yellow and white. -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string])] Param( -# The HTML table caption, a label for the table. -[Parameter(Position=0)][string]$Caption, -# The background CSS value for odd rows. -[Parameter(Position=1)][string]$OddRowBackground, -# The background CSS value for even rows. -[Parameter(Position=2)][string]$EvenRowBackground, -# Any table attributes desired (cellpadding, cellspacing, style, &c.). -[Alias('TableAtts')][string]$TableAttributes = 'cellpadding="2" cellspacing="0" style="font:x-small ''Lucida Console'',monospace"', -# HTML attributes for the table caption. -[Alias('CaptionAtts','CapAtts')][string]$CaptionAttributes = 'style="font:bold small serif;border:1px inset #DDD;padding:1ex 0;background:#FFF"', -# Applies a standard .NET formatting pattern to numbers, such as N or '#,##0.000;(#,##0.000);zero'. -[string]$NumericFormat, -# The HTML table data to be piped in. -[Parameter(ValueFromPipeline=$true)][string]$Html -) -Begin -{ - $odd = $false - if($OddRowBackground) {$OddRowBackground = [Security.SecurityElement]::Escape($OddRowBackground)} - if($EvenRowBackground) {$EvenRowBackground = [Security.SecurityElement]::Escape($EvenRowBackground)} -} -Process -{ - $odd = !$odd - $Html = - if($NumericFormat) - { - [regex]::Replace($Html,'([-$]?)(\d+(?:,\d{3})*(?:\.\d+)?)', - { - Param($match) - '',$match.Groups[1].Value, - ([decimal]$match.Groups[2].Value).ToString($NumericFormat),'' -join '' - }) - } - else {$Html -replace '([-$]?\d+(?:,\d{3})*(?:\.\d+)?)','$1'} - if($Html -like '**') - { - if($Caption) {$Html = $Html -replace '
',"
"} - if($TableAttributes) {$Html = $Html -replace '
$([Security.SecurityElement]::Escape($Caption))
',"
"} - } - if($odd -and $OddRowBackground) {$Html -replace '^',""} - elseif(!$odd -and $EvenRowBackground) {$Html -replace '^',""} - else {$Html} -} diff --git a/Format-Permutations.ps1 b/Format-Permutations.ps1 deleted file mode 100644 index 97c87ffd..00000000 --- a/Format-Permutations.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -<# -.SYNOPSIS -Builds format strings using every combination of elements from multiple arrays. - -.OUTPUTS -System.String list of all combinations - -.FUNCTIONALITY -PowerShell - -.LINK -https://social.technet.microsoft.com/wiki/contents/articles/7855.powershell-using-the-f-format-operator.aspx - -.EXAMPLE -Format-Permutations.ps1 'srv-{0}-{1:00}' 'dev','test','stage','live' (1..4) - -srv-dev-01 -srv-dev-02 -srv-dev-03 -srv-dev-04 -srv-test-01 -srv-test-02 -srv-test-03 -srv-test-04 -srv-stage-01 -srv-stage-02 -srv-stage-03 -srv-stage-04 -srv-live-01 -srv-live-02 -srv-live-03 -srv-live-04 - -.EXAMPLE -Format-Permutations.ps1 '{0}{1}{2}{3}' (0,1) (0,1) (0,1) (0,1) - -0000 -0001 -0010 -0011 -0100 -0101 -0110 -0111 -1000 -1001 -1010 -1011 -1100 -1101 -1110 -1111 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string[]])] Param( -# A standard .NET format string as used with the PowerShell -f operator. -[Parameter(Position=0,Mandatory=$true)][string] $Format, -<# -A list of lists to put together in all combinations (a Cartesian cross-product) and -format with the supplied format string. -#> -[Parameter(Position=1,Mandatory=$true,ValueFromRemainingArguments=$true)][ValidateNotNull()][object[][]] $InputObject -) - -function Format-Permute([string]$Format,[object[][]]$NextValues,[object[]]$Values = @()) -{ - Write-Verbose "'$Format' -f $NextValues ($Values)" - if($NextValues.Length -eq 1) {$NextValues[0] |ForEach-Object {$Format -f ($Values+$_)}} - else {$NextValues[0] |ForEach-Object {Format-Permute $Format $NextValues[1..($NextValues.Length-1)] ($Values+$_)}} -} - -Format-Permute $Format $InputObject diff --git a/Get-EnumValues.ps1 b/Get-EnumValues.ps1 deleted file mode 100644 index 48c86521..00000000 --- a/Get-EnumValues.ps1 +++ /dev/null @@ -1,123 +0,0 @@ -<# -.SYNOPSIS -Returns the possible values of the specified enumeration. - -.INPUTS -System.Type of an Enum to get the values for. - -.OUTPUTS -System.Management.Automation.PSCustomObject with the Value and Name for each defined -value of the Enum. - -.FUNCTIONALITY -PowerShell - -.EXAMPLE -Get-EnumValues Management.Automation.ActionPreference - -|Value Name -|----- ---- -| 0 SilentlyContinue -| 1 Stop -| 2 Continue -| 3 Inquire -| 4 Ignore -| 5 Suspend - -.EXAMPLE -Get-EnumValues ConsoleColor - -|Value Name -|----- ---- -| 0 Black -| 1 DarkBlue -| 2 DarkGreen -| 3 DarkCyan -| 4 DarkRed -| 5 DarkMagenta -| 6 DarkYellow -| 7 Gray -| 8 DarkGray -| 9 Blue -| 10 Green -| 11 Cyan -| 12 Red -| 13 Magenta -| 14 Yellow -| 15 White - -.EXAMPLE -Get-EnumValues.ps1 System.Web.Security.AntiXss.MidCodeCharts - -| Value Name -| ----- ---- -| 0 None -| 1 GreekExtended -| 2 GeneralPunctuation -| 4 SuperscriptsAndSubscripts -| 8 CurrencySymbols -| 16 CombiningDiacriticalMarksForSymbols -| 32 LetterlikeSymbols -| 64 NumberForms -| 128 Arrows -| 256 MathematicalOperators -| 512 MiscellaneousTechnical -| 1024 ControlPictures -| 2048 OpticalCharacterRecognition -| 4096 EnclosedAlphanumerics -| 8192 BoxDrawing -| 16384 EthiopicExtended -| 16384 EthiopicExtended -| 32768 GeometricShapes -| 65536 MiscellaneousSymbols -| 131072 Dingbats -| 262144 MiscellaneousMathematicalSymbolsA -| 524288 SupplementalArrowsA -| 1048576 BraillePatterns -| 2097152 SupplementalArrowsB -| 4194304 MiscellaneousMathematicalSymbolsB -| 8388608 SupplementalMathematicalOperators -| 16777216 MiscellaneousSymbolsAndArrows -| 33554432 Glagolitic -| 67108864 LatinExtendedC -|134217728 Coptic -|268435456 GeorgianSupplement -|536870912 Tifinagh -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([Management.Automation.PSCustomObject])] Param( -# The enumeration type name. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][Type]$Type -) -Process -{ - $description = @{} - $names = [enum]::GetNames($Type) - foreach($name in $names) - { - $Type.GetMember($name)[0].GetCustomAttributes([ComponentModel.DescriptionAttribute], $false) | - ForEach-Object {$description[$name] = $_.Description} - } - if($description.Values |Where-Object {$_}) - { - foreach($name in $names) - { - [pscustomobject]@{ - Value = [int][enum]::Parse($Type,$name) - Name = $name - Description = $description[$name] - } - } - } - else - { - foreach($name in $names) - { - [pscustomobject]@{ - Value = [int][enum]::Parse($Type,$name) - Name = $name - } - } - } -} diff --git a/Get-ModuleScope.ps1 b/Get-ModuleScope.ps1 deleted file mode 100644 index a1e84a84..00000000 --- a/Get-ModuleScope.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -<# -.SYNOPSIS -Returns the scope of an installed module. - -.FUNCTIONALITY -PowerShell Modules - -.INPUTS -System.Object with a "Name" or "ModuleName" property containing a module name. - -.OUTPUTS -System.Management.Automation.PSObject with the following properties: -* ModuleName: The name of the module. -* Scope: The value "CurrentUser" if the module is found within $HOME\Documents\PowerShell\Modules, "AllUsers" if found anywhere else. - -.EXAMPLE -Get-ModuleScope.ps1 Detextive - -ModuleName Scope ----------- ----- -Detextive CurrentUser - -.EXAMPLE -Get-ModuleScope.ps1 Pester - -ModuleName Scope ----------- ----- -Pester CurrentUser -Pester AllUsers -#> - -#Requires -Version 7 -[CmdletBinding()][OutputType([string])] Param( -# Specifies names or name patterns of modules that this cmdlet gets. Wildcard characters are permitted. -[Parameter(Position=0,ValueFromPipelineByPropertyName=$true)][Alias('ModuleName')][string] $Name = '*' -) -Begin -{ - $UserRoot = Join-Path $HOME Documents PowerShell Modules -} -Process -{ - foreach($moduleName in Get-Module $Name -ListAvailable |Select-Object -ExpandProperty Name -Unique) - { - Get-Module $moduleName -ListAvailable | - Select-Object -ExpandProperty ModuleBase | - Split-Path | - Split-Path | - Select-Object -Unique | - ForEach-Object {$_ -eq $UserRoot ? 'CurrentUser' : 'AllUsers'} | - Select-Object -Unique | - ForEach-Object {[pscustomobject]@{ModuleName=$moduleName;Scope=$_}} - } -} diff --git a/Get-RandomBytes.ps1 b/Get-RandomBytes.ps1 deleted file mode 100644 index 3687956f..00000000 --- a/Get-RandomBytes.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -<# -.SYNOPSIS -Returns random bytes. - -.OUTPUTS -System.Byte[] of random bytes. - -.LINK -https://docs.microsoft.com/dotnet/api/system.security.cryptography.rngcryptoserviceprovider - -.EXAMPLE -Get-RandomBytes.ps1 8 - -103 -235 -194 -199 -151 -83 -240 -152 -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -# The number of random bytes to return. -[Parameter(Position=0,Mandatory=$true)][int] $Count -) -[byte[]] $value = New-Object byte[] $Count -$rng = New-Object Security.Cryptography.RNGCryptoServiceProvider -$rng.GetBytes($value) -$rng.Dispose(); $rng = $null -return,$value diff --git a/Get-TypeAccelerators.ps1 b/Get-TypeAccelerators.ps1 deleted file mode 100644 index 78105f76..00000000 --- a/Get-TypeAccelerators.ps1 +++ /dev/null @@ -1,169 +0,0 @@ -<# -.SYNOPSIS -Returns the list of PowerShell type accelerators. - -.OUTPUTS -Collections.Generic.Dictionary[string,type] - -.FUNCTIONALITY -PowerShell - -.EXAMPLE -Get-TypeAccelerators.ps1 - - -Alias Type Suffix ------ ---- ------ -Alias System.Management.Automation.AliasAttribute -AllowEmptyCollection System.Management.Automation.AllowEmptyCollectionAttribute -AllowEmptyString System.Management.Automation.AllowEmptyStringAttribute -AllowNull System.Management.Automation.AllowNullAttribute -ArgumentCompleter System.Management.Automation.ArgumentCompleterAttribute -ArgumentCompletions System.Management.Automation.ArgumentCompletionsAttribute -array System.Array -bool System.Boolean -byte System.Byte uy -char System.Char -CmdletBinding System.Management.Automation.CmdletBindingAttribute -datetime System.DateTime -decimal System.Decimal d -double System.Double -DscResource System.Management.Automation.DscResourceAttribute -ExperimentAction System.Management.Automation.ExperimentAction -Experimental System.Management.Automation.ExperimentalAttribute -ExperimentalFeature System.Management.Automation.ExperimentalFeature -float System.Single -single System.Single -guid System.Guid -hashtable System.Collections.Hashtable -int System.Int32 -int32 System.Int32 -short System.Int16 s -int16 System.Int16 s -long System.Int64 l -int64 System.Int64 l -ciminstance Microsoft.Management.Infrastructure.CimInstance -cimclass Microsoft.Management.Infrastructure.CimClass -cimtype Microsoft.Management.Infrastructure.CimType -cimconverter Microsoft.Management.Infrastructure.CimConverter -IPEndpoint System.Net.IPEndPoint -NullString System.Management.Automation.Language.NullString -OutputType System.Management.Automation.OutputTypeAttribute -ObjectSecurity System.Security.AccessControl.ObjectSecurity -ordered System.Collections.Specialized.OrderedDictionary -Parameter System.Management.Automation.ParameterAttribute -PhysicalAddress System.Net.NetworkInformation.PhysicalAddress -pscredential System.Management.Automation.PSCredential -PSDefaultValue System.Management.Automation.PSDefaultValueAttribute -pslistmodifier System.Management.Automation.PSListModifier -psobject System.Management.Automation.PSObject -pscustomobject System.Management.Automation.PSObject -psprimitivedictionary System.Management.Automation.PSPrimitiveDictionary -ref System.Management.Automation.PSReference -PSTypeNameAttribute System.Management.Automation.PSTypeNameAttribute -regex System.Text.RegularExpressions.Regex -DscProperty System.Management.Automation.DscPropertyAttribute -sbyte System.SByte y -string System.String -SupportsWildcards System.Management.Automation.SupportsWildcardsAttribute -switch System.Management.Automation.SwitchParameter -cultureinfo System.Globalization.CultureInfo -bigint System.Numerics.BigInteger n -securestring System.Security.SecureString -timespan System.TimeSpan -ushort System.UInt16 us -uint16 System.UInt16 us -uint System.UInt32 u -uint32 System.UInt32 u -ulong System.UInt64 ul -uint64 System.UInt64 ul -uri System.Uri -ValidateCount System.Management.Automation.ValidateCountAttribute -ValidateDrive System.Management.Automation.ValidateDriveAttribute -ValidateLength System.Management.Automation.ValidateLengthAttribute -ValidateNotNull System.Management.Automation.ValidateNotNullAttribute -ValidateNotNullOrEmpty System.Management.Automation.ValidateNotNullOrEmptyAttribute -ValidatePattern System.Management.Automation.ValidatePatternAttribute -ValidateRange System.Management.Automation.ValidateRangeAttribute -ValidateScript System.Management.Automation.ValidateScriptAttribute -ValidateSet System.Management.Automation.ValidateSetAttribute -ValidateTrustedData System.Management.Automation.ValidateTrustedDataAttribute -ValidateUserDrive System.Management.Automation.ValidateUserDriveAttribute -version System.Version -void System.Void -ipaddress System.Net.IPAddress -DscLocalConfigurationManager System.Management.Automation.DscLocalConfigurationManagerAttribute -WildcardPattern System.Management.Automation.WildcardPattern -X509Certificate System.Security.Cryptography.X509Certificates.X509Certificate -X500DistinguishedName System.Security.Cryptography.X509Certificates.X500DistinguishedName -xml System.Xml.XmlDocument -CimSession Microsoft.Management.Infrastructure.CimSession -mailaddress System.Net.Mail.MailAddress -semver System.Management.Automation.SemanticVersion -adsi System.DirectoryServices.DirectoryEntry -adsisearcher System.DirectoryServices.DirectorySearcher -wmiclass System.Management.ManagementClass -wmi System.Management.ManagementObject -wmisearcher System.Management.ManagementObjectSearcher -scriptblock System.Management.Automation.ScriptBlock -pspropertyexpression Microsoft.PowerShell.Commands.PSPropertyExpression -psvariable System.Management.Automation.PSVariable -type System.Type -psmoduleinfo System.Management.Automation.PSModuleInfo -powershell System.Management.Automation.PowerShell -runspacefactory System.Management.Automation.Runspaces.RunspaceFactory -runspace System.Management.Automation.Runspaces.Runspace -initialsessionstate System.Management.Automation.Runspaces.InitialSessionState -psscriptmethod System.Management.Automation.PSScriptMethod -psscriptproperty System.Management.Automation.PSScriptProperty -psnoteproperty System.Management.Automation.PSNoteProperty -psaliasproperty System.Management.Automation.PSAliasProperty -psvariableproperty System.Management.Automation.PSVariableProperty -#> - -[CmdletBinding()][OutputType([Collections.Generic.Dictionary[string,type]])] Param( -[ValidateSet('Alias','Type','TypeName')][string] $DictionaryKey -) -if($DictionaryKey -eq 'Alias') -{ - return [PSObject].Assembly.GetType('System.Management.Automation.TypeAccelerators')::Get -} -elseif($DictionaryKey -eq 'Type') -{ - $dictionary = @{} - ([PSObject].Assembly.GetType('System.Management.Automation.TypeAccelerators')::Get).GetEnumerator() | - ForEach-Object {$dictionary[$_.Value] = $_.Key} - return $dictionary -} -elseif($DictionaryKey -eq 'TypeName') -{ - $dictionary = @{} - ([PSObject].Assembly.GetType('System.Management.Automation.TypeAccelerators')::Get).GetEnumerator() | - ForEach-Object {$dictionary[$_.Value.FullName] = $_.Key} - return $dictionary -} -else -{ - return ([PSObject].Assembly.GetType('System.Management.Automation.TypeAccelerators')::Get).GetEnumerator() | - ForEach-Object {[pscustomobject]@{ - Alias = $_.Key - Type = [type]$_.Value - Suffix = switch($_.Key) - { - byte {'uy'} - sbyte {'y'} - short {'s'} - ushort {'us'} - int16 {'s'} - uint16 {'us'} - long {'l'} - ulong {'ul'} - int64 {'l'} - uint64 {'ul'} - uint {'u'} - uint32 {'u'} - bigint {'n'} - decimal {'d'} - } - }} -} diff --git a/Import-Variables.ps1 b/Import-Variables.ps1 deleted file mode 100644 index 49983f14..00000000 --- a/Import-Variables.ps1 +++ /dev/null @@ -1,66 +0,0 @@ -<# -.SYNOPSIS -Creates local variables from a data row or dictionary (hashtable). - -.INPUTS -System.Collections.IDictionary with keys and values to import as variables, -or System.Management.Automation.PSCustomObject with properties to import as variables. - -.FUNCTIONALITY -PowerShell - -.LINK -Add-ScopeLevel.ps1 - -.EXAMPLE -if($line -match '\AProject\("(?[^"]+)"\)') {Import-Variables.ps1 $Matches} - -Copies $Matches.TypeGuid to $TypeGuid if a match is found. - -.EXAMPLE -Invoke-Sqlcmd "select ProductID, Name, ListPrice from Production.Product where ProductID = 1;" -Server 'Server\instance' -Database AdventureWorks |Import-Variables.ps1 - -Copies field values into $ProductID, $Name, and $ListPrice. - -.EXAMPLE -if($env:ComSpec -match '^(?.*?\\)(?[^\\]+$)'){Import-Variables.ps1 $Matches -Verbose} - -Sets $ComPath and $ComExe from the regex captures if the regex matches. - -.EXAMPLE -Invoke-RestMethod https://api.github.com/ |Import-Variables.ps1 ; Invoke-RestMethod $emojis_url - -Sets variables from the fields returned by the web service: $current_user_url, $emojis_url, &c. -Then fetches the list of GitHub emojis. -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([void])] Param( -<# -A hash of string names to any values to set as variables, -or a DataRow or object with properties to set as variables. -Works with DataRows. -#> -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][PSObject] $InputObject, -# The type of object members to convert to variables. -[Alias('Type')][Management.Automation.PSMemberTypes] $MemberType = 'Properties', -# The scope of the variables to create. -[string] $Scope = 'Local', -# Indicates that created variables should be hidden from child scopes. -[switch] $Private -) -Begin -{ - $Scope = Add-ScopeLevel.ps1 $Scope - $sv = if($Private) {@{Scope=$Scope;Option='Private'}} else {@{Scope=$Scope}} -} -Process -{ - $isDict = $InputObject -is [Collections.IDictionary] - [string[]]$vars = - if($isDict) {$InputObject.Keys |Where-Object {$_ -is [string]}} - else {Get-Member -InputObject $InputObject -MemberType $MemberType |Select-Object -ExpandProperty Name} - if(!$vars){return} - Write-Verbose "Importing $($vars.Count) $(if($isDict){'keys'}else{"$MemberType properties"}): $vars" - foreach($var in $vars) {Set-Variable $var $InputObject.$var @sv} -} diff --git a/Invoke-WindowsPowerShell.ps1 b/Invoke-WindowsPowerShell.ps1 deleted file mode 100644 index 524e78fc..00000000 --- a/Invoke-WindowsPowerShell.ps1 +++ /dev/null @@ -1,106 +0,0 @@ -<# -.SYNOPSIS -Runs commands in Windows PowerShell (typically from PowerShell Core). - -.FUNCTIONALITY -PowerShell - -.LINK -Use-Command.ps1 - -.LINK -Stop-ThrowError.ps1 - -.EXAMPLE -Invoke-WindowsPowerShell.ps1 '$PSVersionTable.PSEdition' - -Desktop - -.EXAMPLE -Invoke-WindowsPowerShell.ps1 {Param($n); Get-WmiObject Win32_Process -Filter "Name like '$n'" |foreach ProcessName} power% - -PowerToys.exe -PowerToys.Awake.exe -PowerToys.FancyZones.exe -PowerToys.KeyboardManagerEngine.exe -PowerLauncher.exe -powershell.exe -powershell.exe - -.EXAMPLE -Invoke-WindowsPowerShell.ps1 { Get-ADDefaultDomainPasswordPolicy } - -ComplexityEnabled : True -DistinguishedName : DC=fabrikam,DC=com -LockoutDuration : 00:20:00 -LockoutObservationWindow : 00:20:00 -LockoutThreshold : 3 -MaxPasswordAge : 90.00:00:00 -MinPasswordAge : 2.00:00:00 -MinPasswordLength : 12 -objectClass : {domainDNS} -objectGuid : 1d032086-5e5b-434c-a028-9eba90b663be -PasswordHistoryCount : 5 -ReversibleEncryptionEnabled : False - -.EXAMPLE -Invoke-WindowsPowerShell.ps1 { Get-ADGroupMembers Taskmaster |Select-Object -ExpandProperty Name } - -Greg Davies -Alex Horne - -.EXAMPLE -Invoke-WindowsPowerShell.ps1 { Get-ADPrincipalGroupMembership alexh |Select-Object -ExpandProperty Name } - -Taskmaster -The Horne Section -#> - -#Requires -Version 5 -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars','', -Justification='A global variable is used to cache values.')] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingInvokeExpression','', -Justification='Invoke-Expression is neccessary for the purpose of this script.')] -[CmdletBinding()] Param( -# A script block to run. -[Parameter(ParameterSetName='CommandBlock',Position=0,Mandatory=$true)][scriptblock] $CommandBlock, -# Parameters to the script block. -[Parameter(ParameterSetName='CommandBlock',Position=1,ValueFromRemainingArguments=$true)][psobject[]] $BlockArgs = @(), -# The text of the command to run. -[Parameter(ParameterSetName='CommandText',Position=0,Mandatory=$true)][string] $CommandText -) - -if($PSVersionTable.PSEdition -eq 'Desktop') -{ - if($PSCmdlet.ParameterSetName -eq 'CommandText') {Invoke-Expression $CommandText} - else {$CommandBlock.InvokeReturnAsIs($BlockArgs)} - return -} - -Use-Command.ps1 powershell "$env:SystemRoot\system32\windowspowershell\v1.0\powershell.exe" -Fail - -if(!(Get-Variable WPSModulePath -Scope Global -ValueOnly -ErrorAction Ignore)) -{ - $addmodules = @() - if('C:\Windows\System32\WindowsPowerShell\v1.0\Modules\' -notin ($env:PSModulePath -split ';')) - { $addmodules += 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\' } - if("C:\Users\$env:UserName\Documents\WindowsPowerShell\Modules\" -notin ($env:PSModulePath -split ';')) - { $addmodules += "C:\Users\$env:UserName\Documents\WindowsPowerShell\Modules\" } - $Global:WPSModulePath = if($addmodules.Count) {"$($addmodules -join ';');$env:PSModulePath"} else {$env:PSModulePath} -} -$PSModulePath = $env:PSModulePath # save current module path -$env:PSModulePath = $Global:WPSModulePath # use Windows PowerShell module path -if($PSCmdlet.ParameterSetName -eq 'CommandText') -{ - $CommandText |& "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive -Command - -} -else -{ - if($Host.Name -eq 'Visual Studio Code Host') - { - Stop-ThrowError.ps1 'ScriptBlocks not supported by VSCode prompt' -OperationContext $CommandBlock - } - & "$env:SystemRoot\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive ` - -Command $CommandBlock -args $BlockArgs -} -$env:PSModulePath = $PSModulePath # restore module path diff --git a/Merge-PSObject.ps1 b/Merge-PSObject.ps1 deleted file mode 100644 index 1dfe44fe..00000000 --- a/Merge-PSObject.ps1 +++ /dev/null @@ -1,88 +0,0 @@ -<# -.SYNOPSIS -Create a new PSObject by recursively combining the properties of PSObjects. - -.INPUTS -System.Management.Automation.PSObject to combine. - -.OUTPUTS -System.Management.Automation.PSObject combining the inputs. - -.FUNCTIONALITY -PowerShell - -.LINK -Get-Member - -.LINK -Add-Member - -.EXAMPLE -Merge-PSObject.ps1 ([pscustomobject]@{a=1;b=2}) ([pscustomobject]@{b=0;c=3}) - -a b c -- - - -1 2 3 - -.EXAMPLE -Merge-PSObject.ps1 ([pscustomobject]@{a=1;b=2}) ([pscustomobject]@{b=0;c=3}) -Force - -a b c -- - - -1 0 3 - -.EXAMPLE -'{"a":1,"b":{"u":3},"c":{"v":5}}','{"a":{"w":8},"b":2,"c":{"x":6}}' |ConvertFrom-Json |Merge-PSObject.ps1 -Accumulate -Force |select -Last 1 |ConvertTo-Json - -{ - "a": { - "w": 8 - }, - "b": 2, - "c": { - "v": 5, - "x": 6 - } -} -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([PSObject])] Param( -# Initial PSObject to combine. -[Parameter(Position=0)][PSObject] $ReferenceObject = [pscustomobject]@{}, -<# -PSObjects to combine. PSObject descendant properties are recursively merged. -Primitive values are overwritten by any matching ones in the new PSObject. -#> -[Parameter(Position=1,Mandatory=$true,ValueFromPipeline=$true)][PSObject] $InputObject, -# Continue merging each pipeline object's properties into the same accumulator object. -[switch] $Accumulate, -# Overwrite existing properties. -[switch] $Force -) -Begin {if($Accumulate) {$value = $ReferenceObject.PSObject.Copy()}} -Process -{ - if(!$Accumulate) {$value = $ReferenceObject.PSObject.Copy()} - foreach($p in $InputObject |Get-Member -Type Properties) - { - $name,$type = $p.Name,$p.MemberType - $newvalue = $InputObject.$name - if(!($value |Get-Member $name -Type $type)) - { - $value |Add-Member $name -Type $type -Value $newvalue - } - elseif($Force) - { - $currentvalue = $value.$name - $value.$name = - if($currentvalue -isnot [PSObject] -or $newvalue -isnot [PSObject]) {$newvalue} - else {Merge-PSObject.ps1 $currentvalue $newvalue} - } - elseif($value.$name -is [PSObject] -and $newvalue -is [PSObject]) - { - $value.$name = Merge-PSObject.ps1 $value.$name $newvalue - } - } - return $value -} diff --git a/Read-Choice.ps1 b/Read-Choice.ps1 deleted file mode 100644 index cc10e3ae..00000000 --- a/Read-Choice.ps1 +++ /dev/null @@ -1,75 +0,0 @@ -<# -.SYNOPSIS -Returns choice selected from a list of options. - -.INPUTS -System.String containing a choice to offer. - -.OUTPUTS -System.String containing the choice that was selected. - -.FUNCTIONALITY -PowerShell - -.LINK -https://msdn.microsoft.com/library/system.management.automation.host.pshostuserinterface.promptforchoice.aspx - -.EXAMPLE -Read-Choice.ps1 one,two,three - -Please select: -[] one [] two [] three [?] Help (default is "one"): -one - -.EXAMPLE -Read-Choice.ps1 ([ordered]@{'&one'='first thing';'&two'='second thing';'t&hree'='third thing'}) -Message 'Pick:' - -Pick: -[O] one [T] two [H] three [?] Help (default is "O"): ? -O - first thing -T - second thing -H - third thing -[O] one [T] two [H] three [?] Help (default is "O"): -&one -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string])] Param( -# A list of choice strings. Use & in front of a letter to make it a hotkey. -[Parameter(ParameterSetName='ChoicesArray',Position=0,Mandatory=$true,ValueFromPipeline=$true)] -[Alias('Options')][string[]] $Choices, -<# -An ordered hash of choices mapped to help text descriptions. -Use & in front of a letter to make it a hotkey. -#> -[Parameter(ParameterSetName='ChoicesHash',Position=0,Mandatory=$true)] -[Alias('Menu')][Collections.IDictionary] $ChoiceHash, -# A title to use for the prompt. -[string] $Caption, -# Instructional text to provide in the prompt. -[string] $Message = 'Please select:', -<# -The index of the default choice. -Use -1 to for no default. -Otherwise, the first item (index 0) is the default. -#> -[int] $DefaultIndex -) -Process -{ - [Management.Automation.Host.ChoiceDescription[]] $choicelist = - switch($PSCmdlet.ParameterSetName) - { - ChoicesArray - { - $Choices = $Choices.ForEach({$_}) # flatten nested arrays - $Choices |ForEach-Object {New-Object System.Management.Automation.Host.ChoiceDescription $_} - } - ChoicesHash - { - $Choices = @($ChoiceHash.Keys) - $Choices |ForEach-Object {New-Object System.Management.Automation.Host.ChoiceDescription $_,$ChoiceHash[$_]} - } - } - $Choices[$Host.UI.PromptForChoice($Caption,$Message,$choicelist,$DefaultIndex)] -} diff --git a/Remove-ParameterDefault.ps1 b/Remove-ParameterDefault.ps1 deleted file mode 100644 index b4573904..00000000 --- a/Remove-ParameterDefault.ps1 +++ /dev/null @@ -1,62 +0,0 @@ -<# -.SYNOPSIS -Removes a value that would have been used for a parameter if none was specified, if one existed. - -.INPUTS -An object with a ParameterName property that identifies a property to remove a default for. - -.FUNCTIONALITY -Parameters - -.LINK -Add-ScopeLevel.ps1 - -.LINK -Stop-ThrowError.ps1 - -.LINK -Get-Command - -.LINK -about_Scopes - -.EXAMPLE -Remove-ParameterDefault.ps1 epcsv nti -Scope Global - -Establishes that the -NoTypeInformation param of the Export-Csv cmdlet will revert to false -(as established by the cmdlet) if not otherwise specified, globally for the PowerShell session. - -.EXAMPLE -Remove-ParameterDefault.ps1 Select-Xml Namespace - -Removes any namespaces used by Select-Xml when none are given explicitly. -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -# The name of a cmdlet, function, script, or alias to remove a default parameter value from. -[Parameter(Position=0,Mandatory=$true)][ValidateNotNullOrEmpty()][Alias('CmdletName')][string] $CommandName, -# The name or alias of the parameter to remove a default value from. -[Parameter(Position=1,Mandatory=$true,ValueFromPipelineByPropertyName=$true)][ValidateNotNullOrEmpty()][string] $ParameterName, -# The scope of this default. -[string] $Scope = 'Local' -) -Begin -{ - $Scope = Add-ScopeLevel.ps1 $Scope - $cmd = Get-Command $CommandName -ErrorAction Ignore - if(!$cmd) {Stop-ThrowError.ps1 "Could not find command '$CommandName'" -Argument CommandName} - if($cmd.CommandType -eq 'Alias') {$cmd = Get-Command $cmd.ResolvedCommandName} - if($cmd.CommandType -notin 'Cmdlet','ExternalScript','Function','Script') - {Stop-ThrowError.ps1 "Command '$CommandName' ($($cmd.CommandType)) not supported" -Argument CommandName} - $defaults = Get-Variable PSDefaultParameterValues -Scope $Scope -ErrorAction Ignore -} -Process -{ - if(!$defaults) {return} - $name = - try {"$($cmd.Name):$($cmd.ResolveParameter($ParameterName).Name)"} - catch {Stop-ThrowError.ps1 "Could not find parameter '$ParameterName' for cmdlet '$CommandName'" -Argument ParameterName} - Write-Verbose "Removing default parameter '$name'" - if($defaults.Value.ContainsKey($name)) {$defaults.Value.Remove($name)} -} diff --git a/Set-ParameterDefault.ps1 b/Set-ParameterDefault.ps1 deleted file mode 100644 index cf3338ed..00000000 --- a/Set-ParameterDefault.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -<# -.SYNOPSIS -Assigns a value to use for the specified cmdlet parameter to use when one is not specified. - -.INPUTS -System.Object containing the default value to assign. - -.FUNCTIONALITY -Parameters - -.LINK -Add-ScopeLevel.ps1 - -.LINK -Stop-ThrowError.ps1 - -.LINK -Get-Command - -.LINK -about_Scopes - -.EXAMPLE -Set-ParameterDefault.ps1 epcsv nti $true -Scope Global - -Establishes that the -NoTypeInformation param of the Export-Csv cmdlet will be true if not otherwise specified, -globally for the PowerShell session. - -.EXAMPLE -Set-ParameterDefault.ps1 Select-Xml Namespace @{svg = 'http://www.w3.org/2000/svg'} - -Uses only the SVG namespace for Select-Xml when none are given explicitly. -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -# The name of a cmdlet, function, script, or alias to assign a default parameter value to. -[Parameter(Position=0,Mandatory=$true)][ValidateNotNullOrEmpty()][Alias('CmdletName')][string] $CommandName, -# The name or alias of the parameter to assign a default value to. -[Parameter(Position=1,Mandatory=$true)][ValidateNotNullOrEmpty()][string] $ParameterName, -# The value to assign as a default. -[Parameter(Position=2,Mandatory=$true,ValueFromPipeline=$true)] $Value, -# The scope of this default. -[string] $Scope = 'Local', -# Fails silently if the command or parameter are not found. -[switch] $SkipMissing -) -Begin -{ - $Script:Skip = $false - $Scope = Add-ScopeLevel.ps1 $Scope - $cmd = Get-Command $CommandName -ErrorAction Ignore - if(!$cmd) - { - if($SkipMissing) {$Script:Skip = $true; return} - else {Stop-ThrowError.ps1 "Could not find command '$CommandName'" -Argument CommandName} - } - if($cmd.CommandType -eq 'Alias') {$cmd = Get-Command $cmd.ResolvedCommandName} - if($cmd.CommandType -notin 'Cmdlet','ExternalScript','Function','Script') - { - if($SkipMissing) {$Script:Skip = $true; return} - else {Stop-ThrowError.ps1 "Command '$CommandName' ($($cmd.CommandType)) not supported" -Argument CommandName} - } - $name = - try {"$($cmd.Name):$($cmd.ResolveParameter($ParameterName).Name)"} - catch - { - if($SkipMissing) {$Script:Skip = $true; return} - else {Stop-ThrowError.ps1 "Could not find parameter '$ParameterName' for cmdlet '$CommandName'" -Argument ParameterName} - } - $defaults = Get-Variable PSDefaultParameterValues -Scope $Scope -ErrorAction Ignore - if(!$defaults) - { - Set-Variable PSDefaultParameterValues @{} -Scope $Scope - $defaults = Get-Variable PSDefaultParameterValues -Scope $Scope -ErrorAction Ignore - } -} -Process -{ - if($Script:Skip) {return} - Write-Verbose "Setting default parameter '$name' to '$Value'" - $defaults.Value[$name] = $Value -} diff --git a/Stop-ThrowError.ps1 b/Stop-ThrowError.ps1 deleted file mode 100644 index 7e14c906..00000000 --- a/Stop-ThrowError.ps1 +++ /dev/null @@ -1,133 +0,0 @@ -<# -.SYNOPSIS -Throws a better error than "throw". - -.DESCRIPTION -The PowerShell "throw" keyword doesn't do a good job of providing actionable -detail or context: - -Unable to remove root node. -At C:\Scripts\PS5\Remove-Xml.ps1:34 char:37 -+ ... if($node.ParentNode -eq $null) {throw 'Unable to remove root node.'} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + CategoryInfo : OperationStopped: (Unable to remove root node.:String) [], RuntimeException - + FullyQualifiedErrorId : Unable to remove root node. - -It only shows where the "throw" was used in the called script! - -Using $PSCmdlet.ThrowTerminatingError() does a much better job: - -C:\Scripts\PS5\Remove-Xml.ps1 : Unable to remove root node -Parameter name: SelectXmlInfo -At C:\Scripts\Test-Error.ps1:2 char:23 -+ '' |Select-Xml / |Remove-Xml.ps1 -+ ~~~~~~~~~~~~~~ - + CategoryInfo : InvalidArgument: (:SelectXmlInfo) [Remove-Xml.ps1], ArgumentException - + FullyQualifiedErrorId : RootRequired,Remove-Xml.ps1 - -Now you can see where the trouble is in the calling script! - -However, contructing an exception, then using that to construct an error with the right ID & category & -target object, then using that to call ThrowTerminatingError() is pretty inconvenient. - -This script combines that process into a few simple parameters. - -.FUNCTIONALITY -PowerShell - -.LINK -https://docs.microsoft.com/dotnet/api/system.management.automation.cmdlet.throwterminatingerror - -.LINK -https://docs.microsoft.com/dotnet/api/system.management.automation.errorrecord.-ctor - -.LINK -Get-Variable - -.LINK -New-Object - -.EXAMPLE -Stop-ThrowError.ps1 'Unable to remove root node' -Argument SelectXmlInfo - -C:\Scripts\PS5\Remove-Xml.ps1 : Unable to remove root node -Parameter name: SelectXmlInfo -At C:\Scripts\Test-Error.ps1:2 char:23 -+ '' |Select-Xml / |Remove-Xml.ps1 -+ ~~~~~~~~~~~~~~ - + CategoryInfo : InvalidArgument: (:SelectXmlInfo) [Remove-Xml.ps1], ArgumentException - + FullyQualifiedErrorId : SelectXmlInfo,Remove-Xml.ps1 - -.EXAMPLE -if(Test-Uri.ps1 $u) {[uri]$u} else {Stop-ThrowError.ps1 'Bad URL' -Format URL -InputString $u} - -(Fails for non-uri values of $u.) -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([void])] Param( -# The type of a Exception class to instantiate as part of the error. -[Parameter(ParameterSetName='CatchBlock',Position=0)] -[Parameter(ParameterSetName='Detailed',Mandatory=$true,Position=0)][Type] $ExceptionType, -# The constructor parameters for the exception class specified by ExceptionTypeName. -[Parameter(ParameterSetName='CatchBlock',Position=1)] -[Parameter(ParameterSetName='Detailed',Mandatory=$true,Position=1)][object[]] $ExceptionArguments, -# The error's category, as an enumeration value. -[Parameter(ParameterSetName='Detailed',Mandatory=$true,Position=2)][Management.Automation.ErrorCategory] $ErrorCategory, -# The object in context when the error happened. -[Parameter(ParameterSetName='Detailed',Mandatory=$true,Position=3)][object] $TargetObject, -<# -An string unique to the script that identifies the error. -By default this will use the line number it is called from. -#> -[Parameter(ParameterSetName='Detailed',Position=4)][string] $ErrorId = - "L$(Get-PSCallStack |Select-Object -First 1 |Select-Object -ExpandProperty ScriptLineNumber)", -[Parameter(Position=0,ParameterSetName='Format',Mandatory=$true)] -[Parameter(Position=0,ParameterSetName='InvalidArgument',Mandatory=$true)] -[Parameter(Position=0,ParameterSetName='InvalidOperation',Mandatory=$true)] -[Parameter(Position=0,ParameterSetName='ObjectNotFound',Mandatory=$true)] -[Parameter(Position=0,ParameterSetName='ItemNotFound',Mandatory=$true)] -[Parameter(Position=0,ParameterSetName='NotImplemented',Mandatory=$true)] -[string] $Message, -# The data format the string failed to parse as. -[Parameter(ParameterSetName='Format',Mandatory=$true)][string] $Format, -# The string that failed to parse. -[Parameter(ParameterSetName='Format',Mandatory=$true)][string] $InputString, -# The parameter name that had a bad value. -[Parameter(ParameterSetName='InvalidArgument',Mandatory=$true)][Alias('InvalidArgument')][string] $Argument, -# An object containing the state that failed to process. -[Parameter(ParameterSetName='InvalidOperation',Mandatory=$true)][Alias('InvalidOperation')] $OperationContext, -# An object containing the search detail that failed. -[Parameter(ParameterSetName='ItemNotFound',Mandatory=$true)][Alias('ObjectNotFound')] $SearchContext, -# Indicates that the exception represents incomplete functionality. -[Parameter(ParameterSetName='NotImplemented',Mandatory=$true)][switch] $NotImplemented -) -[object[]] $params = switch($PSCmdlet.ParameterSetName) -{ - CatchBlock {(Get-Variable PSItem -ValueOnly -Scope 1),(New-Object $ExceptionType.FullName $ExceptionArguments)} - Detailed {(New-Object $ExceptionType.FullName $ExceptionArguments),$ErrorId,$ErrorCategory,$TargetObject} - Format {(New-Object FormatException $Message),$Format,'ParserError',$InputString} - InvalidArgument - { - $ScriptParams = Get-Variable PSBoundParameters -ValueOnly -Scope 1 -ErrorAction Ignore - $paramValue = if($ScriptParams -and $ScriptParams.ContainsKey($Argument)) {$ScriptParams[$Argument]} - (New-Object ArgumentException $Message,$Argument),$Argument,'InvalidArgument',$paramValue - } - InvalidOperation - { - (New-Object InvalidOperationException $Message),($OperationContext.GetType().Name), - 'InvalidOperation',$OperationContext - } - ItemNotFound - { - (New-Object Management.Automation.ItemNotFoundException $Message),($SearchContext.GetType().Name), - 'ObjectNotFound',$SearchContext - } - NotImplemented - { - (New-Object NotImplementedException $Message),'NotImplementedException','NotImplemented',$null - } -} -[Management.Automation.PSCmdlet] $caller = Get-Variable PSCmdlet -ValueOnly -Scope 1 -ErrorAction Ignore -if(!$caller) {$caller = $PSCmdlet} -$caller.ThrowTerminatingError((New-Object Management.Automation.ErrorRecord $params)) diff --git a/Test-Administrator.ps1 b/Test-Administrator.ps1 deleted file mode 100644 index 49aa1716..00000000 --- a/Test-Administrator.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -<# -.SYNOPSIS -Checks whether the current session has administrator privileges. - -.FUNCTIONALITY -PowerShell - -.EXAMPLE -Test-Administrator.ps1 - -False -#> - -#Requires -Version 2 -if($IsWindows) -{ - return ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).` - IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -} -else {return [Environment]::IsPrivilegedProcess} diff --git a/Test-NoteProperty.ps1 b/Test-NoteProperty.ps1 deleted file mode 100644 index 1aee5b22..00000000 --- a/Test-NoteProperty.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# -.SYNOPSIS -Looks for any matching NoteProperties on an object. - -.INPUTS -System.Management.Automation.PSObject, perhaps created via [PSCustomObject]@{ … } -or ConvertFrom-Json or Invoke-RestMethod that may have NoteProperties. - -.OUTPUTS -System.Boolean indicating at least one matching NoteProperty was found. - -.FUNCTIONALITY -Properties - -.EXAMPLE -$r = Invoke-RestMethod @args; if(Test-NoteProperty.ps1 -Name Status -InputObject $r) { … } - -Executes the "if" block if there is a status NoteProperty present. - -.EXAMPLE -Get-Content records.json |ConvertFrom-Json |? {$_ |Test-NoteProperty.ps1 *Addr*} |… - -Passes objects through the pipeline that have a property containing "Addr" in the name. -#> -[CmdletBinding()][OutputType([bool])] Param( -# The name of the property to look for. Wildcards are supported. -[Parameter(Mandatory=$true,Position=0)][string] $Name, -# The object to examine. -[Parameter(Mandatory=$true,ValueFromPipeline=$true)][psobject]$InputObject -) -Process {[bool](Get-Member -InputObject $InputObject -Name $Name -MemberType NoteProperty -ErrorAction Ignore)} diff --git a/Test-Range.ps1 b/Test-Range.ps1 deleted file mode 100644 index 5e5871f7..00000000 --- a/Test-Range.ps1 +++ /dev/null @@ -1,56 +0,0 @@ -<# -.SYNOPSIS -Returns true from an initial condition until a terminating condition; a latching test. - -.INPUTS -Any object to test. - -.OUTPUTS -System.Boolean, or the input object if -Filter is specified. - -.FUNCTIONALITY -PowerShell - -.EXAMPLE -Get-Item *.ps1 |Test-Range.ps1 {$_.Name -like 'Join-*.ps1'} {$_.Name -like 'New-*.ps1'} -Filter |select Name - -Name ----- -Join-FileName.ps1 -Join-Keys.ps1 -Measure-DbColumn.ps1 -Measure-DbColumnValues.ps1 -Measure-DbTable.ps1 -Measure-Indents.ps1 -Measure-StandardDeviation.ps1 -Measure-TextFile.ps1 -Merge-Json.ps1 -Merge-PSObject.ps1 -Merge-XmlSelections.ps1 -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -<# -Latch: The initial condition which will begin the matching range. -Inclusive: Includes the input object that this condition evaluates a true value for. -#> -[Parameter(Position=0)][scriptblock] $After = {$true}, -<# -Unlatch: The terminating condition for the matching range. -Exclusive: Excludes the input object that this condition evaluates a true value for. -#> -[Parameter(Position=1)][scriptblock] $Before = {$false}, -# The input value to test. -[Parameter(Mandatory=$true,ValueFromPipeline=$true)] $InputObject, -# Passes through the input values that match the range rather than returning true or false. -[switch] $Filter -) -Begin {$inRange = $false} -Process -{ - if(!$inRange) {$inRange = $After.InvokeReturnAsIs($InputObject)} - elseif($inRange) {$inRange = !$Before.InvokeReturnAsIs($InputObject)} - if(!$Filter) {return $inRange} - elseif($inRange) {return $InputObject} -} diff --git a/Test-Variable.ps1 b/Test-Variable.ps1 deleted file mode 100644 index 97ffa743..00000000 --- a/Test-Variable.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -<# -.SYNOPSIS -Indicates whether a variable has been defined. - -.INPUTS -System.String name of a variable. - -.OUTPUTS -System.Boolean indicating whether the variable name is defined. - -.FUNCTIONALITY -PowerShell - -.LINK -Add-ScopeLevel.ps1 - -.LINK -Get-Variable - -.EXAMPLE -Test-Variable.ps1 true - -True - -.EXAMPLE -Test-Variable.ps1 '' - -False - -A variable can't have an empty string for a name. - -.EXAMPLE -Test-Variable.ps1 $null - -False - -A variable can't have a null name. - -.EXAMPLE -Test-Variable.ps1 null - -True - -.EXAMPLE -'PSVersionTable','false' |Test-Variable.ps1 - -True -True - -.EXAMPLE -'PWD','PID' |Test-Variable.ps1 -Scope Global - -True -True -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([bool])] Param( - # A variable name to test the existence of. - [Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true)][AllowEmptyString()][AllowNull()][string] $Name, - # The scope of the variable to test, Global, Local, Script, or the number of a calling parent context. - [Parameter(Position = 1)][string] $Scope -) -Process -{ - if ($Name -in $null, '') - { - return $false - } - elseif (!$Scope) - { - if (Get-Variable -Name $Name -ErrorAction Ignore) { return $true } - Write-Debug "$($MyInvocation.MyCommand.Name): $Name not found in default scope" - return $false - } - else - { - $Scope = Add-ScopeLevel.ps1 $Scope - if (Get-Variable -Name $Name -Scope $Scope -ErrorAction Ignore) { return $true } - Write-Debug "$($MyInvocation.MyCommand.Name): $Name not found in $Scope scope" - return $false - } -} diff --git a/Uninstall-OldModules.ps1 b/Uninstall-OldModules.ps1 deleted file mode 100644 index 28c87999..00000000 --- a/Uninstall-OldModules.ps1 +++ /dev/null @@ -1,47 +0,0 @@ -<# -.SYNOPSIS -Uninstalls old module versions (ignoring old Windows PowerShell modules). - -.FUNCTIONALITY -PowerShell Modules - -.EXAMPLE -Uninstall-OldModules.ps1 - -Cleans up redundant old modules. -#> - -#Requires -Version 3 -[CmdletBinding(ConfirmImpact='High',SupportsShouldProcess=$true)] Param( -# Indicates the modules should be forced to uninstall. -[switch] $Force -) -if(Get-Command Uninstall-PSResource -ErrorAction Ignore) -{ - Get-Module -ListAvailable | - Where-Object {$_.ModuleBase -notlike '*\WindowsPowerShell\*'} | - Group-Object Name | - Where-Object Count -gt 1 | - ForEach-Object {$_.Group |Sort-Object Version -Descending |Select-Object -Skip 1} | - Where-Object {$Force -or $PSCmdlet.ShouldProcess("$($_.Name) v$($_.Version)",'Uninstall-PSResource')} | - ForEach-Object {Uninstall-PSResource $_.Name -Version $_.Version -Confirm:$false} -} -elseif($PSVersionTable.PSVersion -lt [version]'6.0') -{ - Get-Module -ListAvailable | - Group-Object Name | - Where-Object Count -gt 1 | - ForEach-Object {$_.Group |Sort-Object Version -Descending |Select-Object -Skip 1} | - Where-Object {$Force -or $PSCmdlet.ShouldProcess("$($_.Name) v$($_.Version)",'Uninstall-Module')} | - ForEach-Object {Uninstall-Module $_.Name -RequiredVersion $_.Version -Force:$Force} -} -else -{ - Get-Module -ListAvailable | - Where-Object {$_.ModuleBase -notlike '*\WindowsPowerShell\*'} | - Group-Object Name | - Where-Object Count -gt 1 | - ForEach-Object {$_.Group |Sort-Object Version -Descending |Select-Object -Skip 1} | - Where-Object {$Force -or $PSCmdlet.ShouldProcess("$($_.Name) v$($_.Version)",'Uninstall-Module')} | - ForEach-Object {Uninstall-Module $_.Name -RequiredVersion $_.Version -Force:$Force} -} diff --git a/Update-Modules.ps1 b/Update-Modules.ps1 deleted file mode 100644 index a3363105..00000000 --- a/Update-Modules.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -<# -.SYNOPSIS -Cleans up old modules. - -.FUNCTIONALITY -PowerShell Modules - -.LINK -Uninstall-OldModules.ps1 - -.EXAMPLE -Update-Modules.ps1 - -Updates installed modules and purges old versions. -#> - -#Requires -Version 3 -[CmdletBinding()] Param() -Update-Module -Force -Uninstall-OldModules.ps1 diff --git a/Use-ProgressView.ps1 b/Use-ProgressView.ps1 deleted file mode 100644 index 4b53cd19..00000000 --- a/Use-ProgressView.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -<# -.SYNOPSIS -Sets the progress bar display view. - -.FUNCTIONALITY -PowerShell - -.LINK -about_ANSI_Terminals - -.EXAMPLE -Use-ProgressView.ps1 Classic - -Restores the Windows PowerShell 5.x-style top progress banner for Write-Progress. -#> - -#Requires -Version 7.2 -[CmdletBinding()] Param( -# The progress view to use. -[Parameter(Position=0,Mandatory=$true)][System.Management.Automation.ProgressView] $View -) -$PSStyle.Progress.View = $View diff --git a/Use-ReasonableDefaults.ps1 b/Use-ReasonableDefaults.ps1 deleted file mode 100644 index f2f3b202..00000000 --- a/Use-ReasonableDefaults.ps1 +++ /dev/null @@ -1,105 +0,0 @@ -<# -.SYNOPSIS -Sets certain cmdlet parameter defaults to rational, useful values. - -.FUNCTIONALITY -PowerShell - -.LINK -Use-NetMailConfig.ps1 - -.LINK -Set-ParameterDefault.ps1 - -.LINK -Get-EnumValues.ps1 - -.EXAMPLE -Use-ReasonableDefaults.ps1 - -Sets the security protocol to TLS 1.2. - -Sets default values: -* Out-File -Encoding UTF8 -Width ([int]::MaxValue) -* Export-Csv -NoTypeInformation -UseQuotes AsNeeded -* Invoke-WebRequest -UseBasicParsing -* Select-Xml -Namespace @{ a bunch of standard namespaces } -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([void])] Param( -# Use the greatest value of the System.Net.SecurityProtocolType enum. -[switch] $LatestSecurityProtocol -) -if(!$LatestSecurityProtocol) -{ - [Net.ServicePointManager]::SecurityProtocol = 'Tls12' - if($PSVersionTable.ContainsKey('CLRVersion')) {Use-NetMailConfig.ps1 -Scope Global} -} -else -{ - if($PSVersionTable.ContainsKey('CLRVersion')) - { - Use-NetMailConfig.ps1 -Scope Global - if($PSVersionTable.CLRVersion -lt '4.7.1') - { - if([Net.ServicePointManager]::SecurityProtocol -band [Net.SecurityProtocolType]'Ssl3') - { - [Net.ServicePointManager]::SecurityProtocol = - Get-EnumValues.ps1 Net.SecurityProtocolType |Select-Object -Last 1 -ExpandProperty Name - } - } - } -} -Set-ParameterDefault.ps1 Out-File Width ([int]::MaxValue) -Scope Global -Set-ParameterDefault.ps1 Out-File Encoding UTF8 -Scope Global -Set-ParameterDefault.ps1 Get-ChildItem Force $true -Scope Global -Set-ParameterDefault.ps1 Export-Csv NoTypeInformation $true -Scope Global -Set-ParameterDefault.ps1 Invoke-WebRequest UseBasicParsing $true -Scope Global -if((Get-Command Export-Csv -ParameterName UseQuotes -ErrorAction Ignore)) -{ - Set-ParameterDefault.ps1 Export-Csv UseQuotes AsNeeded -Scope Global -} -Set-ParameterDefault.ps1 Select-Xml Namespace -Scope Global -Value @{ -xhtml = 'http://www.w3.org/1999/xhtml' -svg = 'http://www.w3.org/2000/svg' -xsl = 'http://www.w3.org/1999/XSL/Transform' -fn = 'http://www.w3.org/2005/xpath-functions' -xs = 'http://www.w3.org/2001/XMLSchema' -wsdl = 'http://schemas.xmlsoap.org/wsdl/' -err = 'http://www.w3.org/2005/xqt-errors' -atom = 'http://www.w3.org/2005/Atom' -rss = 'http://purl.org/rss/1.0/' -rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns' -rdfs = 'http://www.w3.org/2000/01/rdf-schema' -xsd = 'http://www.w3.org/2001/XMLSchema' -msb = 'http://schemas.microsoft.com/developer/msbuild/2003' -pom = 'http://maven.apache.org/POM/4.0.0' -owl = 'http://www.w3.org/2002/07/owl' -dc = 'http://purl.org/dc/terms/' -cc = 'http://creativecommons.org/ns#' -foaf = 'http://xmlns.com/foaf/0.1/' -vcard = 'http://www.w3.org/2006/vcard/ns' -dbp = 'http://dbpedia.org/dbprop/' -geo = 'http://www.geonames.org/ontology' -gr = 'http://purl.org/goodrelations/v1' -media = 'http://search.yahoo.com/searchmonkey/media/' -cb = 'http://cb.semsol.org/ns' -ps = 'http://schemas.microsoft.com/powershell/2004/04' -task = 'http://schemas.microsoft.com/windows/2004/02/mit/task' -bcp = 'http://schemas.microsoft.com/sqlserver/2004/bulkload/format' -xsi = 'http://www.w3.org/2001/XMLSchema-instance' -m = 'http://schemas.microsoft.com/ado/2007/08/dataservices/metadata' # SharePoint -maml = 'http://schemas.microsoft.com/maml/2004/10' # PowerShell binary module help format (psbinmod help) -cmd = 'http://schemas.microsoft.com/maml/dev/command/2004/10' # psbinmod help -dev = 'http://schemas.microsoft.com/maml/dev/2004/10' # psbinmod help -MSHelp = 'http://msdn.microsoft.com/mshelp' # psbinmod help -msxsl = 'urn:schemas-microsoft-com:xslt' -z = '#RowsetSchema' # https://docs.microsoft.com/sql/ado/guide/data/namespaces#remarks -s = 'uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' -dt = 'uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' -rs = 'urn:schemas-microsoft-com:rowset' -sodipodi = 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' -inkscape = 'http://www.inkscape.org/namespaces/inkscape' -} -$InformationPreference = 'Continue' diff --git a/Write-CallInfo.ps1 b/Write-CallInfo.ps1 deleted file mode 100644 index f211cfd8..00000000 --- a/Write-CallInfo.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -<# -.SYNOPSIS -Prints caller name and parameters to the host for debugging purposes. -#> - -#Requires -Version 3 -[CmdletBinding()] Param() -(Get-Variable MyInvocation -ValueOnly -Scope 1).{MyCommand}?.Name ?? '' |Write-Host -ForegroundColor Cyan -Get-Variable PSBoundParameters -ValueOnly -Scope 1 |ConvertTo-Json -Depth 100 |Write-Host -ForegroundColor DarkGray diff --git a/Write-Info.ps1 b/Write-Info.ps1 deleted file mode 100644 index cbd78359..00000000 --- a/Write-Info.ps1 +++ /dev/null @@ -1,41 +0,0 @@ -<# -.SYNOPSIS -Writes to the information stream, with color support and more. - -.FUNCTIONALITY -PowerShell -#> - -#Requires -Version 5.1 -[CmdletBinding()] Param( -# Message to write to the information stream. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)] $Message, -# Specifies the text color. There is no default. -[Alias('fg')][Nullable[ConsoleColor]] $ForegroundColor, -# Specifies the background color. There is no default. -[Alias('bg')][Nullable[ConsoleColor]] $BackgroundColor, -# Specifies a log file to write the information string to. -[string] $LogFile, -<# -The string representations of the input objects are concatenated to form the output. -No spaces or newlines are inserted between the output strings. -No newline is added after the last output string. -#> -[switch] $NoNewLine, -<# -By default, uses -InformationAction Continue. -This uses the standard $InformationPreference instead. -#> -[switch] $UseInformationPreference -) -Process -{ - if($LogFile) {Add-Content -Path $LogFile -Value $Message -Encoding utf8} - if(!$UseInformationPreference) {$Local:InformationPreference = 'Continue'} - Write-Information ([Management.Automation.HostInformationMessage]@{ - Message = $Message - ForegroundColor = $ForegroundColor - BackgroundColor = $BackgroundColor - NoNewLine = $NoNewLine - }) -} diff --git a/Write-VisibleString.ps1 b/Write-VisibleString.ps1 deleted file mode 100644 index 9f3d79ff..00000000 --- a/Write-VisibleString.ps1 +++ /dev/null @@ -1,78 +0,0 @@ -<# -.SYNOPSIS -Displays a string, showing nonprintable characters. - -.INPUTS -System.Object to serialize with nonprintable characters made visible as a hex pair. - -.EXAMPLE -Write-VisibleString.ps1 "a`tb`nc" - -a 09 b 0A c -(Formatting is not displayed in help.) -#> - -#Requires -Version 7 -[CmdletBinding()][OutputType([void])] Param( -# The string to show. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][object] $InputObject, -# Parse Runes from the string rather than Chars. -[switch] $AsRunes, -# Print control characters as control picture symbols rather than hex values. -[switch] $UseSymbols -) -Begin -{ - $symbolStart = $PSStyle.Reverse - $symbolEnd = $PSStyle.ReverseOff - $shortHexStart = '{0} {1}{2}' -f $PSStyle.Hidden,$PSStyle.HiddenOff,$PSStyle.Reverse - $shortHexEnd = '{0}{1} {2}' -f $PSStyle.ReverseOff,$PSStyle.Hidden,$PSStyle.HiddenOff - $longHexStart = '{0} {1}{2}{3}' -f $PSStyle.Hidden,$PSStyle.HiddenOff,$PSStyle.Reverse,$PSStyle.Bold - $longHexEnd = '{0}{1}{2} {3}' -f $PSStyle.BoldOff,$PSStyle.ReverseOff,$PSStyle.Hidden,$PSStyle.HiddenOff - filter Write-Char([Parameter(ValueFromPipeline)][int] $Value) - { - if(![char]::IsControl($Value) -and ![char]::IsWhiteSpace($Value) -and - ![char]::IsLowSurrogate($Value) -and ![char]::IsHighSurrogate($Value)) - { - return [char]$Value - } - elseif($UseSymbols -and $Value -le 0x20) - { - return '{0}{1}{2}' -f $symbolStart,[char](0x2400+$Value),$symbolEnd - } - elseif($Value -ge 0x100) - { - return '{0}{1:X4}{2}' -f $longHexStart,$Value,$longHexEnd - } - else - { - return '{0}{1:X2}{2}' -f $shortHexStart,$Value,$shortHexEnd - } - } - filter Write-Rune([Parameter(ValueFromPipelineByPropertyName)][int] $Value, - [Parameter(ValueFromPipelineByPropertyName)][bool] $IsAscii, - [Parameter(ValueFromPipelineByPropertyName)][bool] $IsBmp) - { - if($IsAscii -and ![char]::IsControl($Value) -and ![char]::IsWhiteSpace($Value)) - { - return [char]$Value - } - elseif($UseSymbols -and $Value -le 0x20) - { - return '{0}{1}{2}' -f $symbolStart,[char](0x2400+$Value),$symbolEnd - } - elseif($Value -ge 0x100) - { - return '{0}{1:X4}{2}' -f $longHexStart,$Value,$longHexEnd - } - else - { - return '{0}{1:X2}{2}' -f $shortHexStart,$Value,$shortHexEnd - } - } -} -Process -{ - if($AsRunes) {[convert]::ToString($InputObject).EnumerateRunes() |Write-Rune |Out-String -NoNewline |Write-Info.ps1} - else {[convert]::ToString($InputObject).ToCharArray() |Write-Char |Out-String -NoNewline |Write-Info.ps1} -} diff --git a/test/Add-Counter.Tests.ps1 b/test/Add-Counter.Tests.ps1 deleted file mode 100644 index 6dcc9de8..00000000 --- a/test/Add-Counter.Tests.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -<# -.SYNOPSIS -Tests adding an incrementing integer property to each pipeline object. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Add-Counter' -Tag Add-Counter -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Adds a counter property' -Tag AddCounter,Add,Counter { - It "Should number providers" { - [psobject[]] $providers = Get-PSProvider |Add-Counter.ps1 -PropertyName Position -InitialValue 0 -Force - foreach($i in 0..($providers.Count -1)) - { - $providers[$i].Position |Should -Be $i -Because 'Position should be a simple incrementing integer' - } - } - It "Given JSON '', adding a '' counter should result in ''" -Tag From-One -TestCases @( - @{ JsonInput = '[{"name": "A"},{"name": "B"},{"name": "C"}]'; PropertyName = 'id' - JsonOutput = '[{"name":"A","id":1},{"name":"B","id":2},{"name":"C","id":3}]' } - ) { - Param([string]$JsonInput,[string]$PropertyName,[string]$JsonOutput) - $JsonInput | - ConvertFrom-Json | - Add-Counter.ps1 -PropertyName $PropertyName | - ConvertTo-Json -Compress | - Should -BeExactly $JsonOutput -Because 'an incrementing id property should have been added' - } - } -} diff --git a/test/Add-DynamicParam.Tests.ps1 b/test/Add-DynamicParam.Tests.ps1 deleted file mode 100644 index 9b0f1883..00000000 --- a/test/Add-DynamicParam.Tests.ps1 +++ /dev/null @@ -1,68 +0,0 @@ -<# -.SYNOPSIS -Tests adding a dynamic parameter to a DynamicParam object. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Add-DynamicParam' -Tag Add-DynamicParam -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Adding parameters' -Tag AddDynamicParam,Add,'DynamicParam' { - It "Should add a required string parameter" { - Add-DynamicParam.ps1 -Name Path -Type string -Mandatory - $DynamicParams.Count |Should -Be 1 -Because 'one should have been added' - $DynamicParams.Keys |Should -Contain Path -Because 'the right one should have been added' - $DynamicParams['Path'].ParameterType |Should -Be string -Because 'it should be the right type' - $DynamicParams['Path'].Attributes.Count |Should -Be 1 -Because 'one attribute should exist' - $DynamicParams['Path'].Attributes[0].ParameterSetName |Should -BeExactly __AllParameterSets -Because 'the parameter set should be the default' - $DynamicParams['Path'].Attributes[0].Mandatory |Should -BeTrue -Because 'it should be required' - $DynamicParams['Path'].Attributes[0].ValueFromPipeline |Should -BeFalse -Because 'it shouldn''t accept values from the pipeline' - $DynamicParams['Path'].Attributes[0].ValueFromPipelineByPropertyName |Should -BeFalse -Because 'it shouldn''t accept the property from the pipeline' - $DynamicParams['Path'].Attributes[0].ValueFromRemainingArguments |Should -BeFalse -Because 'it shouldn''t accept the rest of the unnamed params' - } - It "Should add several alternative parameters" { - Add-DynamicParam.ps1 -Name Document -Type Xml.XmlDocument -ParameterSetName Document ` - -Position 0 -Mandatory -ValueFromPipeline - Add-DynamicParam.ps1 -Name Element -Type Xml.XmlElement -Parameter Element ` - -Position 0 -Mandatory -ValueFromPipeline - Add-DynamicParam.ps1 -Name SelectXmlInfo -Type Microsoft.PowerShell.Commands.SelectXmlInfo ` - -ParameterSetName SelectXmlInfo -Position 0 -Mandatory -ValueFromPipeline - $DynamicParams.Count |Should -Be 3 -Because 'three should''ve been added' - $DynamicParams.Keys |Should -Contain Document - $DynamicParams['Document'].ParameterType |Should -Be xml - $DynamicParams['Document'].Attributes.Count |Should -Be 1 - $DynamicParams['Document'].Attributes[0].ParameterSetName |Should -BeExactly Document - $DynamicParams['Document'].Attributes[0].Position |Should -BeExactly 0 - $DynamicParams['Document'].Attributes[0].Mandatory |Should -BeTrue - $DynamicParams['Document'].Attributes[0].ValueFromPipeline |Should -BeTrue - $DynamicParams['Document'].Attributes[0].ValueFromPipelineByPropertyName |Should -BeFalse - $DynamicParams['Document'].Attributes[0].ValueFromRemainingArguments |Should -BeFalse - $DynamicParams.Keys |Should -Contain Element - $DynamicParams['Element'].ParameterType |Should -Be System.Xml.XmlElement - $DynamicParams['Element'].Attributes.Count |Should -Be 1 - $DynamicParams['Element'].Attributes[0].ParameterSetName |Should -BeExactly Element - $DynamicParams['Element'].Attributes[0].Position |Should -BeExactly 0 - $DynamicParams['Element'].Attributes[0].Mandatory |Should -BeTrue - $DynamicParams['Element'].Attributes[0].ValueFromPipeline |Should -BeTrue - $DynamicParams['Element'].Attributes[0].ValueFromPipelineByPropertyName |Should -BeFalse - $DynamicParams['Element'].Attributes[0].ValueFromRemainingArguments |Should -BeFalse - $DynamicParams.Keys |Should -Contain SelectXmlInfo - $DynamicParams['SelectXmlInfo'].ParameterType |Should -Be Microsoft.PowerShell.Commands.SelectXmlInfo - $DynamicParams['SelectXmlInfo'].Attributes.Count |Should -Be 1 - $DynamicParams['SelectXmlInfo'].Attributes[0].ParameterSetName |Should -BeExactly SelectXmlInfo - $DynamicParams['SelectXmlInfo'].Attributes[0].Position |Should -BeExactly 0 - $DynamicParams['SelectXmlInfo'].Attributes[0].Mandatory |Should -BeTrue - $DynamicParams['SelectXmlInfo'].Attributes[0].ValueFromPipeline |Should -BeTrue - $DynamicParams['SelectXmlInfo'].Attributes[0].ValueFromPipelineByPropertyName |Should -BeFalse - $DynamicParams['SelectXmlInfo'].Attributes[0].ValueFromRemainingArguments |Should -BeFalse - } - } - AfterEach { - Remove-Variable -Name DynamicParam -Force -ErrorAction Ignore - } -} diff --git a/test/Add-NoteProperty.Tests.ps1 b/test/Add-NoteProperty.Tests.ps1 deleted file mode 100644 index 77afd8f7..00000000 --- a/test/Add-NoteProperty.Tests.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -<# -.SYNOPSIS -Tests adding a NoteProperty to a PSObject, calculating the value with the object in context. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Add-NoteProperty' -Tag Add-NoteProperty -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Add a calculated property value' -Tag AddNoteProperty,Add,NoteProperty { - It "Should add a property with a static value calculated when added" { - $value = [pscustomobject]@{x=8} |Add-NoteProperty.ps1 bits {[math]::Log2($_.x)} -PassThru - $value.x = 16 # this should not change the pow property - $value.bits |Should -Be 3 -Because 'the bits property value should have been determined only when added' - } - It "Should add multiple properties with a mix of value types" { - $value = [pscustomobject]@{x=8} |Add-NoteProperty.ps1 @{ - bits = {[math]::Log2($_.x)} - format = {'<{0:X}>' -f ($_.x*4)} - isNumeric = $true - } -PassThru - $value.x = 16 # this should not change the pow property - $value.bits |Should -Be 3 -Because 'the bits property value should be statically evaluated' - $value.format |Should -Be '<20>' -Because 'the binary property should be statically evaluated' - $value.isNumeric |Should -BeTrue -Because 'the isNumeric property should be true' - } - } -} diff --git a/test/Add-ParameterDefault.Tests.ps1 b/test/Add-ParameterDefault.Tests.ps1 deleted file mode 100644 index 48706c52..00000000 --- a/test/Add-ParameterDefault.Tests.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# -.SYNOPSIS -Tests appending or creating a value to use for the specified cmdlet parameter to use when one is not specified. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Add-ParameterDefault' -Tag Add-ParameterDefault -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Appends or creates a value to use for the specified cmdlet parameter to use when one is not specified.' ` - -Tag AddParameterDefault,Add,ParameterDefault { - It "Should set a simple default" { - Add-ParameterDefault.ps1 epcsv nti $true -Scope Global - $PSDefaultParameterValues.ContainsKey('Export-Csv:NoTypeInformation') | - Should -BeTrue -Because 'defaults should be added after looking up cmdlet and param aliases' - $PSDefaultParameterValues['Export-Csv:NoTypeInformation'] |Should -BeTrue - } - It "Should set a hashtable default" { - Add-ParameterDefault.ps1 Select-Xml Namespace @{svg = 'http://www.w3.org/2000/svg'} - $PSDefaultParameterValues.ContainsKey('Select-Xml:Namespace') |Should -BeTrue - $PSDefaultParameterValues['Select-Xml:Namespace'].ContainsKey('svg') |Should -BeTrue - $PSDefaultParameterValues['Select-Xml:Namespace']['svg'] |Should -BeExactly 'http://www.w3.org/2000/svg' - } - } -} diff --git a/test/Add-ScopeLevel.Tests.ps1 b/test/Add-ScopeLevel.Tests.ps1 deleted file mode 100644 index 867d1a8e..00000000 --- a/test/Add-ScopeLevel.Tests.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -<# -.SYNOPSIS -Tests conversion of a scope level to account for another call stack level. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Add-ScopeLevel' -Tag Add-ScopeLevel -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Convert a scope level to account for another call stack level.' -Tag AddScopeLevel,Add,ScopeLevel { - It 'Should calculate local scope' { - Add-ScopeLevel.ps1 Local |Should -BeExactly '1' -Because 'local is zero scope' - } - It 'Should calculate a numeric scope' { - 1..8 |ForEach-Object {Add-ScopeLevel.ps1 $_ |Should -BeExactly "$($_+1)"} - } - It 'Should calulate global scope' { - Add-ScopeLevel.ps1 Global |Should -BeExactly Global -Because 'global is the top scope' - } - } -} diff --git a/test/Compare-Properties.Tests.ps1 b/test/Compare-Properties.Tests.ps1 deleted file mode 100644 index 3a1cf861..00000000 --- a/test/Compare-Properties.Tests.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -<# -.SYNOPSIS -Tests comparing the properties of two objects. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Compare-Properties' -Tag Compare-Properties -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Compares the properties of two objects' -Tag CompareProperties,Compare,Properties { - It 'Should find the difference between PSProviders' { - $diff = Compare-Properties.ps1 (Get-PSProvider variable) (Get-PSProvider alias) |Sort-Object PropertyName - $diff.Reference |Should -BeTrue - $diff.Difference |Should -BeTrue - $imptype = $diff |Where-Object PropertyName -eq ImplementingType - $imptype.Value |Should -BeExactly Microsoft.PowerShell.Commands.VariableProvider - $imptype.DifferentValue |Should -BeExactly Microsoft.PowerShell.Commands.AliasProvider - $name = $diff |Where-Object PropertyName -eq Name - $name.Value |Should -BeExactly Variable - $name.DifferentValue |Should -BeExactly Alias - } - } -} diff --git a/test/ConvertTo-SafeEntities.Tests.ps1 b/test/ConvertTo-SafeEntities.Tests.ps1 deleted file mode 100644 index cb898325..00000000 --- a/test/ConvertTo-SafeEntities.Tests.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -<# -.SYNOPSIS -Tests encoding text as XML/HTML, escaping all characters outside 7-bit ASCII. -#> - -#Requires -Version 7 -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertTo-SafeEntities' -Tag ConvertTo-SafeEntities -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Encode text as XML/HTML, escaping all characters outside 7-bit ASCII' ` - -Tag Convert,ConvertTo,ConvertToSafeEntities,SafeEntities,Entities,HTML,XML { - It "Should convert '' to ''" -TestCases @( - @{ Value = "$([Text.Rune]0x1F4A1) File $([char]0x2192) Save"; Result = '💡 File → Save' } - @{ Value = "$([char]0xD83D)$([char]0xDCA1) File $([char]0x2192) Save"; Result = '💡 File → Save' } - @{ Value = "ETA: $([char]0xBD) hour"; Result = 'ETA: ½ hour' } - @{ Value = "$([Text.Rune]0x1F41B) fix bug"; Result = '🐛 fix bug' } - @{ Value = "$([char]0xD83D)$([char]0xDC1B) fix bug"; Result = '🐛 fix bug' } - @{ Value = "$([Text.Rune]0x1F9EA) new test"; Result = '🧪 new test' } - @{ Value = "$([char]0xD83E)$([char]0xDDEA) new test"; Result = '🧪 new test' } - ) { - Param([string] $Value, [string] $Result) - $Value |ConvertTo-SafeEntities.ps1 |Should -BeExactly $Result -Because 'pipeline should work' - ConvertTo-SafeEntities.ps1 $Value |Should -BeExactly $Result -Because 'parameter should work' - } - } -} diff --git a/test/Copy-Html.Tests.ps1 b/test/Copy-Html.Tests.ps1 deleted file mode 100644 index 75fb5138..00000000 --- a/test/Copy-Html.Tests.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -<# -.SYNOPSIS -Tests copying objects as an HTML table. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Copy-Html' -Tag Copy-Html -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Copies objects as an HTML table' -Tag CopyHtml,Copy,Html { - It "Should copy objects as HTML" -TestCases @( - @{ InputObject = '[{Id: 1, Name: "First"}, {Id: 2, Name: "Second"}, {Id: 3, Name: "Third"}]' |ConvertFrom-Json - Result = @' -* - - - -
IdName
1First
2Second
3Third
* -'@ } - ) { - Param([object] $InputObject, [object] $Result) - $InputObject |Copy-Html.ps1 Id,Name - powershell -nol -noni -nop -c "Get-Clipboard -TextFormatType Html" |Out-String | - Should -BeLikeExactly $Result -Because 'pipeline should work' - Copy-Html.ps1 Id,Name -InputObject $InputObject - powershell -nol -noni -nop -c "Get-Clipboard -TextFormatType Html" |Out-String | - Should -BeLikeExactly $Result -Because 'parameter should work' - } - } - -} diff --git a/test/Format-ByteUnits.Tests.ps1 b/test/Format-ByteUnits.Tests.ps1 deleted file mode 100644 index a63c9d04..00000000 --- a/test/Format-ByteUnits.Tests.ps1 +++ /dev/null @@ -1,63 +0,0 @@ -<# -.SYNOPSIS -Tests converting bytes to largest possible units, to improve readability. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Format-ByteUnits' -Tag Format-ByteUnits -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Converts bytes to largest possible units, to improve readability' -Tag FormatByteUnits,Format,ByteUnits { - It "Formatting '', up to '' digits after the decimal returns '', or ' for SI'" -TestCases @( - @{ Bytes = 0; Precision = 16; Result = '0'; SIResult = '0' } - @{ Bytes = 1; Precision = 16; Result = '1'; SIResult = '1 B' } - @{ Bytes = 999; Precision = 16; Result = '999'; SIResult = '999 B' } - @{ Bytes = 0KB; Precision = 16; Result = '0'; SIResult = '0' } - @{ Bytes = 1KB; Precision = 16; Result = '1KB'; SIResult = '1 KiB' } - @{ Bytes = 999KB; Precision = 16; Result = '999KB'; SIResult = '999 KiB' } - @{ Bytes = 1MB; Precision = 16; Result = '1MB'; SIResult = '1 MiB' } - @{ Bytes = 999MB; Precision = 16; Result = '999MB'; SIResult = '999 MiB' } - @{ Bytes = 1GB; Precision = 16; Result = '1GB'; SIResult = '1 GiB' } - @{ Bytes = 999GB; Precision = 16; Result = '999GB'; SIResult = '999 GiB' } - @{ Bytes = 1TB; Precision = 16; Result = '1TB'; SIResult = '1 TiB' } - @{ Bytes = 999TB; Precision = 16; Result = '999TB'; SIResult = '999 TiB' } - @{ Bytes = 1PB; Precision = 16; Result = '1PB'; SIResult = '1 PiB' } - @{ Bytes = 999PB; Precision = 16; Result = '999PB'; SIResult = '999 PiB' } - @{ Bytes = 999999999999999999N; Precision = 2; Result = '888.18PB'; SIResult = '888.18 PiB' } - @{ Bytes = 1234567890L; Precision = 2; Result = '1.15GB'; SIResult = '1.15 GiB' } - @{ Bytes = 1234567890L; Precision = 1; Result = '1.1GB'; SIResult = '1.1 GiB' } - @{ Bytes = 1234567890L; Precision = 0; Result = '1GB'; SIResult = '1 GiB' } - @{ Bytes = 987654321000; Precision = 16; Result = '919.824765063822GB'; SIResult = '919.824765063822 GiB' } - @{ Bytes = 987654321000; Precision = 12; Result = '919.824765063822GB'; SIResult = '919.824765063822 GiB' } - @{ Bytes = 987654321000; Precision = 11; Result = '919.82476506382GB'; SIResult = '919.82476506382 GiB' } - @{ Bytes = 987654321000; Precision = 10; Result = '919.8247650638GB'; SIResult = '919.8247650638 GiB' } - @{ Bytes = 987654321000; Precision = 9; Result = '919.824765064GB'; SIResult = '919.824765064 GiB' } - @{ Bytes = 987654321000; Precision = 8; Result = '919.82476506GB'; SIResult = '919.82476506 GiB' } - @{ Bytes = 987654321000; Precision = 7; Result = '919.8247651GB'; SIResult = '919.8247651 GiB' } - @{ Bytes = 987654321000; Precision = 6; Result = '919.824765GB'; SIResult = '919.824765 GiB' } - @{ Bytes = 987654321000; Precision = 5; Result = '919.82477GB'; SIResult = '919.82477 GiB' } - @{ Bytes = 987654321000; Precision = 4; Result = '919.8248GB'; SIResult = '919.8248 GiB' } - @{ Bytes = 987654321000; Precision = 3; Result = '919.825GB'; SIResult = '919.825 GiB' } - @{ Bytes = 987654321000; Precision = 2; Result = '919.82GB'; SIResult = '919.82 GiB' } - @{ Bytes = 987654321000; Precision = 1; Result = '919.8GB'; SIResult = '919.8 GiB' } - @{ Bytes = 987654321000; Precision = 0; Result = '920GB'; SIResult = '920 GiB' } - @{ Bytes = 9685059; Precision = 1; Result = '9.2MB'; SIResult = '9.2 MiB' } - ) { - Param([bigint] $Bytes, [byte] $Precision, [string] $Result, [string] $SIResult) - Format-ByteUnits.ps1 -Bytes $Bytes -Precision $Precision | - Should -BeExactly $Result -Because 'parameter should work' - $Bytes |Format-ByteUnits.ps1 -Precision $Precision | - Should -BeExactly $Result -Because 'pipeline should work' - Format-ByteUnits.ps1 -Bytes $Bytes -Precision $Precision -UseSI | - Should -BeExactly $SIResult -Because 'SI parameter should work' - $Bytes |Format-ByteUnits.ps1 -Precision $Precision -UseSI | - Should -BeExactly $SIResult -Because 'SI pipeline should work' - } - } - -} From b7943acc62b084dcb9d21cc83278359b1181ae10 Mon Sep 17 00:00:00 2001 From: Brian Lalonde Date: Tue, 28 Apr 2026 20:54:44 -0700 Subject: [PATCH 2/7] =?UTF-8?q?=EF=BB=BF=F0=9F=94=A5=20Remove=20scripts=20?= =?UTF-8?q?moved=20to=20ModernConveniences=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 2 +- Add-CapturesToMatches.ps1 | 56 -- Add-TimeSpan.ps1 | 30 - Compare-Keys.ps1 | 116 ---- Convert-ClipboardTsvToHtml.ps1 | 27 - Convert-ExternalScriptToModule.ps1 | 66 ++ Convert-ICalToMermaidGantt.ps1 | 144 ----- ConvertFrom-Base64.ps1 | 73 --- ConvertFrom-CimInstance.ps1 | 7 +- ConvertFrom-DataRow.ps1 | 1 - ConvertFrom-Duration.ps1 | 96 --- ConvertFrom-EpochTime.ps1 | 36 -- ConvertFrom-Hex.ps1 | 50 -- ConvertFrom-IsoWeekDate.ps1 | 44 -- ConvertTo-Base64.ps1 | 62 -- ConvertTo-EpochTime.ps1 | 42 -- ConvertTo-FileName.ps1 | 93 --- ConvertTo-OrderedDictionary.ps1 | 33 - ConvertTo-PowerShell.ps1 | 318 ---------- ConvertTo-RomanNumeral.ps1 | 62 -- Disable-AnsiColor.ps1 | 23 - Enable-AnsiColor.ps1 | 23 - Expand-EnvironmentVariables.ps1 | 22 - Export-MermaidXY.ps1 | 74 --- Export-OpenApiSchema.ps1 | 15 +- Export-Readme.ps1 | 7 + Find-NewestFile.ps1 | 35 -- Format-Date.ps1 | 61 -- Format-EscapedUrl.ps1 | 55 -- Get-CommandParameters.ps1 | 116 ---- Get-CommandPath.ps1 | 69 --- Get-ConsoleHistory.ps1 | 67 -- Get-FrenchRepublicanDate.ps1 | 235 ------- Get-OutdatedModules.ps1 | 35 -- Import-ClipboardTsv.ps1 | 35 -- Invoke-CachedCommand.ps1 | 114 ---- Join-Keys.ps1 | 72 --- Limit-Digits.ps1 | 35 -- Measure-Properties.ps1 | 107 ---- Measure-Values.ps1 | 299 --------- README.md | 145 +---- Remove-ConsoleHistory.ps1 | 81 --- Remove-NullValues.ps1 | 33 - Repair-MarkdownHeaders.ps1 | 121 ---- Save-PodcastEpisodes.ps1 | 1 - Save-WebRequest.ps1 | 1 - Select-CapturesFromMatches.ps1 | 53 -- Select-ScriptCommands.ps1 | 61 -- Set-RegexReplace.ps1 | 101 --- Show-OpenApiInfo.ps1 | 5 +- Show-PSDriveUsage.ps1 | 84 --- Show-Status.ps1 | 186 ------ Show-Time.ps1 | 48 -- Split-Keys.ps1 | 64 -- Split-Uri.ps1 | 179 ------ Test-DateTime.ps1 | 49 -- Test-FileTypeMagicNumber.ps1 | 209 ------- Test-Interactive.ps1 | 20 - Test-MagicNumber.ps1 | 70 --- Test-NewerFile.ps1 | 50 -- Test-USFederalHoliday.ps1 | 129 ---- Test-Uri.ps1 | 36 -- Trace-WebRequest.ps1 | 303 +++++---- Update-Files.ps1 | 37 -- docs/Add-CapturesToMatches.ps1.md | 82 --- docs/Add-Counter.ps1.md | 130 ---- docs/Add-DynamicParam.ps1.md | 367 ----------- docs/Add-NoteProperty.ps1.md | 197 ------ docs/Add-NotebookCell.ps1.md | 18 +- docs/Add-NugetPackage.ps1.md | 93 --- docs/Add-ParameterDefault.ps1.md | 136 ---- docs/Add-TimeSpan.ps1.md | 90 --- docs/Compare-Keys.ps1.md | 139 ----- docs/Compare-Properties.ps1.md | 145 ----- docs/Convert-ClipboardTsvToHtml.ps1.md | 57 -- docs/ConvertFrom-Base64.ps1.md | 112 ---- docs/ConvertFrom-CimInstance.ps1.md | 75 --- docs/ConvertFrom-DataRow.ps1.md | 119 ---- docs/ConvertFrom-Duration.ps1.md | 113 ---- docs/ConvertFrom-EpochTime.ps1.md | 97 --- docs/ConvertFrom-Hex.ps1.md | 95 --- docs/ConvertFrom-IsoWeekDate.ps1.md | 72 --- docs/ConvertFrom-XmlElement.ps1.md | 25 +- docs/ConvertTo-Base64.ps1.md | 131 ---- docs/ConvertTo-EpochTime.ps1.md | 97 --- docs/ConvertTo-FileName.ps1.md | 196 ------ docs/ConvertTo-OrderedDictionary.ps1.md | 76 --- docs/ConvertTo-PowerShell.ps1.md | 255 -------- docs/ConvertTo-RomanNumeral.ps1.md | 102 --- docs/ConvertTo-SafeEntities.ps1.md | 106 ---- docs/Copy-Html.ps1.md | 98 --- docs/Disable-AnsiColor.ps1.md | 75 --- docs/Enable-AnsiColor.ps1.md | 75 --- docs/Expand-EnvironmentVariables.ps1.md | 75 --- docs/Export-MermaidXY.ps1.md | 173 ------ docs/Export-OpenApiSchema.ps1.md | 155 ----- docs/Find-NewestFile.ps1.md | 82 --- docs/ForEach-Progress.ps1.md | 117 ---- docs/Format-ByteUnits.ps1.md | 125 ---- docs/Format-Date.ps1.md | 99 --- docs/Format-EscapedUrl.ps1.md | 105 ---- docs/Format-HtmlDataTable.ps1.md | 180 ------ docs/Format-Permutations.ps1.md | 108 ---- docs/Get-CommandParameters.ps1.md | 138 ----- docs/Get-CommandPath.ps1.md | 95 --- docs/Get-ConsoleHistory.ps1.md | 139 ----- docs/Get-EnumValues.ps1.md | 146 ----- docs/Get-FrenchRepublicanDate.ps1.md | 137 ----- docs/Get-ModuleScope.ps1.md | 89 --- docs/Get-RandomBytes.ps1.md | 83 --- docs/Get-SecretDetails.ps1.md | 33 +- docs/Get-TypeAccelerators.ps1.md | 167 ----- docs/Import-ClipboardTsv.ps1.md | 87 --- docs/Import-Variables.ps1.md | 149 ----- docs/Invoke-CachedCommand.ps1.md | 146 ----- docs/Invoke-WindowsPowerShell.ps1.md | 129 ---- docs/Join-Keys.ps1.md | 153 ----- docs/Limit-Digits.ps1.md | 114 ---- docs/Measure-Properties.ps1.md | 97 --- docs/Measure-Values.ps1.md | 151 ----- docs/Merge-PSObject.ps1.md | 145 ----- docs/New-Script.ps1.md | 17 +- docs/Read-Choice.ps1.md | 164 ----- docs/Remove-ConsoleHistory.ps1.md | 183 ------ docs/Remove-NullValues.ps1.md | 77 --- docs/Remove-ParameterDefault.ps1.md | 121 ---- docs/Repair-MarkdownHeaders.ps1.md | 152 ----- docs/Save-PodcastEpisodes.ps1.md | 166 ----- docs/Save-WebRequest.ps1.md | 150 ----- docs/Select-CapturesFromMatches.ps1.md | 94 --- docs/Select-ScriptCommands.ps1.md | 103 ---- docs/Set-ParameterDefault.ps1.md | 136 ---- docs/Set-RegexReplace.ps1.md | 117 ---- docs/Set-TerminalProfile.ps1.md | 82 +++ docs/Show-OpenApiInfo.ps1.md | 80 --- docs/Show-PSDriveUsage.ps1.md | 80 --- docs/Show-Status.ps1.md | 127 ---- docs/Show-Time.ps1.md | 144 ----- docs/Split-Keys.ps1.md | 119 ---- docs/Split-Uri.ps1.md | 580 ------------------ docs/Stop-ThrowError.ps1.md | 357 ----------- docs/Test-Administrator.ps1.md | 42 -- docs/Test-DateTime.ps1.md | 114 ---- docs/Test-FileTypeMagicNumber.ps1.md | 116 ---- docs/Test-MagicNumber.ps1.md | 125 ---- docs/Test-NewerFile.ps1.md | 89 --- docs/Test-NoteProperty.ps1.md | 99 --- docs/Test-Range.ps1.md | 99 --- docs/Test-USFederalHoliday.ps1.md | 158 ----- docs/Test-Uri.ps1.md | 98 --- docs/Test-Variable.ps1.md | 136 ---- ...ive.ps1.md => Test-WindowsTerminal.ps1.md} | 15 +- docs/Trace-WebRequest.ps1.md | 235 ------- docs/Uninstall-OldModules.ps1.md | 105 ---- docs/Update-Files.ps1.md | 136 ---- docs/Update-Modules.ps1.md | 58 -- docs/Use-ProgressView.ps1.md | 76 --- docs/Use-ReasonableDefaults.ps1.md | 86 --- docs/Write-CallInfo.ps1.md | 57 -- docs/Write-Info.ps1.md | 154 ----- docs/Write-VisibleString.ps1.md | 105 ---- docs/index.md | 565 +++++++---------- scripts-to-modules.json | 159 +++++ test/Add-CapturesToMatches.Tests.ps1 | 26 - test/Add-TimeSpan.Tests.ps1 | 31 - test/Compare-Keys.Tests.ps1 | 43 -- test/Convert-ClipboardTsvToHtml.Tests.ps1 | 70 --- test/ConvertFrom-Base64.Tests.ps1 | 31 - test/ConvertFrom-CimInstance.Tests.ps1 | 25 +- test/ConvertFrom-DataRow.Tests.ps1 | 23 +- test/ConvertFrom-Duration.Tests.ps1 | 44 -- test/ConvertFrom-EpochTime.Tests.ps1 | 29 - test/ConvertFrom-Hex.Tests.ps1 | 26 - test/ConvertFrom-IsoWeekDate.Tests.ps1 | 30 - test/ConvertTo-Base64.Tests.ps1 | 31 - test/ConvertTo-EpochTime.Tests.ps1 | 30 - test/ConvertTo-OrderedDictionary.Tests.ps1 | 35 -- test/ConvertTo-PowerShell.Tests.ps1 | 114 ---- test/ConvertTo-RomanNumeral.Tests.ps1 | 112 ---- test/Disable-AnsiColor.Tests.ps1 | 25 - test/Enable-AnsiColor.Tests.ps1 | 25 - test/Expand-EnvironmentVariables.Tests.ps1 | 26 - test/Export-OpenApiSchema.Tests.ps1 | 27 +- test/Find-NewestFile.Tests.ps1 | 26 - test/ForEach-Progress.Tests.ps1 | 23 - test/README.md | 520 ++++++---------- test/Select-CapturesFromMatches.Tests.ps1 | 27 - 187 files changed, 998 insertions(+), 17990 deletions(-) delete mode 100644 Add-CapturesToMatches.ps1 delete mode 100644 Add-TimeSpan.ps1 delete mode 100644 Compare-Keys.ps1 delete mode 100644 Convert-ClipboardTsvToHtml.ps1 create mode 100644 Convert-ExternalScriptToModule.ps1 delete mode 100644 Convert-ICalToMermaidGantt.ps1 delete mode 100644 ConvertFrom-Base64.ps1 delete mode 100644 ConvertFrom-Duration.ps1 delete mode 100644 ConvertFrom-EpochTime.ps1 delete mode 100644 ConvertFrom-Hex.ps1 delete mode 100644 ConvertFrom-IsoWeekDate.ps1 delete mode 100644 ConvertTo-Base64.ps1 delete mode 100644 ConvertTo-EpochTime.ps1 delete mode 100644 ConvertTo-FileName.ps1 delete mode 100644 ConvertTo-OrderedDictionary.ps1 delete mode 100644 ConvertTo-PowerShell.ps1 delete mode 100644 ConvertTo-RomanNumeral.ps1 delete mode 100644 Disable-AnsiColor.ps1 delete mode 100644 Enable-AnsiColor.ps1 delete mode 100644 Expand-EnvironmentVariables.ps1 delete mode 100644 Export-MermaidXY.ps1 delete mode 100644 Find-NewestFile.ps1 delete mode 100644 Format-Date.ps1 delete mode 100644 Format-EscapedUrl.ps1 delete mode 100644 Get-CommandParameters.ps1 delete mode 100644 Get-CommandPath.ps1 delete mode 100644 Get-ConsoleHistory.ps1 delete mode 100644 Get-FrenchRepublicanDate.ps1 delete mode 100644 Get-OutdatedModules.ps1 delete mode 100644 Import-ClipboardTsv.ps1 delete mode 100644 Invoke-CachedCommand.ps1 delete mode 100644 Join-Keys.ps1 delete mode 100644 Limit-Digits.ps1 delete mode 100644 Measure-Properties.ps1 delete mode 100644 Measure-Values.ps1 delete mode 100644 Remove-ConsoleHistory.ps1 delete mode 100644 Remove-NullValues.ps1 delete mode 100644 Repair-MarkdownHeaders.ps1 delete mode 100644 Select-CapturesFromMatches.ps1 delete mode 100644 Select-ScriptCommands.ps1 delete mode 100644 Set-RegexReplace.ps1 delete mode 100644 Show-PSDriveUsage.ps1 delete mode 100644 Show-Status.ps1 delete mode 100644 Show-Time.ps1 delete mode 100644 Split-Keys.ps1 delete mode 100644 Split-Uri.ps1 delete mode 100644 Test-DateTime.ps1 delete mode 100644 Test-FileTypeMagicNumber.ps1 delete mode 100644 Test-Interactive.ps1 delete mode 100644 Test-MagicNumber.ps1 delete mode 100644 Test-NewerFile.ps1 delete mode 100644 Test-USFederalHoliday.ps1 delete mode 100644 Test-Uri.ps1 delete mode 100644 Update-Files.ps1 delete mode 100644 docs/Add-CapturesToMatches.ps1.md delete mode 100644 docs/Add-Counter.ps1.md delete mode 100644 docs/Add-DynamicParam.ps1.md delete mode 100644 docs/Add-NoteProperty.ps1.md delete mode 100644 docs/Add-NugetPackage.ps1.md delete mode 100644 docs/Add-ParameterDefault.ps1.md delete mode 100644 docs/Add-TimeSpan.ps1.md delete mode 100644 docs/Compare-Keys.ps1.md delete mode 100644 docs/Compare-Properties.ps1.md delete mode 100644 docs/Convert-ClipboardTsvToHtml.ps1.md delete mode 100644 docs/ConvertFrom-Base64.ps1.md delete mode 100644 docs/ConvertFrom-CimInstance.ps1.md delete mode 100644 docs/ConvertFrom-DataRow.ps1.md delete mode 100644 docs/ConvertFrom-Duration.ps1.md delete mode 100644 docs/ConvertFrom-EpochTime.ps1.md delete mode 100644 docs/ConvertFrom-Hex.ps1.md delete mode 100644 docs/ConvertFrom-IsoWeekDate.ps1.md delete mode 100644 docs/ConvertTo-Base64.ps1.md delete mode 100644 docs/ConvertTo-EpochTime.ps1.md delete mode 100644 docs/ConvertTo-FileName.ps1.md delete mode 100644 docs/ConvertTo-OrderedDictionary.ps1.md delete mode 100644 docs/ConvertTo-PowerShell.ps1.md delete mode 100644 docs/ConvertTo-RomanNumeral.ps1.md delete mode 100644 docs/ConvertTo-SafeEntities.ps1.md delete mode 100644 docs/Copy-Html.ps1.md delete mode 100644 docs/Disable-AnsiColor.ps1.md delete mode 100644 docs/Enable-AnsiColor.ps1.md delete mode 100644 docs/Expand-EnvironmentVariables.ps1.md delete mode 100644 docs/Export-MermaidXY.ps1.md delete mode 100644 docs/Export-OpenApiSchema.ps1.md delete mode 100644 docs/Find-NewestFile.ps1.md delete mode 100644 docs/ForEach-Progress.ps1.md delete mode 100644 docs/Format-ByteUnits.ps1.md delete mode 100644 docs/Format-Date.ps1.md delete mode 100644 docs/Format-EscapedUrl.ps1.md delete mode 100644 docs/Format-HtmlDataTable.ps1.md delete mode 100644 docs/Format-Permutations.ps1.md delete mode 100644 docs/Get-CommandParameters.ps1.md delete mode 100644 docs/Get-CommandPath.ps1.md delete mode 100644 docs/Get-ConsoleHistory.ps1.md delete mode 100644 docs/Get-EnumValues.ps1.md delete mode 100644 docs/Get-FrenchRepublicanDate.ps1.md delete mode 100644 docs/Get-ModuleScope.ps1.md delete mode 100644 docs/Get-RandomBytes.ps1.md delete mode 100644 docs/Get-TypeAccelerators.ps1.md delete mode 100644 docs/Import-ClipboardTsv.ps1.md delete mode 100644 docs/Import-Variables.ps1.md delete mode 100644 docs/Invoke-CachedCommand.ps1.md delete mode 100644 docs/Invoke-WindowsPowerShell.ps1.md delete mode 100644 docs/Join-Keys.ps1.md delete mode 100644 docs/Limit-Digits.ps1.md delete mode 100644 docs/Measure-Properties.ps1.md delete mode 100644 docs/Measure-Values.ps1.md delete mode 100644 docs/Merge-PSObject.ps1.md delete mode 100644 docs/Read-Choice.ps1.md delete mode 100644 docs/Remove-ConsoleHistory.ps1.md delete mode 100644 docs/Remove-NullValues.ps1.md delete mode 100644 docs/Remove-ParameterDefault.ps1.md delete mode 100644 docs/Repair-MarkdownHeaders.ps1.md delete mode 100644 docs/Save-PodcastEpisodes.ps1.md delete mode 100644 docs/Save-WebRequest.ps1.md delete mode 100644 docs/Select-CapturesFromMatches.ps1.md delete mode 100644 docs/Select-ScriptCommands.ps1.md delete mode 100644 docs/Set-ParameterDefault.ps1.md delete mode 100644 docs/Set-RegexReplace.ps1.md create mode 100644 docs/Set-TerminalProfile.ps1.md delete mode 100644 docs/Show-OpenApiInfo.ps1.md delete mode 100644 docs/Show-PSDriveUsage.ps1.md delete mode 100644 docs/Show-Status.ps1.md delete mode 100644 docs/Show-Time.ps1.md delete mode 100644 docs/Split-Keys.ps1.md delete mode 100644 docs/Split-Uri.ps1.md delete mode 100644 docs/Stop-ThrowError.ps1.md delete mode 100644 docs/Test-Administrator.ps1.md delete mode 100644 docs/Test-DateTime.ps1.md delete mode 100644 docs/Test-FileTypeMagicNumber.ps1.md delete mode 100644 docs/Test-MagicNumber.ps1.md delete mode 100644 docs/Test-NewerFile.ps1.md delete mode 100644 docs/Test-NoteProperty.ps1.md delete mode 100644 docs/Test-Range.ps1.md delete mode 100644 docs/Test-USFederalHoliday.ps1.md delete mode 100644 docs/Test-Uri.ps1.md delete mode 100644 docs/Test-Variable.ps1.md rename docs/{Test-Interactive.ps1.md => Test-WindowsTerminal.ps1.md} (67%) delete mode 100644 docs/Trace-WebRequest.ps1.md delete mode 100644 docs/Uninstall-OldModules.ps1.md delete mode 100644 docs/Update-Files.ps1.md delete mode 100644 docs/Update-Modules.ps1.md delete mode 100644 docs/Use-ProgressView.ps1.md delete mode 100644 docs/Use-ReasonableDefaults.ps1.md delete mode 100644 docs/Write-CallInfo.ps1.md delete mode 100644 docs/Write-Info.ps1.md delete mode 100644 docs/Write-VisibleString.ps1.md create mode 100644 scripts-to-modules.json delete mode 100644 test/Add-CapturesToMatches.Tests.ps1 delete mode 100644 test/Add-TimeSpan.Tests.ps1 delete mode 100644 test/Compare-Keys.Tests.ps1 delete mode 100644 test/Convert-ClipboardTsvToHtml.Tests.ps1 delete mode 100644 test/ConvertFrom-Base64.Tests.ps1 delete mode 100644 test/ConvertFrom-Duration.Tests.ps1 delete mode 100644 test/ConvertFrom-EpochTime.Tests.ps1 delete mode 100644 test/ConvertFrom-Hex.Tests.ps1 delete mode 100644 test/ConvertFrom-IsoWeekDate.Tests.ps1 delete mode 100644 test/ConvertTo-Base64.Tests.ps1 delete mode 100644 test/ConvertTo-EpochTime.Tests.ps1 delete mode 100644 test/ConvertTo-OrderedDictionary.Tests.ps1 delete mode 100644 test/ConvertTo-PowerShell.Tests.ps1 delete mode 100644 test/ConvertTo-RomanNumeral.Tests.ps1 delete mode 100644 test/Disable-AnsiColor.Tests.ps1 delete mode 100644 test/Enable-AnsiColor.Tests.ps1 delete mode 100644 test/Expand-EnvironmentVariables.Tests.ps1 delete mode 100644 test/Find-NewestFile.Tests.ps1 delete mode 100644 test/ForEach-Progress.Tests.ps1 delete mode 100644 test/Select-CapturesFromMatches.Tests.ps1 diff --git a/.vscode/settings.json b/.vscode/settings.json index 394f8ceb..dbde2c06 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "markdownlint.config": { - "header-style": { + "heading-style": { "style": "setext_with_atx" } }, diff --git a/Add-CapturesToMatches.ps1 b/Add-CapturesToMatches.ps1 deleted file mode 100644 index 8a63c623..00000000 --- a/Add-CapturesToMatches.ps1 +++ /dev/null @@ -1,56 +0,0 @@ -<# -.SYNOPSIS -Adds named capture group values as note properties to Select-String MatchInfo objects. - -.DESCRIPTION -Navigating the .NET Regex Group and Capture collections to find a capture group can be -a hassle in some versions of PowerShell. - -To simplifies this process, this script just adds simple properties to the MatchInfo objects. - -.INPUTS -Microsoft.PowerShell.Commands.MatchInfo, output from Select-String that used a pattern -with named capture groups. - -.OUTPUTS -Microsoft.PowerShell.Commands.MatchInfo with additional note properties for each named -capture group. - -.FUNCTIONALITY -Search and replace - -.LINK -Add-Member - -.EXAMPLE -Select-String '^(?.*?\b)\s*(?\S+@\S+)$' addrbook.txt |Add-CapturesToMatches.ps1 |select Name,Email,Filename - -Name Email Filename ----- ----- -------- -Arthur Dent adent@example.org addrbook.txt -Tricia McMillan trillian@example.com addrbook.txt -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([Microsoft.PowerShell.Commands.MatchInfo])] Param( -# The MatchInfo output from Select-String to augment with named capture group values. -[Parameter(Position=0,ValueFromRemainingArguments=$true,ValueFromPipeline=$true)] -[Alias('InputObject')][Microsoft.PowerShell.Commands.MatchInfo]$MatchInfo -) -Process -{ - if($PSVersionTable.PSEdition -eq 'Desktop' -and $PSVersionTable.CLRVersion -lt [version]4.7) - { # old CLR is really tedious to get group names - [regex]$regex = $MatchInfo.Pattern - $regex.GetGroupNames() | - Where-Object {$_ -Match '\D'} | - ForEach-Object {Add-Member -InputObject $MatchInfo $_ $MatchInfo.Matches.Groups[$regex.GroupNumberFromName($_)].Value} - } - else - { - $MatchInfo.Matches.Groups | - Where-Object Name -Match '\D' | - ForEach-Object {Add-Member -InputObject $MatchInfo $_.Name $_.Value} - } - $MatchInfo -} diff --git a/Add-TimeSpan.ps1 b/Add-TimeSpan.ps1 deleted file mode 100644 index 79761f48..00000000 --- a/Add-TimeSpan.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# -.SYNOPSIS -Adds a timespan to DateTime values. - -.DESCRIPTION -This is a more PowerShell-idiomatic, pipeline-based way to add a timespan to a datetime. - -.INPUTS -System.DateTime values to add the TimeSpan value to. - -.OUTPUTS -System.DateTime values with the TimeSpan added. - -.FUNCTIONALITY -Date and time - -.EXAMPLE -Get-Date |Add-TimeSpan.ps1 00:00:30 - -Adds 30 seconds to the current date and time value. -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([DateTime])] Param( -# The TimeSpan value to add. -[Parameter(Mandatory=$true)][TimeSpan]$TimeSpan, -# The DateTime value to add to. -[Parameter(Mandatory=$true,ValueFromPipeline=$true)][DateTime]$DateTime -) -Process{$DateTime.Add($TimeSpan)} diff --git a/Compare-Keys.ps1 b/Compare-Keys.ps1 deleted file mode 100644 index b66b2e78..00000000 --- a/Compare-Keys.ps1 +++ /dev/null @@ -1,116 +0,0 @@ -<# -.SYNOPSIS -Returns the differences between two dictionaries. - -.INPUTS -System.Collections.IDictionary to compare to the reference dictionary. - -.OUTPUTS -System.Management.Automation.PSObject with these properties: -* Key: The dictionary key being compared. -* Action: A Data.DataRowState that indicates whether the key-value pair has been - Added, Deleted, Modified, or Unchanged. -* ReferenceValue: The original value. -* DifferenceValue: The new value. - -.FUNCTIONALITY -Dictionary - -.LINK -Compare-Object - -.LINK -Group-Object - -.LINK -ForEach-Object - -.LINK -Sort-Object - -.EXAMPLE -Compare-Keys.ps1 @{ A = 1; B = 2; C = 3 } @{ D = 6; C = 4; B = 2 } -IncludeEqual - -Key Action ReferenceValue DifferenceValue ---- ------ -------------- --------------- -A Deleted 1 -B Unchanged 2 2 -C Modified 3 4 -D Added 6 -#> - -#Requires -Version 7 -[CmdletBinding()] Param( -# The original dictionary to compare. -[Parameter(Position=0,Mandatory=$true)][Collections.IDictionary] $ReferenceDictionary, -# A dictionary to compare to the original. -[Parameter(Position=1,Mandatory=$true,ValueFromPipeline=$true)][Collections.IDictionary] $DifferenceDictionary, -# Indicates that different values should be ignored. -[switch] $ExcludeDifferent, -# Indicates that identical values should be included. -[switch] $IncludeEqual -) -Process -{ - if([Environment]::Version.Major -lt 7) - { - $refEntries = @($ReferenceDictionary.GetEnumerator()) | - Add-Member -MemberType ScriptMethod -Name ToString -Value {'[{0}, {1}]' -f $this.Key, $this.Value} -Force -PassThru - $diffEntries = @($DifferenceDictionary.GetEnumerator()) | - Add-Member -MemberType ScriptMethod -Name ToString -Value {'[{0}, {1}]' -f $this.Key, $this.Value} -Force -PassThru - } - else - { - $refEntries = @($ReferenceDictionary.GetEnumerator()) - $diffEntries = @($DifferenceDictionary.GetEnumerator()) - } - Compare-Object $refEntries $diffEntries -ExcludeDifferent:$ExcludeDifferent -IncludeEqual:$IncludeEqual | - Group-Object {$_.InputObject.Key} | - ForEach-Object { - $key = $_.Values[0] - if($_.Group.Count -gt 1) - { - $refValue, $diffValue = ($_.Group |Sort-Object SideIndicator).InputObject.Value - [pscustomobject]@{ - Key = $key - Action = [Data.DataRowState]::Modified - ReferenceValue = $refValue - DifferenceValue = $diffValue - } - } - else - { - $value = $_.Group[0].InputObject.Value - switch($_.Group[0].SideIndicator) - { - '<=' - { - [pscustomobject]@{ - Key = $key - Action = [Data.DataRowState]::Deleted - ReferenceValue = $value - DifferenceValue = $null - } - } - '==' - { - [pscustomobject]@{ - Key = $key - Action = [Data.DataRowState]::Unchanged - ReferenceValue = $value - DifferenceValue = $value - } - } - '=>' - { - [pscustomobject]@{ - Key = $key - Action = [Data.DataRowState]::Added - ReferenceValue = $null - DifferenceValue = $value - } - } - } - } - } -} diff --git a/Convert-ClipboardTsvToHtml.ps1 b/Convert-ClipboardTsvToHtml.ps1 deleted file mode 100644 index e8c420b0..00000000 --- a/Convert-ClipboardTsvToHtml.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -<# -.SYNOPSIS -Parses TSV clipboard data into HTML table data which is copied back to the clipboard. - -.FUNCTIONALITY -Clipboard - -.EXAMPLE -Convert-ClipboardTsvToHtml.ps1 - -TSV clipboard data may now be pasted into an email or document as a table. -#> - -#Requires -Version 3 -[CmdletBinding()] Param() - -if($PSVersionTable.PSEdition -ne 'Desktop') -{ - Invoke-WindowsPowerShell.ps1 { Convert-ClipboardTsvToHtml.ps1 } -} -else -{ - Import-ClipboardTsv.ps1 | - ConvertTo-Html -Fragment | - ConvertTo-SafeEntities.ps1 | - Set-Clipboard -AsHtml -} diff --git a/Convert-ExternalScriptToModule.ps1 b/Convert-ExternalScriptToModule.ps1 new file mode 100644 index 00000000..e0fd66ab --- /dev/null +++ b/Convert-ExternalScriptToModule.ps1 @@ -0,0 +1,66 @@ +<# +.SYNOPSIS +Convert a script from external script usage to module cmdlet usage. + +.FUNCTIONALITY +PowerShell + +.INPUTS +System.String containing the path of the script to update. +#> + +#Requires -Version 7 +using namespace System.Collections.Generic +using namespace System.IO +using namespace System.Management.Automation.Language +using module Detextive +[CmdletBinding()] Param( +# The module to use instead of external scripts. +[Parameter(Position=0)][string] $ModuleName = 'ModernConveniences', +# The script to update to module usage. +[Parameter(Position=1,ValueFromPipelineByPropertyName=$true)][Alias('FullName')][string] $Path = '*.ps1' +) +Begin +{ + filter Update-ScriptFile + { + [CmdletBinding()] Param( + [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][FileInfo[]] $Values, + [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)] + [System.Collections.ObjectModel.Collection[psobject]] $Group + ) + if($Values.Count -ne 1) {throw "Unexpected grouping of $($Values.Count) files."} + $ps1,$cmd = $Values.FullName,$Values.BaseName + $ext = New-Object Stack[IScriptExtent] $Group.Count + $Group |ForEach-Object {$ext.Push($_)} + [int] $usingOffset = Get-ScriptTokens $ps1 | + Where-Object Kind -notin 'Comment','NewLine' | + Select-Object -First 1 | + ForEach-Object {$_.Extent.StartOffset} + $encoding = Get-FileEncoding $ps1 + $script = Get-Content $ps1 -Raw + $ext |ForEach-Object { + $start,$end = $_.StartOffset,$_.EndOffset + $script = $script.Remove($start, $end - $start).Insert($start, (Split-Path $_.Text -LeafBase)) + } + $script.Insert($usingOffset, "using module $ModuleName`r`n") | + Out-File $ps1 -Encoding $encoding + } + + function Find-ExternalScriptUsage + { + [CmdletBinding()] Param( + [Parameter(Position=0,Mandatory=$true)][string] $Path + ) + [string[]] $cmdlets = Get-Command -Module $ModuleName |Select-Object -ExpandProperty Name + if(!$cmdlets) {throw "Could not find any cmdlets in $ModuleName. Did you import it?"; return} + return Select-ScriptCommands $Path -CommandType ExternalScript | + Where-Object {(Split-Path $_.CommandName -LeafBase) -iin $cmdlets} | + ForEach-Object {$_.Tokens.Extent} | + Group-Object {Get-Item $_.File} + } +} +Process +{ + Find-ExternalScriptUsage $Path |Update-ScriptFile +} diff --git a/Convert-ICalToMermaidGantt.ps1 b/Convert-ICalToMermaidGantt.ps1 deleted file mode 100644 index ceeb11cb..00000000 --- a/Convert-ICalToMermaidGantt.ps1 +++ /dev/null @@ -1,144 +0,0 @@ -<# -.SYNOPSIS -Imports iCal events and converts them into a Mermaid Gantt chart for each day, sectioned by location. - -.FUNCTIONALITY -Mermaid Diagrams - -.INPUTS -Any object with these properties: -* Id: [string] A unique identifier for the event. -* Title: [string] Required. The name of the event. -* Location: [string] Where the event is held -* Url: [uri] A link to more information about the event. -* Start: When the event begins, as a DateTime, string, or Ical.Net.DataTypes.CalDateTime. -* End: When the event concludes, as a DateTime, string, or Ical.Net.DataTypes.CalDateTime. - -.OUTPUTS -System.String containing a Mermaid Gantt chart for the day. - -.LINK -https://datatracker.ietf.org/doc/html/rfc5545 - -.LINK -https://mermaid.js.org/syntax/gantt.html - -.LINK -New-Guid - -.LINK -Get-Date - -.EXAMPLE -ImportIcal\Import-Calendar -String (Invoke-RestMethod https://spokanefilmfestival.org/events/?ical=1) |Select-Object -ExpandProperty Events |Convert-ICalToMermaidGantt.ps1 - ---- -displayMode: compact ---- -gantt -title Saturday March 7, 2026 -dateFormat HH:mm -axisFormat %H:%M -tickInterval 1hour -todayMarker off -... -#> - -#Requires -Version 7 -[CmdletBinding(DefaultParameterSetName='Event')] Param( -[Parameter(ValueFromPipelineByPropertyName=$true)][Alias('Uid')][string] $Id = (New-Guid).ToString('D'), -[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][Alias('Summary')][string] $Title, -[Parameter(ValueFromPipelineByPropertyName=$true)][string] $Location, -[Parameter(ValueFromPipelineByPropertyName=$true)][uri] $Url, -[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] $Start, -[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] $End -) -Begin -{ - $Script:EventList = @() - $Script:DayChart = @() - - filter Format-Event - { - [CmdletBinding()] Param( - [Parameter(ValueFromPipelineByPropertyName=$true)][string] $Id, - [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string] $Title, - [Parameter(ValueFromPipelineByPropertyName=$true)][string] $Location, - [Parameter(ValueFromPipelineByPropertyName=$true)][uri] $Url, - [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][datetime] $Start, - [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][datetime] $End - ) - if($Url) - { - return @" -$Title : $Id, $(Get-Date $Start -Format HH:mm), $(Get-Date $End -Format HH:mm) -click $Id href "$Url" -"@ - } - else - { - return @" -$Title : $(Get-Date $Start -Format HH:mm), $(Get-Date $End -Format HH:mm) -"@ - } - } - - filter Format-Location - { - [CmdletBinding()] Param( - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][string] $Name, - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][psobject[]] $Group - ) - $Local:OFS = [System.Environment]::NewLine - return @" -section $Name -$($Group |Format-Event) -"@ - } - - filter Format-Day - { - [CmdletBinding()] Param( - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][string] $Name, - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][psobject[]] $Group - ) - $Local:OFS = [System.Environment]::NewLine - return @" ---- -displayMode: compact ---- -gantt -title $(Get-Date $Name -Format 'dddd MMMM d, yyyy') -dateFormat HH:mm -axisFormat %H:%M -tickInterval 1hour -todayMarker off -$($Group |Group-Object Location |Format-Location) -"@ - } -} -Process -{ - if(Get-Member -InputObject $Start -Name AsDateTimeOffset -Type Property) {$Start = $Start.AsDateTimeOffset.LocalDateTime} - elseif($Start -is [string]) {$Start = Get-Date $Start} - elseif($Start -isnot [datetime]) {Stop-ThrowError.ps1 'Start was not a DateTime' -Argument Start} - if(Get-Member -InputObject $End -Name AsDateTimeOffset -Type Property) {$End = $End.AsDateTimeOffset.LocalDateTime} - elseif($End -is [string]) {$End = Get-Date $End} - elseif($End -isnot [datetime]) {Stop-ThrowError.ps1 'End was not a DateTime' -Argument 'End'} - $Script:EventList += [pscustomobject]@{ - Id = "id-$Id" - Title = $Title - Location = $Location - Url = $Url - Start = $Start - End = $End - } -} -End -{ - $Script:EventList | - Sort-Object Start, End, Location | - Group-Object {Get-Date $_.Start -Format yyyy-MM-dd} | - ForEach-Object {$Script:DayChart += $_ |Format-Day} - return $Script:DayChart -} diff --git a/ConvertFrom-Base64.ps1 b/ConvertFrom-Base64.ps1 deleted file mode 100644 index d1c0a6d1..00000000 --- a/ConvertFrom-Base64.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -<# -.SYNOPSIS -Converts base64-encoded text to bytes or text. - -.INPUTS -System.String of base64-encoded text to decode. - -.OUTPUTS -System.String or System.Byte[] of decoded text or data. - -.FUNCTIONALITY -Data encoding - -.LINK -https://docs.microsoft.com/dotnet/api/system.convert.frombase64string - -.LINK -https://www.rfc-editor.org/rfc/rfc7515.html#appendix-C - -.EXAMPLE -ConvertFrom-Base64.ps1 dXNlcm5hbWU6QmFkUEBzc3dvcmQ= -Encoding utf8 - -username:BadP@ssword - -.EXAMPLE -'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9' |ConvertFrom-Base64.ps1 -Encoding ascii -UriStyle - -{"alg":"HS256","typ":"JWT"} - -.EXAMPLE -'77u/dHJ1ZQ0K' |ConvertFrom-Base64.ps1 |Format-Hex - - Label: Byte (System.Byte) <3D01E7E8> - - Offset Bytes Ascii - 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F - ------ ----------------------------------------------- ----- -0000000000000000 EF BB BF 74 72 75 65 0D 0A true�� -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string])][OutputType([byte[]])] Param( -# The base64-encoded data. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][string] $Data, -<# -Uses the specified encoding to convert the bytes in the data to text. - -If no encoding is provided, the data will be returned as a byte array. -#> -[Parameter(Position=1)][ValidateSet('ascii','byte','utf16','utf16BE','utf32','utf32BE','utf7','utf8')] -[string] $Encoding = 'byte', -<# -Indicates that the URI-friendly variant of the base64 algorithm should be used. -This variant, as used by JWTs, uses - instead of +, and _ instead of /, and trims the = padding at the end -to avoid extra escaping within URLs or URL-encoded data. -#> -[switch] $UriStyle -) -Process -{ - if($UriStyle) - { - $Data = $Data -replace '-','+' -replace '_','/' - $Data += '='*(3-(($Data.Length-1)% 4)) - } - $value = [Convert]::FromBase64String($Data) - if($Encoding -eq 'byte') {$value} - else - { - $encoder = [Text.Encoding]::GetEncoding(($Encoding -replace '^utf','utf-')) - $encoder.GetString($value) - } -} diff --git a/ConvertFrom-CimInstance.ps1 b/ConvertFrom-CimInstance.ps1 index ad92fefd..9beee836 100644 --- a/ConvertFrom-CimInstance.ps1 +++ b/ConvertFrom-CimInstance.ps1 @@ -12,12 +12,11 @@ PSObject converted from the CimInstance entered. Scheduled Tasks .EXAMPLE -$tasks = Get-ScheduledTask |ConvertFrom-CimInstance.ps1 +$tasks = Get-ScheduledTask |ConvertFrom-CimInstance Gets the scheduled tasks as PSObjects that support tab completion and can be serialized and exported. #> -#Requires -Version 3 [CmdletBinding()][OutputType([Management.Automation.PSCustomObject])] Param( # The CimInstance object to convert to a PSObject. [Parameter(Position=0,ValueFromPipeline=$true)] @@ -31,8 +30,8 @@ Process if($null -eq $InputObject.$name) {continue} switch($InputObject.CimInstanceProperties[$name].CimType) { - Instance {$value[$name] = $InputObject.$name |ConvertFrom-CimInstance.ps1} - InstanceArray {$value[$name] = [psobject[]]@($InputObject.$name |ConvertFrom-CimInstance.ps1)} + Instance {$value[$name] = $InputObject.$name |ConvertFrom-CimInstance} + InstanceArray {$value[$name] = [psobject[]]@($InputObject.$name |ConvertFrom-CimInstance)} default {$value[$name] = $InputObject.$name} } } diff --git a/ConvertFrom-DataRow.ps1 b/ConvertFrom-DataRow.ps1 index d022c459..a4fa03a7 100644 --- a/ConvertFrom-DataRow.ps1 +++ b/ConvertFrom-DataRow.ps1 @@ -18,7 +18,6 @@ Database Invoke-Sqlcmd "select top 3 ProductID, Name from Production.Product" -ServerInstance ServerName -Database AdventureWorks |ConvertFrom-DataRow.ps1 |ConvertTo-Html #> -#Requires -Version 3 [CmdletBinding(DefaultParameterSetName='AsObject')] [OutputType([Management.Automation.PSCustomObject],ParameterSetName='AsObject')] [OutputType([object[]],ParameterSetName='AsValues')] diff --git a/ConvertFrom-Duration.ps1 b/ConvertFrom-Duration.ps1 deleted file mode 100644 index 52b8e4c4..00000000 --- a/ConvertFrom-Duration.ps1 +++ /dev/null @@ -1,96 +0,0 @@ -<# -.SYNOPSIS -Parses a Timespan from a ISO8601 duration string. - -.INPUTS -System.String containing an ISO8601 duration. - -.OUTPUTS -System.Timespan containing the duration, as parsed and converted to a Timespan. - -.FUNCTIONALITY -Date and time - -.LINK -https://en.wikipedia.org/wiki/ISO_8601#Durations - -.LINK -Import-Variables.ps1 - -.LINK -Test-Variable.ps1 - -.LINK -Stop-ThrowError.ps1 - -.EXAMPLE -"$(ConvertFrom-Duration.ps1 P1D)" - -1.00:00:00 - -.EXAMPLE -"$(ConvertFrom-Duration.ps1 P3Y6M4DT12H30M5S)" - -WARNING: Adding year(s) as a mean number of days (365.2425). -WARNING: Adding month(s) as a mean number of days (30.436875). -1283.12:30:05 -#> - -#Requires -Version 7 -[CmdletBinding()][OutputType([timespan])] Param( -<# -An ISO8601 duration string in one of four formats: - -* PnYnMnDTnHnMnS -* PnW -* Pyyyy-MM-ddTHH:mm:ss -* PyyyyMMddTHHmmss -#> -[Parameter(Position=0,ValueFromPipeline=$true,ValueFromRemainingArguments)] -[ValidatePattern('\AP(?:T?\d\w+|\d\d\d\d(?:-\d\d){2}T\d\d(?::\d\d){2})\z', -ErrorMessage='An ISO8601 duration is required')] -[string[]] $InputObject, -# Supresses warnings about approximate conversions. -[Alias('Quiet')][switch]$NoWarnings -) -Begin -{ - $MeanMonth,$MeanYear = 30.436875,365.2425 - [regex[]] $formats = '\AP(?\d+)W\z', - '\AP(?:(?\d+)Y)?(?:(?\d+)M)?(?:(?\d+)D)?(?:T(?:(?\d+)H)?(?:(?\d+)M)?(?:(?\d+)S)?)?\z', - '\AP(?\d{4})-(?\d{2})-(?\d{2})T(?\d{2}):(?\d{2}):(?\d{2})\z', - '\AP(?\d{4})(?\d{2})(?\d{2})T(?\d{2})(?\d{2})(?\d{2})\z' -} -Process -{ - foreach($o in $InputObject) - { - [bool]$matched = $false - foreach($f in $formats) - { - if($o -match $f) {$matched = $true; break} - } - if(!$matched) - { - Stop-ThrowError.ps1 "Could not parse '$o' as an ISO8601 duration." -Argument InputObject - } - Import-Variables.ps1 $Matches - [timespan]$value = 0 - if(Test-Variable.ps1 Years) - { - if(!$NoWarnings) {Write-Warning "Adding year(s) as a mean number of days ($MeanYear)."} - $value += New-Object Timespan ($MeanYear*[int]$Years),0,0,0 - } - if(Test-Variable.ps1 Months) - { - if(!$NoWarnings) {Write-Warning "Adding month(s) as a mean number of days ($MeanMonth)."} - $value += New-Object Timespan ($MeanMonth*[int]$Months),0,0,0 - } - if(Test-Variable.ps1 Weeks) {$value += New-Object Timespan (7*[int]$Weeks),0,0,0} - if(Test-Variable.ps1 Days) {$value += New-Object Timespan ([int]$Days),0,0,0} - if(Test-Variable.ps1 Hours) {$value += New-Object Timespan ([int]$Hours),0,0} - if(Test-Variable.ps1 Minutes) {$value += New-Object Timespan 0,([int]$Minutes),0} - if(Test-Variable.ps1 Seconds) {$value += New-Object Timespan 0,0,([int]$Seconds)} - $value - } -} diff --git a/ConvertFrom-EpochTime.ps1 b/ConvertFrom-EpochTime.ps1 deleted file mode 100644 index 648880c2..00000000 --- a/ConvertFrom-EpochTime.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -<# -.SYNOPSIS -Converts an integer Unix (POSIX) time (seconds since Jan 1, 1970) into a DateTime value. - -.INPUTS -System.Int32 value converted from date and time value. - -.OUTPUTS -System.DateTime value to convert to integer. - -.FUNCTIONALITY -Date and time - -.LINK -https://en.wikipedia.org/wiki/Unix_time - -.LINK -https://stackoverflow.com/a/1860511/54323 - -.LINK -Get-Date - -.EXAMPLE -1556884381 |ConvertFrom-EpochTime.ps1 - -Friday, May 3, 2019 11:53:01 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([int])] Param( -# The Epoch time value to convert to a DateTime. -[Parameter(Mandatory=$true,ValueFromPipeline=$true)][long] $InputObject, -# Indicates the DateTime provided is local, and should be converted to UTC. -[Alias('UTC','Z')][switch] $UniversalTime -) -Process{(Get-Date 1970-01-01 -AsUTC:$UniversalTime).AddSeconds($InputObject)} diff --git a/ConvertFrom-Hex.ps1 b/ConvertFrom-Hex.ps1 deleted file mode 100644 index c2725ee4..00000000 --- a/ConvertFrom-Hex.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -<# -.SYNOPSIS -Convert a string of hexadecimal digits into a byte array. - -.INPUTS -System.String of hex digits. - -.OUTPUTS -System.Byte[] of bytes parsed from hex digits. - -.FUNCTIONALITY -Data encoding - -.LINK -https://docs.microsoft.com/dotnet/api/system.numerics.biginteger.parse#System_Numerics_BigInteger_Parse_System_String_System_Globalization_NumberStyles_ - -.LINK -https://docs.microsoft.com/dotnet/api/system.array.reverse#System_Array_Reverse_System_Array_ - -.EXAMPLE -ConvertFrom-Hex.ps1 'EF BB BF' - -239 -187 -191 - -.EXAMPLE -[text.encoding]::UTF8.GetString((ConvertFrom-Hex.ps1 0x25504446)) - -%PDF - -.EXAMPLE -'{0:X2} {1:X2} {2:X2}' -f (ConvertFrom-Hex.ps1 c0ffee) - -C0 FF EE -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([byte[]])] Param( -# A string of hex digits. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][string] $InputObject -) -Process -{ - $hex = $InputObject -replace '\A0x|[^0-9A-Fa-f]+','' - [byte[]] $value = [bigint]::Parse("00$hex",'HexNumber').ToByteArray() - [array]::Reverse($value) - while($value.Length -gt ($hex.Length / 2)) {$null,$value = $value} - return $value -} diff --git a/ConvertFrom-IsoWeekDate.ps1 b/ConvertFrom-IsoWeekDate.ps1 deleted file mode 100644 index d2bfc6d7..00000000 --- a/ConvertFrom-IsoWeekDate.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -<# -.SYNOPSIS -Returns a DateTime object from an ISO week date string. - -.INPUTS -System.String containing an ISO week date. - -.OUTPUTS -System.DateTime corresponding to the ISO week date. - -.FUNCTIONALITY -Date and time - -.LINK -https://en.wikipedia.org/wiki/ISO_week_date - -.EXAMPLE -ConvertFrom-IsoWeekDate.ps1 2000-W01-1 - -Monday, January 3, 2000 00:00:00 - -.EXAMPLE -ConvertFrom-IsoWeekDate.ps1 2022-W08-2 - -Tuesday, February 22, 2022 00:00:00 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([datetime])] Param( -# An ISO week date of the formatt ####-W##-#. -[Parameter(Position=0,ValueFromPipeline=$true)][ValidatePattern('\A\d+-W\d\d-\d\z')][string] $InputObject -) -Process -{ - if($InputObject -notmatch '\A(?\d+)-W(?\d\d)-(?\d)\z') - { - Stop-ThrowError.ps1 "Unable to parse '$InputObject' as an ISO week date." -Argument InputObject - } - $year,$week,$dow = [int]$Matches.Year,([int]($Matches.Week)-1),[int]$Matches.DayOfWeek - $yearstart = New-Object DateTime $year,1,1 - $startdow = [int]$yearstart.DayOfWeek - if($startdow -gt 4) {return $yearstart.AddDays(7*$week+$dow+(7-$startdow))} - else {return $yearstart.AddDays(7*$week+$dow-$startdow)} -} diff --git a/ConvertTo-Base64.ps1 b/ConvertTo-Base64.ps1 deleted file mode 100644 index 03861ebd..00000000 --- a/ConvertTo-Base64.ps1 +++ /dev/null @@ -1,62 +0,0 @@ -<# -.SYNOPSIS -Converts bytes or text to base64-encoded text. - -.INPUTS -System.String or System.Byte[] of data to base64-encode. - -.OUTPUTS -System.String containing the base64-encoded data. - -.FUNCTIONALITY -Data encoding - -.LINK -https://docs.microsoft.com/dotnet/api/system.convert.tobase64string - -.EXAMPLE -ConvertTo-Base64.ps1 'username:BadP@ssword' utf8 - -dXNlcm5hbWU6QmFkUEBzc3dvcmQ= - -.EXAMPLE -'{"alg":"HS256","typ":"JWT"}' |ConvertTo-Base64.ps1 -UriStyle - -eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 - -.EXAMPLE -,[byte[]]@(0xEF,0xBB,0xBF,0x74,0x72,0x75,0x65,0x0D,0x0A) |ConvertTo-Base64.ps1 - -77u/dHJ1ZQ0K -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string])] Param( -# Binary data to convert. -[Parameter(ParameterSetName='BinaryData',Position=0,Mandatory=$true,ValueFromPipeline=$true)] -[byte[]] $Data, -# Text data to convert. -[Parameter(ParameterSetName='TextData',Position=0,Mandatory=$true,ValueFromPipeline=$true)] -[string] $Text, -# The text encoding to use when converting text to binary data. -[Parameter(ParameterSetName='TextData',Position=1)] -[ValidateSet('ascii','utf16','utf16BE','utf32','utf32BE','utf7','utf8')] -[string] $Encoding = 'utf8', -<# -Indicates that the URI-friendly variant of the base64 algorithm should be used. -This variant, as used by JWTs, uses - instead of +, and _ instead of /, and trims the = padding at the end -to avoid extra escaping within URLs or URL-encoded data. -#> -[switch] $UriStyle -) -Process -{ - if($Text) - { - $encoder = [Text.Encoding]::GetEncoding(($Encoding -replace '^utf','utf-')) - $Data = $encoder.GetBytes($Text) - } - $value= [Convert]::ToBase64String($Data) - if($UriStyle) {$value.Trim('=') -replace '\+','-' -replace '/','_'} - else {$value} -} diff --git a/ConvertTo-EpochTime.ps1 b/ConvertTo-EpochTime.ps1 deleted file mode 100644 index d1370534..00000000 --- a/ConvertTo-EpochTime.ps1 +++ /dev/null @@ -1,42 +0,0 @@ -<# -.SYNOPSIS -Converts a DateTime value into an integer Unix (POSIX) time, seconds since Jan 1, 1970. - -.INPUTS -System.DateTime value to convert to integer. - -.OUTPUTS -System.Int32 value converted from date and time value. - -.FUNCTIONALITY -Date and time - -.LINK -https://en.wikipedia.org/wiki/Unix_time - -.LINK -https://stackoverflow.com/a/1860511/54323 - -.LINK -Get-Date - -.EXAMPLE -Get-Date |ConvertTo-EpochTime.ps1 - -1556884381 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([int])] Param( -# The DateTime value to convert to number of seconds since Jan 1, 1970. -[Parameter(Mandatory=$true,ValueFromPipeline=$true)][DateTime] $DateTime, -# Indicates the DateTime provided is local, and should be converted to UTC. -[Alias('UTC','Z')][switch] $UniversalTime -) -Process -{ - $value = [double]::Parse((Get-Date $(if($UniversalTime){$DateTime.ToUniversalTime()}else{$DateTime}) -UFormat %s)) - if($value -le [int]::MaxValue -and $value -ge [int]::MinValue) {return [int]$value} - if($value -le [long]::MaxValue -and $value -ge [long]::MinValue) {return [long]$value} - return $value -} diff --git a/ConvertTo-FileName.ps1 b/ConvertTo-FileName.ps1 deleted file mode 100644 index 9ace73e4..00000000 --- a/ConvertTo-FileName.ps1 +++ /dev/null @@ -1,93 +0,0 @@ -<# -.SYNOPSIS -Returns a valid and safe filename from a given string. - -.INPUTS -System.String containing a filename that may contain invalid characters. - -.OUTPUTS -System.String containing a filename without any invalid characters. - -.FUNCTIONALITY -Unicode - -.EXAMPLE -'app*.log' |ConvertTo-FileName.ps1 - -app_.log - -.EXAMPLE -'one|two-' |ConvertTo-FileName.ps1 -CurrentPlatformOnly - -one_two-_three_ - -.EXAMPLE -'app-${value}.config' |ConvertTo-FileName.ps1 Ascii -ExcludeChars '%','$','{','}','`' - -app-_value_.config -#> - -using namespace System.Text -#Requires -Version 7 -[CmdletBinding()][OutputType([string])] Param( -# Allows limiting the filename to either ASCII or Basic Multilingual Plane characters, if specified. -[ValidateSet('Bmp', 'Ascii')][string] $OutputBlock, -# The character to use to replace a range of invalid characters. -[rune] $Replacement = '_'[0], -# Characters to include (overrides exclusions). -[ValidateNotNull()][char[]] $IncludeChars = @(), -# Characters to exclude. -[ValidateNotNull()][char[]] $ExcludeChars = @(), -# Runes to include (overrides excludes). -[ValidateNotNull()][rune[]] $IncludeRunes = @(), -# Runes to exclude. -[ValidateNotNull()][rune[]] $ExcludeRunes = @(), -# Indicates that only characters invalid for the current platform should be excluded by default, -# otherwise invalid characters from any platform will be excluded by default (unless overridden). -[switch] $CurrentPlatformOnly, -# The string value to sanitize for use as a filename. -[Parameter(Mandatory=$true,ValueFromPipeline=$true)][string] $InputObject -) -Begin -{ - [char[]] $skipchars = $CurrentPlatformOnly ? ([IO.Path]::GetInvalidFileNameChars()) : - @('"', '*', '/', ':', '<', '>', '?', '\', '|') - function Copy-Rune - { - [CmdletBinding()] Param( - [Parameter(Position=0,Mandatory=$true)][rune] $Rune - ) - Set-Variable skipping $false -Scope 1 - (Get-Variable value -Scope 1).Value.Append($Rune) |Out-Null - } - function Skip-Rune - { - $skipping = Get-Variable skipping -Scope 1 - if(!$skipping.Value) - { - $skipping.Value = $true - (Get-Variable value -Scope 1).Value.Append($Replacement) |Out-Null - } - } -} -Process -{ - $skipping, $value = $false, (New-Object StringBuilder) - foreach ($rune in $InputObject.EnumerateRunes()) - { - if($rune -in $IncludeRunes) {Copy-Rune $rune} - elseif($rune -in $ExcludeRunes) {Skip-Rune} - elseif($rune.IsBmp) - { - [char] $char = $rune.Value - if($char -in $IncludeChars) {Copy-Rune $rune} - elseif($char -in $ExcludeChars) {Skip-Rune} - elseif($char -in $skipchars -or [char]::IsControl($char)) {Skip-Rune} - elseif($OutputBlock -eq 'Ascii' -and !$rune.IsAscii) {Skip-Rune} - else {Copy-Rune $rune} - } - elseif($OutputBlock -eq 'Bmp') {Skip-Rune} - else {Copy-Rune $rune} - } - return $value.ToString() -} diff --git a/ConvertTo-OrderedDictionary.ps1 b/ConvertTo-OrderedDictionary.ps1 deleted file mode 100644 index 612ad3eb..00000000 --- a/ConvertTo-OrderedDictionary.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -<# -.SYNOPSIS -Converts an object to an ordered dictionary of properties and values. - -.INPUTS -Any .NET object to convert into a properties hash. - -.OUTPUTS -System.Collections.Specialized.OrderedDictionary of the object's property names and values. - -.FUNCTIONALITY -Dictionary - -.LINK -Get-Member - -.EXAMPLE -ls *.txt |ConvertTo-OrderedDictionary.ps1 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([Collections.Specialized.OrderedDictionary])] Param( -# An object to convert to a dictionary. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)]$InputObject -) -Process -{ - $properties = [ordered]@{} - Get-Member -InputObject $InputObject -MemberType Properties | - Select-Object -ExpandProperty Name | - ForEach-Object {[void]$properties.Add($_,$InputObject.$_)} - $properties -} diff --git a/ConvertTo-PowerShell.ps1 b/ConvertTo-PowerShell.ps1 deleted file mode 100644 index dbac3132..00000000 --- a/ConvertTo-PowerShell.ps1 +++ /dev/null @@ -1,318 +0,0 @@ -<# -.SYNOPSIS -Serializes complex content into PowerShell literals. - -.INPUTS -System.Object (any object) to serialize. - -.OUTPUTS -System.String containing the object serialized to PowerShell literal statements. - -.FUNCTIONALITY -Data formats - -.EXAMPLE -4096LMB |ConvertTo-PowerShell.ps1 - -4LGB - -.EXAMPLE -ConvertFrom-Json '[{"a":1,"b":2,"c":{"d":"\/Date(1490216371478)\/","e":null}}]' |ConvertTo-PowerShell.ps1 - -[pscustomobject]@{ - a = 1L - b = 2L - c = [pscustomobject]@{ - d = [datetime]'2017-03-22T20:59:31' - e = $null - } -} -#> - -#Requires -Version 3 -[CmdletBinding(DefaultParameterSetName='GenerateKey')][OutputType([string])] Param( -# An array, hash, object, or value type that can be represented as a PowerShell literal. -[Parameter(Position=0,ValueFromPipeline=$true)] $Value, -# The starting indent value. You can probably ignore this. -[string] $Indent = '', -# The string to use for incremental indentation. -[string] $IndentBy = "`t", -# The line ending sequence to use. -[string] $Newline = [environment]::NewLine, -# Indicates the first line has already been indented. You can probably ignore this. -[switch] $SkipInitialIndent, -# The maximum width of string literals. -[ValidateRange(1,0xFFFF)][uint16] $Width = 80, -<# -Generates a key to use for encrypting credential and secure string literals. -If this is omitted, credentials will be encrypted using DPAPI, which will only be -decryptable on the same Windows machine where they were encrypted. -#> -[Parameter(ParameterSetName='GenerateKey')][Alias('PortableKey')][switch] $GenerateKey, -<# -The key to use for encrypting credentials and secure strings, as a secure string to be -encoded into UTF-8 bytes. -#> -[Parameter(ParameterSetName='SecureKey',Mandatory=$true)][securestring] $SecureKey, -<# -A credential containing a password (the username is ignored) to be used for encrypting -credentials and secure strings, after encoding to UTF-8 bytes. -#> -[Parameter(ParameterSetName='Credential',Mandatory=$true)][pscredential] $Credential, -# The key to use for encrypting credentials and secure strings, as a byte array. -[Parameter(ParameterSetName='KeyBytes',Mandatory=$true)][byte[]] $KeyBytes -) -Begin -{ - $Script:OFS = "$Newline$Indent" - $Local:PSDefaultParameterValues = @{ - 'ConvertTo-PowerShell.ps1:Indent' = "$Indent$IndentBy" - 'ConvertTo-PowerShell.ps1:IndentBy' = $IndentBy - 'ConvertTo-PowerShell.ps1:Width' = $Width - } - $itab = if($SkipInitialIndent){''}else{$Indent} - $tab = $Indent - $tabtab = "$Indent$IndentBy" - $units = @{ 1LKB = 'KB'; 1LMB = 'MB'; 1LGB = 'GB'; 1LTB = 'TB'; 1LPB = 'PB' } - if($GenerateKey) - { - [byte[]] $KeyBytes = Get-RandomBytes.ps1 32 - "[byte[]]`$key = $($KeyBytes -join ',')" - } - elseif($SecureKey) - { - $Credential = New-Object pscredential 'SecureKey',$SecureKey - } - if($Credential) - { - [byte[]] $salt = Get-RandomBytes.ps1 8 - $hash = New-Object Security.Cryptography.Rfc2898DeriveBytes ` - ([Text.Encoding]::UTF8.GetBytes(($Credential.Password |ConvertFrom-SecureString -AsPlainText))),$salt, - (Get-Random 9999 -Minimum 1000) - $iterations = $hash.IterationCount - [byte[]] $salt = $hash.Salt - [byte[]] $KeyBytes = $hash.GetBytes(32) - $hash.Dispose(); $hash = $null - $creduser = $Credential.UserName -replace "'","''" - "`$hash = New-Object Security.Cryptography.Rfc2898DeriveBytes ``" - " ([Text.Encoding]::UTF8.GetBytes(((Get-Credential '$creduser').Password |ConvertFrom-SecureString -AsPlainText))," - " ($($salt -join ',')),$iterations" - "[byte[]]`$key = `$hash.GetBytes(32)" - "`$hash.Dispose(); `$hash = `$null" - } - if($KeyBytes) - { - $Local:PSDefaultParameterValues['ConvertTo-PowerShell.ps1:Key'] = $KeyBytes - $keyopt = ' -Key $key' - $dpapiwarn = '' - $Script:PSDefaultParameterValues['ConvertFrom-SecureString:Key'] = $KeyBytes - } - else - { - $keyopt = '' - $dpapiwarn = " # using DPAPI, only valid for $env:UserName on $env:ComputerName as of $(Get-Date)" - } - - function Format-PSString([string]$string) - { - $q,$string = - if($string -match '[\0-\x1F\x7F]') - { - '"' - $string -replace '\$','`$' -replace '`','``' -replace '"','`"' -replace "`0",'`0' ` - -replace "`a",'`a' -replace "`b",'`b' -replace "`f",'`f' -replace "`t",'`t' ` - -replace "`v",'`v' -replace '[\0-\t\v\f\x0E-\x1F\x7F]',{'`u{{{0:X2}}}' -f ([int]$_.Value[0])} - } - else - { - "'" - $string -replace "'","''" - } - if($string -match '[\n\r]') {"@$q$Newline$string$Newline$q@"} - else {"$itab$q$string$q"} - } - - filter Format-WrapString - { - Write-Debug "Format-WrapString '$_' -Width $Width" - for($i = 0; ($i+$Width) -lt $_.Length; $i += $Width) {$_.Substring($i,$Width)} - if($_.Length % $Width) {$_.Substring($_.Length - ($_.Length % $Width))} - } - - $typealias = Get-TypeAccelerators.ps1 -DictionaryKey TypeName - filter Format-ParameterType - { - $type = $_.ParameterType.FullName - if($typealias.ContainsKey($type)) {$type = $typealias[$type]} - "[$type]" - } - - filter Format-ParameterAttribute - { - Import-Variables.ps1 $_ - $name = $_.GetType().Name -replace 'Attribute\z','' - switch($name) - { - Parameter - { - $props = @() - if($ParameterSetName -ne '__AllParameterSets') {$props += "ParameterSetName=$ParameterSetName"} - if($Position -ne [int]::MinValue) {$props += "Position=$Position"} - 'Mandatory','ValueFromPipeline','ValueFromPipelineByPropertyName','ValueFromRemainingArguments' | - Get-Variable -ErrorAction Ignore | - Where-Object {$_.Value} | - ForEach-Object {$props += "$($_.Name)=`$$($_.Value.ToString().ToLower())"} - if($props){"[$name($($props -join ','))]"} else {''} - } - Alias {"[Alias($(($AliasNames |ConvertTo-PowerShell.ps1 -SkipInitialIndent) -join ','))]"} - ValidateCount {"[$name($MinLength,$MaxLength)]"} - ValidateDrive {"[$name($(($ValidRootDrives |ConvertTo-PowerShell.ps1 -SkipInitialIndent) -join ','))]"} - ValidateLength {"[$name($MinLength,$MaxLength)]"} - ValidatePattern {"[$name('$($RegexPattern -replace "'","''")')]"} - ValidateRange {"[$name($MinRange,$MaxRange)]"} - ValidateScript {"[$name({$ScriptBlock})]"} - ValidateSet {"[$name($(($ValidValues |ConvertTo-PowerShell.ps1 -SkipInitialIndent) -join ','))]"} - default {"[$name()]"} - } - } - - function Format-Child($InputObject,[switch]$UseKeys) - { - if($null -eq $InputObject) {return} - $(if($UseKeys){$InputObject.Keys}else{Get-Member -InputObject $InputObject -MemberType Properties |Select-Object -ExpandProperty Name}) | - Where-Object {$_ -notmatch '\W'} | - ForEach-Object {"$IndentBy$_ = $(ConvertTo-PowerShell.ps1 $InputObject.$_ -Indent "$tab$IndentBy" -SkipInitialIndent)"} - } -} -Process -{ - if($null -eq $Value) - { "$itab`$null" } - elseif($Value -is [bool]) - { "$itab`$$Value" } - elseif([int],[long],[byte],[decimal],[double],[float],[short],[sbyte],[uint16],[uint32],[uint64],[bigint] -contains $Value.GetType()) - { - $number,$unit = $Value,'' - if($number -ge 1KB) - { - for($magnitude = 1LKB; $magnitude -le 1PB -and !($Value % $magnitude); $magnitude *= 1LKB) - { - $number = $Value / $magnitude - $unit = $units[$magnitude] - } - } - $suffix,$prefix = - if($Value -is [int]) {} - elseif($Value -is [long]) { 'L' } - elseif($Value -is [decimal]) { 'd' } - elseif($Value -is [bigint]) - { - if($PSVersionTable.PSVersion.Major -lt 7) { "'","[bigint]'" } - else { 'n' } - } - elseif($PSVersionTable.PSVersion.Major -lt 7) { '',"[$($Value.GetType().Name)]" } - else - { - switch($Value.GetType().Name) - { - Byte { 'uy' } - Int16 { 's' } - SByte { 'y' } - UInt16 { 'us' } - UInt32 { 'u' } - UInt64 { 'ul' } - } - } - "$itab$prefix$number$suffix$unit" - } - elseif($Value -is [char]) - { - switch([int]$Value) - { - 0 {'[char]"`0"'} - 7 {'[char]"`a"'} - 8 {'[char]"`b"'} - 9 {'[char]"`t"'} - 0xA {'[char]"`n"'} - 0xB {'[char]"`v"'} - 0xC {'[char]"`f"'} - 0xD {'[char]"`r"'} - 0x1B {'[char]"`e"'} - {[char]::IsControl($_)} {'[char]0x{0:X2}' -f $_} - default {"$itab[$($Value.GetType().Name)]'$Value'"} - } - } - elseif([guid],[timespan],[char] -contains $Value.GetType()) - { "$itab[$($Value.GetType().Name)]'$Value'" } - elseif($Value -is [datetimeoffset]) - { "$itab[datetimeoffset]'$($Value.ToString('yyyy-MM-dd\THH:mm:ss.fffffzzzz'))'" } - elseif($Value -is [datetime]) - { "$itab[datetime]'$(Get-Date -Date $Value -f yyyy-MM-dd\THH:mm:ss)'" } - elseif($Value -is [enum]) - { "$itab([$($Value.GetType().FullName)]::$Value)" } - elseif($Value -is [string]) - { Format-PSString $Value } - elseif($Value -is [array]) - {@" -$itab@( -$($Value |ForEach-Object {ConvertTo-PowerShell.ps1 $_}) -$tab) -"@} - elseif($Value -is [securestring]) - { - $password = (ConvertFrom-SecureString $Value |Format-WrapString) -join "' +$Newline${tabtab}'" - "(ConvertTo-SecureString ($Newline${tabtab}'$password')$keyopt)$dpapiwarn" - } - elseif($Value -is [pscredential]) - { - Write-Debug "Credential $($Value.UserName)" - $username = "'$($Value.UserName -replace "'","''")'" - $password = - if(!$Value.Password) {'$null'} - else - { - $p = (ConvertFrom-SecureString $Value.Password |Format-WrapString) -join "' +$Newline${tabtab}'" - "(ConvertTo-SecureString ($Newline${tabtab}'$p')$keyopt)" - } - "${itab}New-Object pscredential $username,$password$dpapiwarn" - } - elseif($Value -is [Management.Automation.RuntimeDefinedParameterDictionary]) - {@" -${itab}Param( -$(($Value.GetEnumerator() |ForEach-Object {"$tabtab$(ConvertTo-PowerShell.ps1 $_.Value)"}) -join ',') -$tab) -"@} - elseif($Value -is [Management.Automation.RuntimeDefinedParameter]) - {@" -$($Value.Attributes |Format-ParameterAttribute) -$itab$($Value |Format-ParameterType) `$$($Value.Name) -"@} - elseif($Value -is [ScriptBlock]) - { "{$Value}" } - elseif($Value -is [Collections.Specialized.OrderedDictionary]) - {@" -$itab[ordered]@{ -$tab$(Format-Child $Value -UseKeys) -$tab} -"@} - elseif($Value -is [Hashtable]) - {@" -$itab@{ -$tab$(Format-Child $Value -UseKeys) -$tab} -"@} - elseif($Value -is [xml]) - { "[xml]$(Format-PSString $Value.OuterXml)" } - elseif($Value -is [PSObject]) - {@" -$itab[pscustomobject]@{ -$tab$(Format-Child $Value) -$tab} -"@} - else - {@" -$itab@{ -$tab$(Format-Child $Value) -$tab} -"@} -} diff --git a/ConvertTo-RomanNumeral.ps1 b/ConvertTo-RomanNumeral.ps1 deleted file mode 100644 index cf494dcd..00000000 --- a/ConvertTo-RomanNumeral.ps1 +++ /dev/null @@ -1,62 +0,0 @@ -<# -.SYNOPSIS -Convert a number to a Roman numeral. - -.INPUTS -System.Int32 value to convert to a Roman numeral string. - -.OUTPUTS -System.String containing a Roman numeral. - -.LINK -https://www.c-sharpcorner.com/blogs/converting-to-and-from-roman-numerals1 - -.LINK -Get-Variable - -.EXAMPLE -ConvertTo-RomanNumeral.ps1 2020 - -MMXX - -.EXAMPLE -ConvertTo-RomanNumeral.ps1 8 - -VIII -#> - -#Requires -Version 3 -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPositionalParameters','', -Justification='This function is reasonable to use positional parameters with.')] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments','', -Justification='These variables are used by Get-Variable, which isn''t detected correctly.')] -[CmdletBinding()][OutputType([string])] Param( -# The numeric value to convert into a Roman numeral string. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][ValidateRange(1,3999)][int] $Value, -# Indicates that Unicode Roman numeral characters should be used (U+2160-U+216F). -[switch] $Unicode -) -Begin -{ - ${1000} = if($Unicode) {@('Ⅿ','ⅯⅯ','ⅯⅯⅯ')} else {@('M','MM','MMM')} - ${100} = if($Unicode) {@('Ⅽ','ⅭⅭ','ⅭⅭⅭ','ⅭⅮ','Ⅾ','ⅮⅭ','ⅮⅭⅭ','ⅮⅭⅭⅭ','ⅭⅯ')} else {@('C','CC','CCC','CD','D','DC','DCC','DCCC','CM')} - ${10} = if($Unicode) {@('Ⅹ','ⅩⅩ','ⅩⅩⅩ','ⅩⅬ','Ⅼ','ⅬⅩ','ⅬⅩⅩ','ⅬⅩⅩⅩ','ⅩⅭ')} else {@('X','XX','XXX','XL','L','LX','LXX','LXXX','XC')} - ${1} = if($Unicode) {@('Ⅰ','Ⅱ','Ⅲ','Ⅳ','Ⅴ','Ⅵ','Ⅶ','Ⅷ','Ⅸ')} else {@('I','II','III','IV','V','VI','VII','VIII','IX')} - function Split-Magnitude([int]$x,[int]$magnitude,[string]$acc='') - { - Write-Verbose "x: $x mag: $magnitude acc: $acc" - $m = Get-Variable $magnitude -ValueOnly - $i = [math]::Floor($x/$magnitude) -1 - if($i -lt 0 -or $i -ge $m.Length) {return $acc,$x} - else {return ($acc+$m[$i]),($x % $magnitude)} - } -} -Process -{ - $rn,$rem = Split-Magnitude $Value 1000 - $rn,$rem = Split-Magnitude $rem 100 $rn - $rn,$rem = Split-Magnitude $rem 10 $rn - $rn,$rem = Split-Magnitude $rem 1 $rn - $rn = $rn -replace 'ⅩⅡ\z','Ⅻ' -replace 'ⅩⅠ\z','Ⅺ' - return $rn -} diff --git a/Disable-AnsiColor.ps1 b/Disable-AnsiColor.ps1 deleted file mode 100644 index fa9ea35b..00000000 --- a/Disable-AnsiColor.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -<# -.SYNOPSIS -Disables ANSI terminal colors. - -.FUNCTIONALITY -Console - -.LINK -https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals - -.EXAMPLE -Disable-AnsiColor.ps1 - -Disables ANSI terminal colors. -#> - -#Requires -Version 7.2 -[CmdletBinding()] Param( -# Disable colors only for text redirected to files. -[switch] $HostOnly -) - -$PSStyle.OutputRendering = $HostOnly ? 'Host' : 'PlainText' diff --git a/Enable-AnsiColor.ps1 b/Enable-AnsiColor.ps1 deleted file mode 100644 index 7942f67e..00000000 --- a/Enable-AnsiColor.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -<# -.SYNOPSIS -Enables ANSI terminal colors. - -.FUNCTIONALITY -Console - -.LINK -https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals - -.EXAMPLE -Enable-AnsiColor.ps1 - -Enables ANSI terminal colors. -#> - -#Requires -Version 7.2 -[CmdletBinding()] Param( -# Enable colors only for host console output. -[switch] $HostOnly -) - -$PSStyle.OutputRendering = $HostOnly ? 'Host' : 'Ansi' diff --git a/Expand-EnvironmentVariables.ps1 b/Expand-EnvironmentVariables.ps1 deleted file mode 100644 index b1490a9f..00000000 --- a/Expand-EnvironmentVariables.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -<# -.SYNOPSIS -Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string. - -.FUNCTIONALITY -EnvironmentVariables - -.LINK -https://docs.microsoft.com/dotnet/api/system.environment.expandenvironmentvariables - -.EXAMPLE -Expand-EnvironmentVariables.ps1 %SystemRoot%\System32\cmd.exe - -C:\WINDOWS\System32\cmd.exe -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -# The string to be expanded. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][string] $Value -) -Process { return [Environment]::ExpandEnvironmentVariables($Value) } diff --git a/Export-MermaidXY.ps1 b/Export-MermaidXY.ps1 deleted file mode 100644 index b533176d..00000000 --- a/Export-MermaidXY.ps1 +++ /dev/null @@ -1,74 +0,0 @@ -<# -.SYNOPSIS -Generates a Mermaid XY bar/line chart for the values of a series of properties. - -.FUNCTIONALITY -Mermaid Diagrams - -.INPUTS -System.Object with the properties requested. - -.OUTPUTS -System.String containing Mermaid XY chart data. - -.LINK -https://mermaid.js.org/syntax/xyChart.html - -.EXAMPLE -Get-Item Save-*.ps1 |Export-MermaidXY.ps1 -Title "Save scripts" -Units bytes -LabelProperty Name -BarProperty Length - -xychart-beta -title "Save scripts" -x-axis "" [Save-PodcastEpisodes.ps1, Save-Secret.ps1, Save-WebRequest.ps1] -y-axis "bytes" 0 --> 3239 -bar "Length" [2754, 3239, 3112] -#> - -#Requires -Version 7 -[CmdletBinding()] Param( -# The property to use as labels on the X axis. -[string] $LabelProperty, -# Properties to use to render a line graph. -[string[]] $LineProperty = @(), -# Properties to use to render a bar graph. -[string[]] $BarProperty = @(), -# A title for the chart. -[string] $Title, -# The label for the X axis. -[Alias('Domain','Progression')][string] $XAxisLabel, -# The label for the Y axis. -[Alias('Range','Units')][string] $YAxisLabel, -# The objects with the specified properties. -[Parameter(ValueFromPipeline=$true)][psobject] $InputObject -) -Begin -{ - filter Format-Values - { - [CmdletBinding()] Param( - [Parameter(Position=0,Mandatory=$true)][psobject[]] $ChartData, - [Parameter(Mandatory=$true,ValueFromPipeline=$true)][string] $Property, - [ValidateSet('bar','line')][string] $Type - ) - $Local:OFS = ', ' - return "$Type `"$Property`" [$($ChartData |Select-Object -ExpandProperty $Property)]" - } -} -End -{ - $data = $input - $labels = $data | - Select-Object -ExpandProperty $LabelProperty | - ForEach-Object {$_ -match '\W' ? "`"$($_ -replace '"')`"" : $_} - $minmax = $LineProperty + $BarProperty |ForEach-Object {$data |Select-Object -ExpandProperty $_} |Measure-Object -Minimum -Maximum - $min = $minmax.Minimum -gt 0 ? 0 : $minmax.Minimum - $max = $minmax.Maximum - $Local:OFS = "`n" - return @" -xychart-beta -title "$Title" -x-axis "$XAxisLabel" [$($labels -join ', ')] -y-axis "$YAxisLabel" $min --> $max -$(@($LineProperty |Format-Values -ChartData $data -Type line) + @($BarProperty |Format-Values -ChartData $data -Type bar)) -"@ -} diff --git a/Export-OpenApiSchema.ps1 b/Export-OpenApiSchema.ps1 index 30446d7a..fdf9b6fa 100644 --- a/Export-OpenApiSchema.ps1 +++ b/Export-OpenApiSchema.ps1 @@ -12,23 +12,22 @@ Json https://www.openapis.org/ .LINK -Export-Json.ps1 +Export-Json .LINK -Set-Json.ps1 +Set-Json .EXAMPLE -Export-OpenApiSchema.ps1 api.json +Export-OpenApiSchema api.json Returns the schema of the 200 response of any defined endpoint is returned. .EXAMPLE -Export-OpenApiSchema.ps1 api.json POST /hello -RequestSchema +Export-OpenApiSchema api.json POST /hello -RequestSchema Returns the schema of the request body of the POST /hello endpoint. #> -#Requires -Version 7 [CmdletBinding(DefaultParameterSetName='ResponseStatus')][OutputType([string])] Param( # The path to the OpenAPI JSON file. [Parameter(Position=0)][string] $Path, @@ -45,7 +44,7 @@ Process { $Method = $Method.ToLowerInvariant() return ($PSCmdlet.ParameterSetName -eq 'RequestSchema' ` - ? (Export-Json.ps1 "/paths/$EndpointPath/$Method/parameters/*/schema" -Path $Path) - : (Export-Json.ps1 "/paths/$EndpointPath/$Method/responses/$ResponseStatus/content/*/schema" -Path $Path) ) | - Set-Json.ps1 '/$schema' 'http://json-schema.org/draft-04/schema#' + ? (Export-Json "/paths/$EndpointPath/$Method/parameters/*/schema" -Path $Path) + : (Export-Json "/paths/$EndpointPath/$Method/responses/$ResponseStatus/content/*/schema" -Path $Path) ) | + Set-Json '/$schema' 'http://json-schema.org/draft-04/schema#' } diff --git a/Export-Readme.ps1 b/Export-Readme.ps1 index 3de8b908..104e9ef6 100644 --- a/Export-Readme.ps1 +++ b/Export-Readme.ps1 @@ -303,6 +303,13 @@ Useful General-Purpose Scripts [pester.yml]: https://github.com/brianary/scripts/actions/workflows/pester.yml "Pester test run history" +> [!NOTE] +> Many scripts have been moved into modules to improve their usability! +> See **[ModernConveniences][]** and the [scripts-to-modules.json roadmap][]. + +[ModernConveniences]: https://github.com/brianary/ModernConveniences/ "A collection of general-purpose functions for objects, properties, and more." +[scripts-to-modules.json roadmap]: scripts-to-modules.json "The plan to divide the scripts into modules by purpose." + This repo contains a collection of generally useful scripts (mostly Windows PowerShell). See [PS5](PS5) for legacy scripts, [syscfg](syscfg) for single-use system config scripts. diff --git a/Find-NewestFile.ps1 b/Find-NewestFile.ps1 deleted file mode 100644 index ef1303bf..00000000 --- a/Find-NewestFile.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -<# -.SYNOPSIS -Finds the most recent file. - -.INPUTS -System.IO.FileInfo[] a list of files to compare. - -.OUTPUTS -System.IO.FileInfo representing the newest of the files compared. - -.FUNCTIONALITY -Files - -.LINK -Test-NewerFile.ps1 - -.EXAMPLE -ls C:\java.exe -Recurse -ErrorAction Ignore |Find-NewestFile.ps1 - -Directory: C:\Program Files (x86)\Minecraft\runtime\jre-x64\1.8.0_25\bin - -Mode LastWriteTime Length Name ----- ------------- ------ ---- --a---- 2017-02-05 15:03 190888 java.exe -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([IO.FileInfo])] Param( -# The list of files to search. -[Parameter(ValueFromPipeline=$true,ValueFromRemainingArguments=$true)] -[IO.FileInfo[]] $Files -) -Begin { $NewestFile = $null } -Process { $Files |ForEach-Object {if(Test-NewerFile.ps1 $NewestFile $_){$NewestFile=$_}} } -End { $NewestFile } diff --git a/Format-Date.ps1 b/Format-Date.ps1 deleted file mode 100644 index 1c85d5df..00000000 --- a/Format-Date.ps1 +++ /dev/null @@ -1,61 +0,0 @@ -<# -.SYNOPSIS -Returns a date/time as a named format. - -.FUNCTIONALITY -Date and time - -.LINK -Get-Date - -.EXAMPLE -Format-Date Iso8601WeekDate 2021-01-20 - -2021-W03-3 - -.EXAMPLE -'Feb 2, 2020 8:20 PM +00:00' |Format-Date Iso8601Z - -2020-02-02T20:20:00Z -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string])] Param( -# The format to serialize the date as. -[Parameter(Position=0,Mandatory=$true)] -[ValidateSet('FrenchRepublicanDateTime','Iso8601','Iso8601Date','Iso8601OrdinalDate', -'Iso8601Week','Iso8601WeekDate','Iso8601Z','LocalLongDate','LocalLongDateTime','Rfc1123','Rfc1123Gmt')] -[string] $Format, -# The date/time value to format. -[Parameter(Position=1,ValueFromPipeline=$true)][datetime] $Date = (Get-Date) -) -Process -{ - switch($Format) - { - FrenchRepublicanDateTime {"$(Get-FrenchRepublicanDate.ps1 $Date)"} - Iso8601 {Get-Date $Date -f "yyyy'-'MM'-'dd'T'HH':'mm':'sszzzz"} - Iso8601Date {Get-Date $Date -uf %Y-%m-%d} # PS5 doesn't support %F - Iso8601OrdinalDate {Get-Date $Date -uf "%Y-$('{0:000}' -f $Date.DayOfYear)"} - Iso8601Week - { - $V = '{0:00}' -f [int](Get-Date $Date -uf %V) # PS5 doesn't zero-pad %V - if(1 -eq (Get-Date $Date -uf %V) -and $Date.Month -eq 12) {"$($Date.Year+1)-W$V"} - elseif(50 -lt (Get-Date $Date -uf %V) -and $Date.Month -eq 1) {"$($Date.Year-1)-W$V"} - else {Get-Date $Date -uf %Y-W$V} - } - Iso8601WeekDate - { - $w = [int]$Date.DayOfWeek; if($w -eq 0) {$w = 7} # PS5-7.1 formats Sundays as zero - $V = '{0:00}' -f [int](Get-Date $Date -uf %V) - if(1 -eq (Get-Date $Date -uf %V) -and $Date.Month -eq 12) {"$($Date.Year+1)-W$V-$w"} - elseif(50 -lt (Get-Date $Date -uf %V) -and $Date.Month -eq 1) {"$($Date.Year-1)-W$V-$w"} - else {Get-Date $Date -uf %Y-W$V-$w} - } - Iso8601Z {"$(Get-Date $Date.ToUniversalTime() -f s)Z"} - LocalLongDate {Get-Date $Date -f D} - LocalLongDateTime {Get-Date $Date -f F} - Rfc1123 {Get-Date $Date -uf '%a, %e %b %Y %T %Z'} # CLR R format zero-pads date instead of space-padding like %e - Rfc1123Gmt {Get-Date $Date.ToUniversalTime() -uf '%a, %e %b %Y %T GMT'} - } -} diff --git a/Format-EscapedUrl.ps1 b/Format-EscapedUrl.ps1 deleted file mode 100644 index b9ccdc9e..00000000 --- a/Format-EscapedUrl.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -<# -.SYNOPSIS -Escape URLs more aggressively. - -.DESCRIPTION -Some characters such as apostrophes and parentheses are legal for URLs, -but are a hassle within certain formats (Markdown, JSON, SQL, &c). - -This script URL-escapes these characters to %xx format. - -.FUNCTIONALITY -Data formats - -.INPUTS -System.Uri to escape. - -.OUTPUTS -System.String containing the URL escaped for maximum compatibility. - -.EXAMPLE -Format-EscapedUrl.ps1 -Clipboard - -Updates the URL on the clipboard with a more aggressively escaped version. - -.EXAMPLE -Format-EscapedUrl.ps1 "https://example.com/search(en-US)?q=Name%20%3D%20'System'&sort=y" - -https://example.com/search%28en-US%29?q=Name%20%3D%20%27System%27&sort=y -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string])] Param( -# The URL to format for maximum compatibility. -[Parameter(ParameterSetName='Uri',Position=0,ValueFromPipeline=$true,ValueFromRemainingArguments=$true,Mandatory=$true)] -[Alias('Url')][uri[]]$Uri, -# Indicates that the URL comes from the clipboard, and is updated on the clipboard. -[Parameter(ParameterSetName='Clipboard')][switch]$Clipboard -) -Begin -{ - [char[]]$chars = ' ',"'",'(',')','[',']','$' -} -Process -{ - if($Clipboard) {Get-Clipboard |Format-EscapedUrl.ps1 |Set-Clipboard} - else - { - foreach($u in $Uri) - { - $escaped = if($u.IsAbsoluteUri){$u.AbsoluteUri}else{$u.OriginalString} - foreach($c in $chars) {$escaped = $escaped.Replace([string]$c,('%{0:X2}' -f [int]$c))} - $escaped - } - } -} diff --git a/Get-CommandParameters.ps1 b/Get-CommandParameters.ps1 deleted file mode 100644 index d70abc21..00000000 --- a/Get-CommandParameters.ps1 +++ /dev/null @@ -1,116 +0,0 @@ -<# -.SYNOPSIS -Returns the parameters of the specified cmdlet. - -.FUNCTIONALITY -Command - -.LINK -Stop-ThrowError.ps1 - -.LINK -Get-Command - -.EXAMPLE -Get-CommandParameters.ps1 Write-Verbose - -CommandName : Write-Verbose -ParameterName : Message -ParameterType : System.String -TypeAlias : string -ParameterSets : {__AllParameterSets} -Mandatory : True -Position : 0 -ValueFromPipelineByPropertyName : False -ValueFromPipeline : True -SwitchParameter : False -IsDynamic : False - -.EXAMPLE -Get-CommandParameters.ps1 Out-Default -NamesOnly - -Transcript -InputObject -#> - -#Requires -Version 3 -[CmdletBinding()] -[OutputType([string])] -Param( -# The name of a cmdlet. -[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)][Alias('Name')][string] $CommandName, -# The name of a parameter set defined by the cmdlet. -[string] $ParameterSet, -# Return only the parameter names (otherwise) -[switch] $NamesOnly, -# Includes common parameters such as -Verbose and -WhatIf. -[switch] $IncludeCommon -) -Begin -{ - [string[]] $excludeParams = - if($IncludeCommon) {@()} - else - { - [string[]][System.Management.Automation.PSCmdlet]::CommonParameters + - [string[]][System.Management.Automation.PSCmdlet]::OptionalCommonParameters - } - $typeAlias = @{} - Get-TypeAccelerators.ps1 | - Where-Object Alias -NotMatch '\d\d\z' | - ForEach-Object {$typeAlias[$_.Type.FullName] = $_.Alias} - - filter ConvertFrom-ParameterMetadata - { - [CmdletBinding()] Param( - [Parameter(Position=0,Mandatory=$true)][string] $CommandName, - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][string] $Name, - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][type] $ParameterType, - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)] - [Collections.Generic.Dictionary[string,Management.Automation.ParameterSetMetadata]] $ParameterSets, - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][bool] $IsDynamic, - [Parameter(ValueFromPipelineByPropertyName=$true)][string[]] $Aliases, - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][attribute[]] $Attributes, - [Parameter(ValueFromPipelineByPropertyName=$true,Mandatory=$true)][bool] $SwitchParameter - ) - $paramAtts = $Attributes |Where-Object {$_ -is [Management.Automation.ParameterAttribute]} - return [pscustomobject]@{ - CommandName = $CommandName - ParameterName = $Name - ParameterType = $ParameterType - TypeAlias = $ParameterType.FullName -replace '(\A\w+(?:\.\w+)*)(\W+)?', - {$typeAlias.ContainsKey($_.Groups[1].Value) ? ($typeAlias[$_.Groups[1].Value]+$_.Groups[2].Value) : $_.Value} - ParameterSets = $ParameterSets.Keys - Mandatory = $paramAtts.Mandatory - Position = $paramAtts.Position - ValueFromPipelineByPropertyName = $paramAtts.ValueFromPipelineByPropertyName - ValueFromPipeline = $paramAtts.ValueFromPipeline - SwitchParameter = $SwitchParameter - IsDynamic = $IsDynamic - } - } -} -Process -{ - $cmd = Get-Command -Name $CommandName -ErrorAction Ignore - if(!$cmd) {Stop-ThrowError.ps1 "Cmdlet not found: $CommandName" -ParameterName CommandName} - if($ParameterSet) - { - $params = $cmd.ParameterSets | - Where-Object Name -eq $ParameterSet | - Select-Object -ExpandProperty Parameters | - Where-Object Name -notin $excludeParams - if($NamesOnly) {return $params |Select-Object -ExpandProperty Name} - else {return $params |ConvertFrom-ParameterMetadata $CommandName} - } - else - { - if($NamesOnly) {return $cmd.Parameters.Keys |Where-Object {$_ -notin $excludeParams}} - else - { - return $cmd.Parameters.Keys | - Where-Object {$_ -notin $excludeParams} | - ForEach-Object {$cmd.Parameters[$_] |ConvertFrom-ParameterMetadata $CommandName} - } - } -} diff --git a/Get-CommandPath.ps1 b/Get-CommandPath.ps1 deleted file mode 100644 index 0f4df5a5..00000000 --- a/Get-CommandPath.ps1 +++ /dev/null @@ -1,69 +0,0 @@ -<# -.SYNOPSIS -Locates a command. - -.DESCRIPTION -Returns the full path to an application found in a directory in $env:Path, -optionally with an extension from $env:PathExt. - -.INPUTS -System.String of commands to get the location details of. - -.OUTPUTS -System.String of location details for the specified commands that were found. - -.FUNCTIONALITY -Command - -.LINK -Get-Command - -.EXAMPLE -Get-CommandPath.ps1 powershell - -C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe - -.EXAMPLE -Get-CommandPath.ps1 dotnet -FindAllInPath - -C:\Program Files\dotnet\dotnet.exe -C:\Program Files (x86)\dotnet\dotnet.exe -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([string])] Param( -<# -The name of the executable program to look for in the $env:Path directories, -if the extension is omitted, $env:PathExt will be used to find one. -#> -[Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)] -[Alias('Name','AN')][string[]] $ApplicationName, -# Indicates that every directory in the Path should be searched for the command. -[switch] $FindAllInPath -) -Process -{ - if($FindAllInPath) - { - $files = - if((Split-Path $ApplicationName -Extension)) {$ApplicationName} - else {$env:PATHEXT.ToLower() -split ';' |ForEach-Object {[io.path]::ChangeExtension($ApplicationName,$_)}} - Write-Verbose "Searching Path for $($files -join ', ')" - foreach($p in $env:Path -split ';') - { - $files | - ForEach-Object {Join-Path $p $_} | - Where-Object {Test-Path $_ -Type Leaf} - } - } - else - { - foreach($cmd in Get-Command $ApplicationName) - { - if($cmd -is [Management.Automation.ApplicationInfo]) {$cmd.Path} - elseif($cmd -is [Management.Automation.ExternalScriptInfo]) {$cmd.Path} - elseif($cmd -is [Management.Automation.AliasInfo]) {$cmd.Definition} - else {Write-Error "$ApplicationName is $($cmd.GetType().FullName)"} - } - } -} diff --git a/Get-ConsoleHistory.ps1 b/Get-ConsoleHistory.ps1 deleted file mode 100644 index b27373d4..00000000 --- a/Get-ConsoleHistory.ps1 +++ /dev/null @@ -1,67 +0,0 @@ -<# -.SYNOPSIS -Returns the DOSKey-style console command history (up arrow or F8). - -.OUTPUTS -System.Management.Automation.PSObject with these properties: - -* Id: The position of the command in the console history. -* CommandLine: The command entered in the history. - -.FUNCTIONALITY -Console - -.EXAMPLE -Get-ConsoleHistory.ps1 -Like *readme* - -Id CommandLine --- ----------- -30 gc .\README.md -56 gc .\README.md - -.EXAMPLE -Get-ConsoleHistory.ps1 -Id 30 - -Id CommandLine --- ----------- -30 gc .\README.md -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -[Parameter(ParameterSetName='Id',Mandatory=$true)][int] $Id, -[Parameter(ParameterSetName='Like',Mandatory=$true)][string] $Like, -[Parameter(ParameterSetName='Match',Mandatory=$true)][string] $Match, -[Parameter(ParameterSetName='All')][switch] $All -) -$history = Get-PSReadLineOption |Select-Object -ExpandProperty HistorySavePath -switch($PSCmdlet.ParameterSetName) -{ - Id - { - [pscustomobject]@{ - Id = $Id - CommandLine = Get-Content $history -TotalCount $Id |Select-Object -Last 1 - } - } - Like - { - $id = 0 - (Get-Content $history) |Where-Object {$id++; $_ -like $Like} |ForEach-Object {[pscustomobject]@{ - Id = $id - CommandLine = $_ - }} - } - Match - { - Select-String -Pattern $Match -Path $history |ForEach-Object {[pscustomobject]@{ - Id = $_.LineNumber - CommandLine = $_.Line - }} - } - default - { - $id = 0 - Get-Content $history |ForEach-Object {[pscustomobject]@{Id=++$id;CommandLine=$_}} - } -} diff --git a/Get-FrenchRepublicanDate.ps1 b/Get-FrenchRepublicanDate.ps1 deleted file mode 100644 index b8766b5b..00000000 --- a/Get-FrenchRepublicanDate.ps1 +++ /dev/null @@ -1,235 +0,0 @@ -<# -.SYNOPSIS -Returns a date and time converted to the French Republican Calendar. - -.INPUTS -System.DateTime containing the Gregorian date and time to convert. - -.OUTPUTS -System.Management.Automation.PSCustomObject containing a French Republican Calendar -date and time in these properties: - -* Year: the numeric year -* Année: the Roman numeral year -* AnnéeUnicode: the Unicode Roman numeral year -* Month: the numeric month -* MonthName: the English month name -* Mois: the French month name -* Day: the numeric day of the month -* DayOfYear: the numeric day of the year -* Jour: the French name of the day of the year -* DayName: the English name of the day of the year -* Decade: the number of the 10-day "week" of the year -* DayOfDecade: the numeric day of the 10-day "week" -* DecadeOrdinal: the name of the day of the 10-day "week" -* DecimalTime: the decimal time (10 hours/day, 100 minutes/hour, 100 seconds/minute) -* GregorianDate: the original Gregorian date, as provided - -.FUNCTIONALITY -Date and time - -.LINK -https://wikipedia.org/wiki/French_Republican_calendar - -.LINK -https://wikipedia.org/wiki/Equinox - -.LINK -https://www.timeanddate.com/calendar/seasons.html - -.LINK -https://www.projectpluto.com/calendar.htm - -.LINK -https://github.com/Bill-Gray/lunar/blob/master/date.cpp#L340 - -.LINK -http://rosettacode.org/wiki/French_Republican_calendar - -.LINK -http://www.windhorst.org/calendar/ - -.LINK -Stop-ThrowError.ps1 - -.EXAMPLE -Get-FrenchRepublicanDate.ps1 2020-07-08 - -Year : 228 -Année : CCXXVIII -AnnéeUnicode : ⅭⅭⅩⅩⅧ -Month : 10 -MonthName : Harvest -Mois : Messidor -Day : 21 -DayOfYear : 291 -Jour : Menthe -DayName : Mint -Decade : 30 -DayOfDecade : 1 -DecadeOrdinal : Primidi -DecimalTime : 0:00:00 -GregorianDate : 2020-07-08 00:00:00 -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -# The Gregorian calendar date and time to convert. -[Parameter(Position=0,ValueFromPipeline=$true)][datetime] $Date = (Get-Date), -# Which method to use to calculate leap years, of the competing choices. -[ValidateSet('Equinox','Romme','Continuous','128Year')][string] $Method = 'Romme' -) -Begin -{ - function Get-128YearLeapDay([int]$year) - { - [int] $remainder = 0 - [int] $pastdays = 31 * [math]::DivRem($year,128,[ref]$remainder) + - [math]::Floor($remainder/4) - [int] $yearlength = 365+[int](!($year % 4) -and ($year % 128)) - return $pastdays,$yearlength - } - function Get-ContinuousLeapDay([int]$year) - { - [int] $remainder = 0 - [int] $pastdays = (97 * [math]::DivRem($year+1,400,[ref]$remainder)) + - (24 * [math]::DivRem($remainder,100,[ref]$remainder)) + - [math]::Floor($remainder/4) - [int] $yearlength = 365+[int]([datetime]::IsLeapYear($year+1)) - return $pastdays,$yearlength - } - function Get-RommeLeapDay([int]$year) - { - [int] $remainder = 0 - [int] $pastdays = (97 * [math]::DivRem($year,400,[ref]$remainder)) + - (24 * [math]::DivRem($remainder,100,[ref]$remainder)) + - [math]::Floor($remainder/4) - [int] $yearlength = 365+[int]([datetime]::IsLeapYear($year)) - return $pastdays,$yearlength - } - $origin = [datetime]'1792-09-22' - ${les mois} = 'Vendémiaire','Brumaire','Frimaire','Nivôse','Pluviôse','Ventôse', - 'Germinal','Floréal','Prairial','Messidor','Thermidor','Fructidor','Sansculottides' - $months = 'Grape Harvest','Fog','Frost','Snowy','Rainy','Windy', - 'Germination','Flowering','Meadow','Harvest','Heat','Fruit','Complementary Days' - ${les jours du decade} = 'Primidi','Duodi','Tridi','Quartidi','Quintidi','Sextidi','Septidi','Octidi','Nonidi','Décadi' - ${les jours} = - 'Raisin','Safran','Châtaigne','Colchique','Cheval','Balsamine','Carotte','Amaranthe','Panais','Cuve', - 'Pomme de terre','Immortelle','Potiron','Réséda','Âne','Belle de nuit','Citrouille','Sarrasin','Tournesol','Pressoir', - 'Chanvre','Pêche','Navet','Amaryllis','Bœuf','Aubergine','Piment','Tomate','Orge','Tonneau', - 'Pomme','Céleri','Poire','Betterave','Oie','Héliotrope','Figue','Scorsonère','Alisier','Charrue', - 'Salsifis','Mâcre','Topinambour','Endive','Dindon','Chervis','Cresson','Dentelaire','Grenade','Herse', - 'Bacchante','Azerole','Garance','Orange','Faisan','Pistache','Macjonc','Coing','Cormier','Rouleau', - 'Raiponce','Turneps','Chicorée','Nèfle','Cochon','Mâche','Chou-fleur','Miel','Genièvre','Pioche', - 'Cire','Raifort','Cèdre','Sapin','Chevreuil','Ajonc','Cyprès','Lierre','Sabine','Hoyau', - 'Érable à sucre','Bruyère','Roseau','Oseille','Grillon','Pignon','Liège','Truffe','Olive','Pelle', - 'Tourbe','Houille','Bitume','Soufre','Chien','Lave','Terre végétale','Fumier','Salpêtre','Fléau', - 'Granit','Argile','Ardoise','Grès','Lapin','Silex','Marne','Pierre à chaux','Marbre','Van', - 'Pierre à plâtre','Sel','Fer','Cuivre','Chat','Étain','Plomb','Zinc','Mercure','Crible', - 'Lauréole','Mousse','Fragon','Perce-neige','Taureau','Laurier-thym','Amadouvier','Mézéréon','Peuplier','Coignée', - 'Ellébore','Brocoli','Laurier','Avelinier','Vache','Buis','Lichen','If','Pulmonaire','Serpette', - 'Thlaspi','Thimelé','Chiendent','Trainasse','Lièvre','Guède','Noisetier','Cyclamen','Chélidoine','Traîneau', - 'Tussilage','Cornouiller','Violier','Troène','Bouc','Asaret','Alaterne','Violette','Marceau','Bêche', - 'Narcisse','Orme','Fumeterre','Vélar','Chèvre','Épinard','Doronic','Mouron','Cerfeuil','Cordeau', - 'Mandragore','Persil','Cochléaria','Pâquerette','Thon','Pissenlit','Sylvie','Capillaire','Frêne','Plantoir', - 'Primevère','Platane','Asperge','Tulipe','Poule','Bette','Bouleau','Jonquille','Aulne','Couvoir', - 'Pervenche','Charme','Morille','Hêtre','Abeille','Laitue','Mélèze','Ciguë','Radis','Ruche', - 'Gainier','Romaine','Marronnier','Roquette','Pigeon','Lilas','Anémone','Pensée','Myrtille','Greffoir', - 'Rose','Chêne','Fougère','Aubépine','Rossignol','Ancolie','Muguet','Champignon','Hyacinthe','Râteau', - 'Rhubarbe','Sainfoin','Bâton d''or','Chamerisier','Ver à soie','Consoude','Pimprenelle','Corbeille d''or','Arroche','Sarcloir', - 'Statice','Fritillaire','Bourrache','Valériane','Carpe','Fusain','Civette','Buglosse','Sénevé','Houlette', - 'Luzerne','Hémérocalle','Trèfle','Angélique','Canard','Mélisse','Fromental','Martagon','Serpolet','Faux', - 'Fraise','Bétoine','Pois','Acacia','Caille','Œillet','Sureau','Pavot','Tilleul','Fourche', - 'Barbeau','Camomille','Chèvrefeuille','Caille-lait','Tanche','Jasmin','Verveine','Thym','Pivoine','Chariot', - 'Seigle','Avoine','Oignon','Véronique','Mulet','Romarin','Concombre','Échalote','Absinthe','Faucille', - 'Coriandre','Artichaut','Girofle','Lavande','Chamois','Tabac','Groseille','Gesse','Cerise','Parc', - 'Menthe','Cumin','Haricot','Orcanète','Pintade','Sauge','Ail','Vesce','Blé','Chalémie', - 'Épeautre','Bouillon blanc','Melon','Ivraie','Bélier','Prêle','Armoise','Carthame','Mûre','Arrosoir', - 'Panic','Salicorne','Abricot','Basilic','Brebis','Guimauve','Lin','Amande','Gentiane','Écluse', - 'Carline','Câprier','Lentille','Aunée','Loutre','Myrte','Colza','Lupin','Coton','Moulin', - 'Prune','Millet','Lycoperdon','Escourgeon','Saumon','Tubéreuse','Sucrion','Apocyn','Réglisse','Échelle', - 'Pastèque','Fenouil','Épine vinette','Noix','Truite','Citron','Cardère','Nerprun','Tagette','Hotte', - 'Églantier','Noisette','Houblon','Sorgho','Écrevisse','Bigarade','Verge d''or','Maïs','Marron','Panier', - 'La Fête de la Vertu','La Fête du Génie','La Fête du Travail','La Fête de l''Opinion','La Fête des Récompenses','La Fête de la Révolution' - $days = - 'Grape','Saffron','Chestnut','Crocus','Horse','Impatiens','Carrot','Amaranth','Parsnip','Vat', - 'Potato','Strawflower','Winter squash','Mignonette','Donkey','Four o''clock flower','Pumpkin','Buckwheat','Sunflower','Wine-Press', - 'Hemp','Peach','Turnip','Amaryllis','Ox','Eggplant','Chili pepper','Tomato','Barley','Barrel', - 'Apple','Celery','Pear','Beetroot','Goose','Heliotrope','Common fig','Black Salsify','Chequer Tree','Plough', - 'Salsify','Water chestnut','Jerusalem artichoke','Endive','Turkey','Skirret','Watercress','Leadworts','Pomegranate','Harrow', - 'Baccharis','Azarole','Madder','Orange','Pheasant','Pistachio','Tuberous pea','Quince','Service tree','Roller', - 'Rampion','Turnip','Chicory','Medlar','Pig','Lamb''s lettuce','Cauliflower','Honey','Juniper','Pickaxe', - 'Wax','Horseradish','Cedar tree','Fir','Roe deer','Gorse','Cypress Tree','Ivy','Savin Juniper','Grub-hoe', - 'Sugar Maple','Heather','Reed plant','Sorrel','Cricket','Pine nut','Cork','Truffle','Olive','Shovel', - 'Peat','Coal','Bitumen','Sulphur','Dog','Lava','Topsoil','Manure','Saltpeter','Flail', - 'Granite','Clay','Slate','Sandstone','Rabbit','Flint','Marl','Limestone','Marble','Winnowing basket', - 'Gypsum','Salt','Iron','Copper','Cat','Tin','Lead','Zinc','Mercury','Sieve', - 'Spurge-laurel','Moss','Butcher''s Broom','Snowdrop','Bull','Laurustinus','Tinder polypore','Daphne mezereum','Poplar','Axe', - 'Hellebore','Broccoli','Bay laurel','Filbert','Cow','Box Tree','Lichen','Yew tree','Lungwort','Billhook', - 'Pennycress','Rose Daphne','Couch grass','Common Knotgrass','Hare','Woad','Hazel','Cyclamen','Celandine','Sleigh', - 'Coltsfoot','Dogwood','Matthiola','Privet','Billygoat','Wild Ginger','Italian Buckthorn','Violet','Goat Willow','Spade', - 'Narcissus','Elm','Common fumitory','Hedge mustard','Goat','Spinach','Doronicum','Pimpernel','Chervil','Twine', - 'Mandrake','Parsley','Scurvy-grass','Daisy','Tuna','Dandelion','Wood Anemone','Maidenhair fern','Ash tree','Dibber', - 'Primrose','Plane Tree','Asparagus','Tulip','Hen','Chard','Birch','Daffodil','Alder','Hatchery', - 'Periwinkle','Hornbeam','Morel','Beech Tree','Bee','Lettuce','Larch','Hemlock','Radish','Hive', - 'Judas tree','Romaine lettuce','Horse chestnut','Arugula or Rocket','Pigeon','Lilac','Anemone','Pansy','Bilberry','Grafting knife', - 'Rose','Oak Tree','Fern','Hawthorn','Nightingale','Common Columbine','Lily of the valley','Button mushroom','Hyacinth','Rake', - 'Rhubarb','Sainfoin','Wallflower','Fan Palm tree','Silkworm','Comfrey','Salad burnet','Basket of Gold','Orache','Garden hoe', - 'Thrift','Fritillary','Borage','Valerian','Carp','Spindle (shrub)','Chive','Bugloss','Wild mustard','Shepherd''s crook', - 'Alfalfa','Daylily','Clover','Angelica','Duck','Lemon balm','Oat grass','Martagon lily','Wild Thyme','Scythe', - 'Strawberry','Woundwort','Pea','Acacia','Quail','Carnation','Elderberry','Poppy plant','Linden or Lime tree','Pitchfork', - 'Cornflower','Camomile','Honeysuckle','Bedstraw','Tench','Jasmine','Verbena','Thyme','Peony','Hand Cart', - 'Rye','Oat','Onion','Speedwell','Mule','Rosemary','Cucumber','Shallot','Wormwood','Sickle', - 'Coriander','Artichoke','Clove','Lavender','Chamois','Tobacco','Redcurrant','Hairy Vetchling','Cherry','Park', - 'Mint','Cumin','Bean','Alkanet','Guinea fowl','Sage Plant','Garlic','Tare','Wheat','Shawm', - 'Spelt','Common mullein','Melon','Ryegrass','Ram','Horsetail','Mugwort','Safflower','Blackberry','Watering can', - 'Switchgrass','Common Glasswort','Apricot','Basil','Ewe','Marshmallow','Flax','Almond','Gentian','Lock', - 'Carline thistle','Caper','Lentil','Inula','Otter','Myrtle','Rapeseed','Lupin','Cotton','Mill', - 'Plum','Millet','Puffball','Six-row Barley','Salmon','Tuberose','Winter Barley','Apocynum','Liquorice','Ladder', - 'Watermelon','Fennel','Barberry','Walnut','Trout','Lemon','Teasel','Buckthorn','Mexican Marigold','Harvesting basket', - 'Wild Rose','Hazelnut','Hops','Sorghum','Crayfish','Bitter orange','Goldenrod','Maize or Corn','Sweet Chestnut','Pack Basket', - 'Celebration of Virtue','Celebration of Talent','Celebration of Labour','Celebration of Convictions','Celebration of Honors (Awards)','Celebration of the Revolution' -} -Process -{ # 1792-09-22 = 1 Vendémiaire Ⅰ - if($Date -lt $origin) {Stop-ThrowError.ps1 ('Dates prior to {0:MMMM d, yyyy} are not yet supported.' -f $origin) -NotImplemented} - [int] ${jour de l'année}, [int] ${l'année} = ($Date.Date - $origin).TotalDays, 1 - if(${jour de l'année} -gt 364) - { - [int] $lastyear = [math]::DivRem(${jour de l'année},365,[ref]${jour de l'année}) - [int] ${past leap days}, [int] ${last year length} = switch($Method) - { - 128Year {Get-128YearLeapDay $lastyear} - Coninuous {Get-ContinuousLeapDay $lastyear} - Equinox {Stop-ThrowError.ps1 'Equinox isn''t supported yet' -NotImplemented} - Romme {Get-RommeLeapDay $lastyear} - } - ${jour de l'année} -= ${past leap days} - if(${jour de l'année} -gt -1) {${l'année} = $lastyear +1; ${jour de l'année}++} - else {${l'année} = $lastyear; ${jour de l'année} += ${last year length} +1} - } - [int] ${jour du mois} = 1 - [int] $mois = 1+[math]::DivRem(${jour de l'année}-1,30,[ref]${jour du mois}) - ${jour du mois}++ - ${jour de decade} = 1 - $decade = 1+[math]::DivRem(${jour de l'année}-1,10,[ref]${jour de decade}) - ${jour de decade}++ - [pscustomobject]@{ - Year = ${l'année} - Année = ConvertTo-RomanNumeral.ps1 ${l'année} - AnnéeUnicode = ConvertTo-RomanNumeral.ps1 ${l'année} -Unicode - Month = $mois - MonthName = $months[$mois-1] - Mois = ${les mois}[$mois-1] - Day = ${jour du mois} - DayOfYear = ${jour de l'année} - Jour = ${les jours}[${jour de l'année}-1] - DayName = $days[${jour de l'année}-1] - Decade = $decade - DayOfDecade = ${jour de decade} - DecadeOrdinal = ${les jours du decade}[${jour de decade}-1] - DecimalTime = '{0:0:00:00}' -f [math]::Floor($Date.TimeOfDay.Ticks / 8640000) - GregorianDate = $Date - } |Add-Member ScriptMethod ToString -Force -PassThru ` - {"$($this.Jour) ($($this.DayName)), $($this.Day) $($this.Mois) ($($this.MonthName)) $($this.AnnéeUnicode)"} -} diff --git a/Get-OutdatedModules.ps1 b/Get-OutdatedModules.ps1 deleted file mode 100644 index 175e89e2..00000000 --- a/Get-OutdatedModules.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -<# -.SYNOPSIS -Returns a list of modules that have upgrades available. - -.FUNCTIONALITY -PowerShell Modules - -.LINK -Get-ModuleScope.ps1 - -.EXAMPLE -Get-OutdatedModules.ps1 - -Name Scope CurrentVersion AvailableVersion ----------- -------- --------------- ---------------- -PSReadLine AllUsers 2.3.6 2.4.5 -ThreadJob AllUsers 2.0.7 2.1.0 -#> - -#Requires -Version 7 -[CmdletBinding()] Param() -Get-Module -ListAvailable | - Group-Object Name | - ForEach-Object -Parallel { - $name, $group = $_.Name, $_.Group - try - {[pscustomobject]@{ - Name = $name - Scope = Get-ModuleScope.ps1 $name |Select-Object -ExpandProperty Scope - CurrentVersion = $group |Measure-Object Version -Maximum |Select-Object -ExpandProperty Maximum - AvailableVersion = Find-Module $name -infa Ignore -ErrorAction Stop |Select-Object -ExpandProperty Version - }} - catch{} - } | - Where-Object {$_.CurrentVersion -lt $_.AvailableVersion} diff --git a/Import-ClipboardTsv.ps1 b/Import-ClipboardTsv.ps1 deleted file mode 100644 index fd6a2643..00000000 --- a/Import-ClipboardTsv.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -<# -.SYNOPSIS -Parses TSV clipboard data into objects. - -.FUNCTIONALITY -Clipboard - -.LINK -Get-Clipboard - -.LINK -ConvertFrom-Csv - -.EXAMPLE -Import-ClipboardTsv.ps1 |Format-Table -AutoSize - -Name Alias Actor ----- ----- ----- -Rita Farr Elasti-Girl April Bowlby -Larry Trainor Negative Man Matt Bomer/Mathew Zuk -Kay Challis Crazy Jane Diane Guerrero -Cliff Steele Robotman Brendan Fraser/Riley Shanahan -Victor Stone Cyborg Joivan Wade -Dr. Niles Caulder The Chief Timothy Dalton -Eric Morden Mr. Nobody Alan Tudyk -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -# The field separator character. -[char] $Delimiter = "`t" -) -$data = Get-Clipboard -$data[1..($data.Length-1)] | - ConvertFrom-Csv -Delimiter $Delimiter -Header ($data[0] -split $Delimiter) diff --git a/Invoke-CachedCommand.ps1 b/Invoke-CachedCommand.ps1 deleted file mode 100644 index dceb7a19..00000000 --- a/Invoke-CachedCommand.ps1 +++ /dev/null @@ -1,114 +0,0 @@ -<# -.SYNOPSIS -Caches the output of a command for recall if called again. - -.FUNCTIONALITY -Command - -.EXAMPLE -Invoke-CachedCommand.ps1 {Invoke-RestMethod https://example.org/endpoint} -Session - -Returns the result of executing the script block, or the previous cached output if available. -#> - -#Requires -Version 7 -[CmdletBinding()] Param( -# Specifies the expression to cache the output of. -[Parameter(Position=0,Mandatory=$true)][scriptblock] $Expression, -# Parameters to the script block. -[Parameter(Position=1,ValueFromRemainingArguments=$true)][psobject[]] $BlockArgs = @(), -# The rolling duration to cache the output for (updated with each call). -[Parameter(ParameterSetName='ExpiresAfter')][timespan] $ExpiresAfter, -# Point in time to cache the output until. -[Parameter(ParameterSetName='Expires')][datetime] $Expires, -# Caches the output for this session. -[Parameter(ParameterSetName='Session')][switch] $Session, -# Forces rerunning the command to update the cache. -[switch] $Force -) -Begin -{ - function Initialize-Variables - { - [CmdletBinding()] Param() - $Script:Hash = [Security.Cryptography.MD5]::Create() - $Script:SessionCacheName = "$(Split-Path $PSCommandPath -LeafBase)#$PID" - $Script:SessionCache = Get-Variable $Script:SessionCacheName -Scope Global -ErrorAction Ignore - if(!$Script:SessionCache) - { - $Script:SessionCache = Set-Variable $Script:SessionCacheName @{} -Scope Global -Option Constant -PassThru ` - -Description 'Cached command output' - } - $Script:CacheDir = if($IsWindows) - { - Join-Path $env:LocalAppData (Split-Path $PSCommandPath -LeafBase) - } - elseif($IsLinux) - { - Join-Path ($env:XDG_CACHE_HOME ?? "$HOME/.cache") (Split-Path $PSCommandPath -LeafBase) - } - else - { - Join-Path ([io.path]::GetTempPath()) (Split-Path $PSCommandPath -LeafBase) - } - New-Item $Script:CacheDir -Type Directory -ErrorAction Ignore |Out-Null - Get-ChildItem $Script:CacheDir | - Where-Object LastWriteTime -lt (Get-Date) | - Remove-Item - } - - function Get-ScriptBlockHash - { - [CmdletBinding()] Param( - [Parameter(Position=0)][scriptblock] $ScriptBlock, - [Parameter(Position=1)][psobject[]] $BlockArgs = @() - ) - return (@("$ScriptBlock") + @($BlockArgs |ForEach-Object {ConvertTo-Json $_ -Compress}) | - ForEach-Object {ConvertTo-Base64.ps1 $Script:Hash.ComputeHash([Text.Encoding]::UTF8.GetBytes($_)) -UriStyle}) -join '.' - } - - function Get-CachedOutput - { - [CmdletBinding()] Param( - [Parameter(Position=0)][scriptblock] $ScriptBlock, - [Parameter(Position=1)][psobject[]] $BlockArgs = @(), - [datetime] $Expires, - [switch] $Force - ) - $now = Get-Date - $cacheFileName = Join-Path $Script:CacheDir "$(Get-ScriptBlockHash $ScriptBlock -BlockArgs $BlockArgs).xml" - if(Test-Path $cacheFileName -Type Leaf) - { - $cacheFile = Get-Item $cacheFileName - if($now -gt $cacheFile.LastWriteTime -or $Force) - { - $ScriptBlock.InvokeReturnAsIs(@($BlockArgs)) |Export-Clixml $cacheFileName -Force - } - } - else - { - $ScriptBlock.InvokeReturnAsIs(@($BlockArgs)) |Export-Clixml $cacheFileName - $cacheFile = Get-Item $cacheFileName - } - $cacheFile.LastWriteTime = $Expires - Import-Clixml $cacheFileName - } -} -Process -{ - Initialize-Variables - switch($PSCmdlet.ParameterSetName) - { - ExpiresAfter {Get-CachedOutput $Expression -BlockArgs $BlockArgs -Expires (Get-Date).Add($ExpiresAfter) -Force:$Force} - Expires {Get-CachedOutput $Expression -BlockArgs $BlockArgs -Expires $Expires -Force:$Force} - Session - { - $key = Get-ScriptBlockHash $Expression -BlockArgs $BlockArgs - if($Force -or !$Script:SessionCache.Value.ContainsKey($key)) - { - $Script:SessionCache.Value[$key] = $Expression.InvokeReturnAsIs(@($BlockArgs)) - } - return $Script:SessionCache.Value[$key] - } - } -} diff --git a/Join-Keys.ps1 b/Join-Keys.ps1 deleted file mode 100644 index 5f88f768..00000000 --- a/Join-Keys.ps1 +++ /dev/null @@ -1,72 +0,0 @@ -<# -.SYNOPSIS -Combines dictionaries together into a single dictionary. - -.INPUTS -System.Collections.IDictionary to combine. - -.OUTPUTS -System.Collections.IDictionary combining the inputs. - -.FUNCTIONALITY -Dictionary - -.EXAMPLE -Join-Keys.ps1 @{a=1;b=2} @{b=0;c=3} - -Name Value ----- ----- -b 2 -c 3 -a 1 - -.EXAMPLE -@{b=0;c=3},@{c=4;d=5} |Join-Keys.ps1 @{a=1;b=2} -Force |foreach {$_ |ConvertTo-Json -Compress} - -{"c":3,"b":0,"a":1} -{"d":5,"b":2,"c":4,"a":1} - -.EXAMPLE -@{b=0;c=3},@{c=4;d=5} |Join-Keys.ps1 @{a=1;b=2} -Force -Accumulate |foreach {$_ |ConvertTo-Json -Compress} - -{"c":3,"b":0,"a":1} -{"c":4,"b":0,"d":5,"a":1} - -.EXAMPLE -@{b=0;c=3},@{c=4;d=5} |Join-Keys.ps1 -Accumulate |select -Last 1 - -Name Value ----- ----- -c 3 -b 0 -d 5 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([Collections.IDictionary])] Param( -# Initial dictionary value to combine. -[Parameter(Position=0)][Collections.IDictionary] $ReferenceObject = @{}, -# Hashtables or other dictionaries to combine. -[Parameter(Position=1,Mandatory=$true,ValueFromPipeline=$true)][Collections.IDictionary] $InputObject, -<# -Indicates that the ReferenceObject should be updated with each input dictionary, -rather than the default behavior of combining the original ReferenceObject with each. -#> -[switch] $Accumulate, -<# -For matching keys, overwrites old values with new ones. -By default, only new keys are added. -#> -[switch] $Force -) -Begin {if($Accumulate) {$value = $ReferenceObject.Clone()}} -Process -{ - if(!$Accumulate) {$value = $ReferenceObject.Clone()} - foreach($key in $InputObject.Keys) - { - if(!$value.ContainsKey($key)) {$value.Add($key,$InputObject[$key])} - elseif($Force) {$value[$key] = $InputObject[$key]} - } - return $value -} diff --git a/Limit-Digits.ps1 b/Limit-Digits.ps1 deleted file mode 100644 index 1decdd2b..00000000 --- a/Limit-Digits.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -<# -.SYNOPSIS -Rounds off a number to the requested number of digits. - -.INPUTS -System.Decimal or System.Double or other numeric type that is implicitly convertible -to those types. - -.OUTPUTS -System.Decimal or System.Double depending on input type. - -.FUNCTIONALITY -Data - -.EXAMPLE -[math]::PI |Limit-Digits.ps1 4 - -3.1416 - -.EXAMPLE -1.5 |Limit-Digits.ps1 -Mode ToZero - -1 -#> - -#Requires -Version 3 -[CmdletBinding()] Param( -# The number of digits following the decimal to truncate the value to. -[Parameter(Position=0)][int] $Digits = 0, -# A numeric value to round off. -[Parameter(Position=1,Mandatory=$true,ValueFromPipeline=$true)] $InputObject, -# The rounding methodology to use. -[MidpointRounding] $Mode = [MidpointRounding]::ToEven -) -Process { return [Math]::Round($InputObject, $Digits, $Mode) } diff --git a/Measure-Properties.ps1 b/Measure-Properties.ps1 deleted file mode 100644 index b7400b9b..00000000 --- a/Measure-Properties.ps1 +++ /dev/null @@ -1,107 +0,0 @@ -<# -.SYNOPSIS -Provides frequency details about the properties across objects in the pipeline. - -.INPUTS -System.Object values to be analyzed in aggregate. - -.OUTPUTS -System.Management.Automation.PSCustomObject that describes the properties of the objects: -* PropertyName -* Type -* Unique -* Nulls -* Values -* Minimum -* Maximum - -.FUNCTIONALITY -Data - -.LINK -Write-Info.ps1 - -.LINK -Stop-ThrowError.ps1 - -.EXAMPLE -Get-PSDrive |Measure-Properties.ps1 |Format-Table -AutoSize - -Type: System.Management.Automation.PSDriveInfo -Count: 13 - -PropertyName Type Unique Nulls Values Minimum Maximum ------------- ---- ------ ----- ------ ------- ------- -Used System.Object False 12 1 219129761792.00 219129761792.00 -Free System.Object False 12 1 803764846592.00 803764846592.00 -CurrentLocation System.String False 11 2 Users\brian -Name System.String True 0 13 A WSMan -Root System.String False 4 9 \ SQLSERVER:\ -Description System.String False 1 12 X509 Certificate Provider -VolumeSeparatedByColon System.Boolean False 12 1 1.00 1.00 -#> - -#Requires -Version 7 -[CmdletBinding()] Param( -[Parameter(ValueFromPipeline=$true)] $InputObject -) -Begin -{ - $typename = New-Object Collections.Generic.HashSet[string] - [long] $count = 0 - $type = [ordered]@{} - $nullvalue = [ordered]@{} - $value = [ordered]@{} -} -Process -{ - [void]$typename.Add($null -eq $InputObject ? '(null)' : $InputObject.GetType().FullName) - $count++ - foreach($property in $InputObject.PSObject.Properties) - { - $propname,$propvalue,$proptype = $property.Name,$property.Value,$property.TypeNameOfValue - if($propvalue -isnot [icomparable]) {continue} - if(!$type.Contains($propname)) {$type[$propname] = $proptype} - if(!$nullvalue.Contains($propname)) {$nullvalue[$propname] = 0} - if($null -eq $propvalue) - { - $nullvalue[$propname]++ - } - elseif($value.Contains($propname)) - { - if($proptype -ne $type[$propname]) - { - Stop-ThrowError.ps1 "Property '$propname' has conflicting types: '$($type[$propname])' vs '$proptype'" -Argument InputObject - } - $value[$propname] += $propvalue - } - else - { - $value[$propname] = @($propvalue) - } - } -} -End -{ - Write-Info.ps1 'Type: ' -fg Green -NoNewLine - Write-Info.ps1 ($typename.GetEnumerator() -join ', ') -fg Gray - Write-Info.ps1 'Count: ' -fg Green -NoNewLine - Write-Info.ps1 $count -fg Gray - foreach($propname in $value.Keys) - { - $uniquevalues = @($value[$propname] |Select-Object -Unique).Count - #TODO: detect numeric types for stats - $stats = $value[$propname] |Measure-Object -Minimum -Maximum - #TODO: detect stringc type for length stats - #TODO: detect datetime types for expanded stats? - [pscustomobject]@{ - PropertyName = $propname - Type = $type[$propname] - Unique = $count -eq $uniquevalues - Nulls = $count - $uniquevalues - Values = $uniquevalues - Minimum = $stats.Minimum - Maximum = $stats.Maximum - } - } -} diff --git a/Measure-Values.ps1 b/Measure-Values.ps1 deleted file mode 100644 index 07d29895..00000000 --- a/Measure-Values.ps1 +++ /dev/null @@ -1,299 +0,0 @@ -<# -.SYNOPSIS -Provides analysis of supplied values. - -.INPUTS -System.Object values to be analyzed in aggregate. - -.OUTPUTS -System.Management.Automation.PSCustomObject that describes the values with properties like -MeanAverage and StandardDeviation. - -.FUNCTIONALITY -Data - -.EXAMPLE -1..54 |ForEach-Object {Get-Random} |Measure-Values.ps1 - -Type : System.Int32 -Values : 54 -NullValues : 0 -IsUnique : True -UniqueValues : 54 -Minimum : 94194382 -Maximum : 2128816298 -MeanAverage : 1088097395.2963 -MedianAverage : 1223934436 -ModeAverage : 1088097395.2963 -Variance : 3.74619103093056E+17 -StandardDeviation : 612061355.660571 - -.EXAMPLE -1..127 |ForEach-Object {Get-Date -UnixTimeSeconds (Get-Random)} |Measure-Values.ps1 - -Type : System.DateTime -Values : 127 -NullValues : 0 -IsUnique : True -UniqueValues : 127 -IsDateOnly : False -DateOnlyValues : 0 -DateTimeValues : 127 -Minimum : 1970-12-23 12:18:33 -Maximum : 2037-10-28 21:09:37 -MostCommonValue : 1970-12-23 12:18:33 -MeanAverage : 2002-09-23 09:03:30 -MedianAverage : 2002-07-23 06:51:20 -ModeAverage : 2002-09-23 09:03:30 -UniqueYears : 59 -MeanAverageYear : 2002 -MedianAverageYear : 2002 -ModeAverageYear : 1979 -StandardDeviationYear : 20.9125879067699 -UniqueMonths : 12 -MinimumMonth : January -MaximumMonth : December -MeanAverageMonth : July -MedianAverageMonth : June -ModeAverageMonth : May -StandardDeviationMonth : 3.45228333389263 -January : 10 -Febuary : 6 -March : 16 -April : 7 -May : 19 -June : 11 -July : 6 -August : 7 -September : 14 -October : 10 -November : 7 -December : 14 -UniqueDays : 29 -MinimumDay : 1 -MaximumDay : 30 -MeanAverageDay : 15.4645669291339 -MedianAverageDay : 15 -ModeAverageDay : 7 -StandardDeviationDay : 8.53172908617298 -UniqueWeekdays : 7 -MinimumWeekday : Sunday -MaximumWeekday : Saturday -MeanAverageWeekday : Wednesday -MedianAverageWeekday : Wednesday -ModeAverageWeekday : Wednesday -StandardDeviationWeekday : 1.92091482392633 -Sunday : 13 -Monday : 20 -Tuesday : 21 -Wednesday : 23 -Thursday : 16 -Friday : 15 -Saturday : 19 -#> - -#Requires -Version 7 -[CmdletBinding()] Param( -# The values to analyze. -[Parameter(ValueFromPipeline)] $InputObject -) -Begin -{ - function Measure-Stats([Parameter(ValueFromPipeline=$true)][double] $NumericValues) - {End{ - $numbers = $input - $stats = $numbers |Measure-Object -AllStats - $sorted = @($numbers |Sort-Object) - $middle = $sorted.Length/2 - $frequency = $numbers |Group-Object -NoElement |Sort-Object Count -Descending - $mode = $frequency |Where-Object Count -eq $frequency[0].Count | - Select-Object -ExpandProperty Values |Measure-Object -Average - return [pscustomobject]@{ - UniqueValues = @($numbers |Select-Object -Unique).Count - Sum = $stats.Sum - Minimum = $stats.Minimum - Maximum = $stats.Maximum - MeanAverage = $stats.Average - MedianAverage = switch($sorted.Length) - { - 1 {$sorted[0]} - {$_ -gt 1 -and $_ -band 1} {($sorted[[math]::Floor($middle)]+$sorted[[math]::Ceiling($middle)])/2} - default {$sorted[$middle]} - } - ModeAverage = $mode.Average - Variance = [math]::Pow($stats.StandardDeviation,2) - StandardDeviation = $stats.StandardDeviation - } - }} - function Get-MonthName([int] $Month) - { - return (Get-Culture).DateTimeFormat.GetMonthName($Month) - } - $nulls = 0 - [Collections.Generic.Dictionary[[type],[Collections.ArrayList]]] $values = @{} -} -Process -{ - if($null -eq $InputObject) {$nulls++} - elseif($InputObject -is [DBNull]) {$nulls++} - else - { - $type = $InputObject.GetType() - if($values.ContainsKey($type)) {$values[$type] += $InputObject} - else {$values.Add($type,@($InputObject))} - } -} -End -{ - foreach($type in $values.Keys) - { - if($type -in [int],[long],[byte],[decimal],[double],[float],[short],[sbyte],[uint16],[uint32],[uint64],[bigint],[char]) - { - $stats = $values[$type] |Measure-Stats - return [pscustomobject]@{ - Type = $type - Values = $values[$type].Count - NullValues = $nulls - IsUnique = $stats.UniqueValues -lt $values[$type].Count ? $false : $true - UniqueValues = $stats.UniqueValues - Minimum = $stats.Minimum - Maximum = $stats.Maximum - MeanAverage = $stats.MeanAverage - MedianAverage = $stats.MedianAverage - ModeAverage = $stats.ModeAverage - Variance = $stats.Variance - StandardDeviation = $stats.StandardDeviation - } - } - elseif($type -eq [string]) - { - $stats = $values[$type] |Measure-Object -Minimum -Maximum - $lenstats = $values[$type] |Select-Object -ExpandProperty Length |Measure-Stats - $unique = @($values[$type] |Select-Object -Unique).Count - ($minChar,$maxChar,$leadingZero,$leadingSpace,$trailingSpace) = ([int][char]::MaxValue,[int][char]::MinValue,0,0,0) - foreach($v in $values[$type]) - { - $minmax = $v.GetEnumerator() |Measure-Object -Minimum -Maximum - if($minmax.Minimum -lt $minChar) {$minChar = [int]$minmax.Minimum} - if($minmax.Maximum -gt $maxChar) {$maxChar = [int]$minmax.Maximum} - if($v.StartsWith('0')) {$leadingZero++} - if($v.StartsWith(' ')) {$leadingSpace++} - if($v.EndsWith(' ')) {$trailingSpace++} - } - return [pscustomobject]@{ - Type = $type - Values = $values[$type].Count - NullValues = $nulls - IsUnique = $unique -lt $values[$type].Count ? $false : $true - UniqueValues = $unique - Minimum = $stats.Minimum - Maximum = $stats.Maximum - MinimumCharacter = [char]$minChar - MaximumCharacter = [char]$maxChar - HasLeadingZero = $leadingZero - HasLeadingSpace = $leadingSpace - HasTrailingSpace = $trailingSpace - MinimumLength = $lenstats.Minimum - MaximumLength = $lenstats.Maximum - MeanAverageLength = $lenstats.MeanAverage - MedianAverageLength = $lenstats.MedianAverage - ModeAverageLength = $lenstats.ModeAverage - VarianceLength = $lenstats.Variance - StandardDeviation = $lenstats.StandardDeviation - } - } - elseif($type -in [datetime],[dateonly],[timeonly],[datetimeoffset]) - { - [Collections.ArrayList] $v = $values[$type] - [Collections.ArrayList] $e = $v |ConvertTo-EpochTime.ps1 - $stats = $v |Measure-Object -Minimum -Maximum - $estats = $e |Measure-Stats - $ystats = $v |Select-Object -ExpandProperty Year |Measure-Stats - $mstats = $v |Select-Object -ExpandProperty Month |Measure-Stats - $dstats = $v |Select-Object -ExpandProperty Day |Measure-Stats - $wstats = $v |ForEach-Object {[int]$_.DayOfWeek} |Measure-Stats - $unique = @($v |Select-Object -Unique).Count - $dateonly = $type -eq [dateonly] ? $v : @($v |Where-Object {$_ -eq $_.Date}).Count - $datetime = $v.Count - $dateonly - return [pscustomobject]@{ - Type = $type - Values = $v.Count - NullValues = $nulls - IsUnique = $unique -lt $v.Count ? $false : $true - UniqueValues = $unique - IsDateOnly = !$datetime - DateOnlyValues = $dateonly - DateTimeValues = $datetime - Minimum = $stats.Minimum - Maximum = $stats.Maximum - MostCommonValue = $v |Group-Object -NoElement |Sort-Object Count -Descending |Select-Object -First 1 -ExpandProperty Values - MeanAverage = Get-Date -UnixTimeSeconds ([int]$estats.MeanAverage) - MedianAverage = Get-Date -UnixTimeSeconds ([int]$estats.MedianAverage) - ModeAverage = Get-Date -UnixTimeSeconds ([int]$estats.ModeAverage) - UniqueYears = $ystats.UniqueValues - MeanAverageYear = [int]($ystats.MeanAverage) - MedianAverageYear = [int]($ystats.MedianAverage) - ModeAverageYear = [int]($ystats.ModeAverage) - StandardDeviationYear = $ystats.StandardDeviation - UniqueMonths = $mstats.UniqueValues - MinimumMonth = Get-MonthName $mstats.Minimum - MaximumMonth = Get-MonthName $mstats.Maximum - MeanAverageMonth = Get-MonthName $mstats.MeanAverage - MedianAverageMonth = Get-MonthName $mstats.MedianAverage - ModeAverageMonth = Get-MonthName $mstats.ModeAverage - StandardDeviationMonth = $mstats.StandardDeviation - January = @($v |Where-Object {$_.Month -eq 1}).Count - Febuary = @($v |Where-Object {$_.Month -eq 2}).Count - March = @($v |Where-Object {$_.Month -eq 3}).Count - April = @($v |Where-Object {$_.Month -eq 4}).Count - May = @($v |Where-Object {$_.Month -eq 5}).Count - June = @($v |Where-Object {$_.Month -eq 6}).Count - July = @($v |Where-Object {$_.Month -eq 7}).Count - August = @($v |Where-Object {$_.Month -eq 8}).Count - September = @($v |Where-Object {$_.Month -eq 9}).Count - October = @($v |Where-Object {$_.Month -eq 10}).Count - November = @($v |Where-Object {$_.Month -eq 11}).Count - December = @($v |Where-Object {$_.Month -eq 12}).Count - UniqueDays = $dstats.UniqueValues - MinimumDay = $dstats.Minimum - MaximumDay = $dstats.Maximum - MeanAverageDay = $dstats.MeanAverage - MedianAverageDay = $dstats.MedianAverage - ModeAverageDay = $dstats.ModeAverage - StandardDeviationDay = $dstats.StandardDeviation - UniqueWeekdays = $wstats.UniqueValues - MinimumWeekday = [DayOfWeek] $wstats.Minimum - MaximumWeekday = [DayOfWeek] $wstats.Maximum - MeanAverageWeekday = [DayOfWeek][int] $wstats.MeanAverage - MedianAverageWeekday = [DayOfWeek][int] $wstats.MedianAverage - ModeAverageWeekday = [DayOfWeek][int] $wstats.ModeAverage - StandardDeviationWeekday = $wstats.StandardDeviation - Sunday = @($v |Where-Object {$_.DayOfWeek -eq [DayOfWeek]::Sunday}).Count - Monday = @($v |Where-Object {$_.DayOfWeek -eq [DayOfWeek]::Monday}).Count - Tuesday = @($v |Where-Object {$_.DayOfWeek -eq [DayOfWeek]::Tuesday}).Count - Wednesday = @($v |Where-Object {$_.DayOfWeek -eq [DayOfWeek]::Wednesday}).Count - Thursday = @($v |Where-Object {$_.DayOfWeek -eq [DayOfWeek]::Thursday}).Count - Friday = @($v |Where-Object {$_.DayOfWeek -eq [DayOfWeek]::Friday}).Count - Saturday = @($v |Where-Object {$_.DayOfWeek -eq [DayOfWeek]::Saturday}).Count - } - } - elseif($type -eq [bool]) - { - return [pscustomobject]@{ - Type = $type - Values = $values[$type].Count - NullValues = $nulls - FalseValues = @($values[$type] |Where-Object {!$_}).Count - TrueValues = @($values[$type] |Where-Object {$_}).Count - } - } - else - { - return [pscustomobject]@{ - Type = $type - Values = $values[$type].Count - NullValues = $nulls - } - } - } -} diff --git a/README.md b/README.md index 308bff7c..1725a31c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -Useful General-Purpose Scripts +Useful General-Purpose Scripts ============================== [![Pester tests results](https://gist.githubusercontent.com/brianary/4642e5c804aa1b40738def5a7c03607a/raw/badge.svg)][pester.yml] -[![Pester tests coverage](https://img.shields.io/badge/Pester_coverage-3334_%E2%80%B1-orangered)](https://github.com/brianary/scripts/tree/main/test) +[![Pester tests coverage](https://img.shields.io/badge/Pester_coverage-3471_%E2%80%B1-orange +red)](https://github.com/brianary/scripts/tree/main/test) [![GitHub license badge](https://badgen.net/github/license/brianary/Scripts?icon=github)](https://mit-license.org/ "MIT License") [![GitHub stars badge](https://badgen.net/github/stars/brianary/Scripts?icon=github)](https://github.com/brianary/scripts/stargazers "Stars") [![GitHub watchers badge](https://badgen.net/github/watchers/brianary/Scripts?icon=github)](https://github.com/brianary/scripts/watchers "Watchers") @@ -15,6 +16,13 @@ Useful General-Purpose Scripts [pester.yml]: https://github.com/brianary/scripts/actions/workflows/pester.yml "Pester test run history" +> [!NOTE] +> Many scripts have been moved into modules to improve their usability! +> See **[ModernConveniences][]** and the [scripts-to-modules.json roadmap][]. + +[ModernConveniences]: https://github.com/brianary/ModernConveniences/ "A collection of general-purpose functions for objects, properties, and more." +[scripts-to-modules.json roadmap]: scripts-to-modules.json "The plan to divide the scripts into modules by purpose." + This repo contains a collection of generally useful scripts (mostly Windows PowerShell). See [PS5](PS5) for legacy scripts, [syscfg](syscfg) for single-use system config scripts. @@ -22,17 +30,9 @@ See [PS5](PS5) for legacy scripts, [syscfg](syscfg) for single-use system config PowerShell Scripts ------------------ -### Clipboard - -- **[Convert-ClipboardTsvToHtml.ps1](Convert-ClipboardTsvToHtml.ps1)**: Parses TSV clipboard data into HTML table data which is copied back to the clipboard. -- **[Import-ClipboardTsv.ps1](Import-ClipboardTsv.ps1)**: Parses TSV clipboard data into objects. - ### Command -- **[Get-CommandParameters.ps1](Get-CommandParameters.ps1)**: Returns the parameters of the specified cmdlet. -- **[Get-CommandPath.ps1](Get-CommandPath.ps1)**: Locates a command. - **[Hide-Command.ps1](Hide-Command.ps1)**: Make a command unavailable. -- **[Invoke-CachedCommand.ps1](Invoke-CachedCommand.ps1)**: Caches the output of a command for recall if called again. - **[Invoke-CommandWithParams.ps1](Invoke-CommandWithParams.ps1)**: Execute a command by using matching dictionary entries as parameters. - **[Use-Command.ps1](Use-Command.ps1)**: Checks for the existence of the given command, and adds if missing and a source is defined. @@ -44,10 +44,6 @@ PowerShell Scripts ### Console -- **[Disable-AnsiColor.ps1](Disable-AnsiColor.ps1)**: Disables ANSI terminal colors. -- **[Enable-AnsiColor.ps1](Enable-AnsiColor.ps1)**: Enables ANSI terminal colors. -- **[Get-ConsoleHistory.ps1](Get-ConsoleHistory.ps1)**: Returns the DOSKey-style console command history (up arrow or F8). -- **[Remove-ConsoleHistory.ps1](Remove-ConsoleHistory.ps1)**: Removes an entry from the DOSKey-style console command history (up arrow or F8). - **[Set-ConsoleColorTheme.ps1](Set-ConsoleColorTheme.ps1)**: Overrides ConsoleClass window color palette entries with a preset color theme. ### Credential @@ -59,33 +55,14 @@ PowerShell Scripts - **[Remove-CachedCredential.ps1](Remove-CachedCredential.ps1)**: Removes a credential from secure storage. - **[Save-Secret.ps1](Save-Secret.ps1)**: Sets a secret in a secret vault with metadata. -### Data - -- **[Limit-Digits.ps1](Limit-Digits.ps1)**: Rounds off a number to the requested number of digits. -- **[Measure-Properties.ps1](Measure-Properties.ps1)**: Provides frequency details about the properties across objects in the pipeline. -- **[Measure-Values.ps1](Measure-Values.ps1)**: Provides analysis of supplied values. - -### Data encoding - -- **[ConvertFrom-Base64.ps1](ConvertFrom-Base64.ps1)**: Converts base64-encoded text to bytes or text. -- **[ConvertFrom-Hex.ps1](ConvertFrom-Hex.ps1)**: Convert a string of hexadecimal digits into a byte array. -- **[ConvertTo-Base64.ps1](ConvertTo-Base64.ps1)**: Converts bytes or text to base64-encoded text. - ### Data formats -- **[ConvertTo-PowerShell.ps1](ConvertTo-PowerShell.ps1)**: Serializes complex content into PowerShell literals. -- **[Format-EscapedUrl.ps1](Format-EscapedUrl.ps1)**: Escape URLs more aggressively. - **[New-Jwt.ps1](New-Jwt.ps1)**: Generates a JSON Web Token (JWT) -- **[Split-Uri.ps1](Split-Uri.ps1)**: Splits a URI into component parts. -- **[Test-FileTypeMagicNumber.ps1](Test-FileTypeMagicNumber.ps1)**: Tests for a given common file type by magic number. - **[Test-Jwt.ps1](Test-Jwt.ps1)**: Determines whether a string is a valid JWT. -- **[Test-MagicNumber.ps1](Test-MagicNumber.ps1)**: Tests a file for a "magic number" (identifying sequence of bytes) at a given location. -- **[Test-Uri.ps1](Test-Uri.ps1)**: Determines whether a string is a valid URI. - **[Test-Windows1252.ps1](Test-Windows1252.ps1)**: Determines whether a file contains Windows-1252 bytes that are invalid UTF-8 bytes. ### Database -- **[ConvertFrom-DataRow.ps1](ConvertFrom-DataRow.ps1)**: Converts a DataRow object to a PSObject, Hashtable, or single value. - **[Export-DatabaseScripts.ps1](Export-DatabaseScripts.ps1)**: Exports MS SQL database objects from the given server and database as files, into a consistent folder structure. - **[Export-TableMerge.ps1](Export-TableMerge.ps1)**: Exports table data as a T-SQL MERGE statement. - **[Find-DatabaseValue.ps1](Find-DatabaseValue.ps1)**: Searches an entire database for a field value. @@ -104,25 +81,7 @@ PowerShell Scripts ### Date and time -- **[Add-TimeSpan.ps1](Add-TimeSpan.ps1)**: Adds a timespan to DateTime values. -- **[ConvertFrom-Duration.ps1](ConvertFrom-Duration.ps1)**: Parses a Timespan from a ISO8601 duration string. -- **[ConvertFrom-EpochTime.ps1](ConvertFrom-EpochTime.ps1)**: Converts an integer Unix (POSIX) time (seconds since Jan 1, 1970) into a DateTime value. -- **[ConvertFrom-IsoWeekDate.ps1](ConvertFrom-IsoWeekDate.ps1)**: Returns a DateTime object from an ISO week date string. -- **[ConvertTo-EpochTime.ps1](ConvertTo-EpochTime.ps1)**: Converts a DateTime value into an integer Unix (POSIX) time, seconds since Jan 1, 1970. - **[ConvertTo-LogParserTimestamp.ps1](ConvertTo-LogParserTimestamp.ps1)**: Formats a datetime as a LogParser literal. -- **[Format-Date.ps1](Format-Date.ps1)**: Returns a date/time as a named format. -- **[Get-FrenchRepublicanDate.ps1](Get-FrenchRepublicanDate.ps1)**: Returns a date and time converted to the French Republican Calendar. -- **[Show-Time.ps1](Show-Time.ps1)**: Displays a formatted date using powerline font characters. -- **[Test-DateTime.ps1](Test-DateTime.ps1)**: Tests whether the given string can be parsed as a date. -- **[Test-USFederalHoliday.ps1](Test-USFederalHoliday.ps1)**: Returns true if the given date is a U.S. federal holiday. - -### Dictionary - -- **[Compare-Keys.ps1](Compare-Keys.ps1)**: Returns the differences between two dictionaries. -- **[ConvertTo-OrderedDictionary.ps1](ConvertTo-OrderedDictionary.ps1)**: Converts an object to an ordered dictionary of properties and values. -- **[Join-Keys.ps1](Join-Keys.ps1)**: Combines dictionaries together into a single dictionary. -- **[Remove-NullValues.ps1](Remove-NullValues.ps1)**: Removes dictionary entries with null vaules. -- **[Split-Keys.ps1](Split-Keys.ps1)**: Clones a dictionary keeping only the specified keys. ### DotNet @@ -136,20 +95,15 @@ PowerShell Scripts ### EnvironmentVariables - **[Compress-EnvironmentVariables.ps1](Compress-EnvironmentVariables.ps1)**: Replaces each of the longest matching parts of a string with an embedded environment variable with that value. -- **[Expand-EnvironmentVariables.ps1](Expand-EnvironmentVariables.ps1)**: Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string. ### Files - **[Backup-File.ps1](Backup-File.ps1)**: Create a backup as a sibling to a file, with date and time values in the name. -- **[Find-NewestFile.ps1](Find-NewestFile.ps1)**: Finds the most recent file. - **[Join-FileName.ps1](Join-FileName.ps1)**: Combines a filename with a string. - **[Measure-Caches.ps1](Measure-Caches.ps1)**: Returns a list of matching cache directories, and their sizes, sorted. - **[New-Shortcut.ps1](New-Shortcut.ps1)**: Create a Windows shortcut. - **[Remove-LockyFile.ps1](Remove-LockyFile.ps1)**: Removes a file that may be prone to locking. -- **[Show-PSDriveUsage.ps1](Show-PSDriveUsage.ps1)**: Displays drive usage graphically, and with a human-readable summary. - **[Test-LockedFile.ps1](Test-LockedFile.ps1)**: Returns true if the specified file is locked. -- **[Test-NewerFile.ps1](Test-NewerFile.ps1)**: Returns true if the difference file is newer than the reference file. -- **[Update-Files.ps1](Update-Files.ps1)**: Copies specified source files that exist in the destination directory. ### Git and GitHub @@ -167,29 +121,20 @@ PowerShell Scripts - **[ConvertTo-MultipartFormData.ps1](ConvertTo-MultipartFormData.ps1)**: Creates multipart/form-data to send as a request body. - **[Get-ContentSecurityPolicy.ps1](Get-ContentSecurityPolicy.ps1)**: Returns the content security policy at from the given URL. - **[Get-SslDetails.ps1](Get-SslDetails.ps1)**: Enumerates the SSL protocols that the client is able to successfully use to connect to a server. -- **[Save-WebRequest.ps1](Save-WebRequest.ps1)**: Downloads a given URL to a file, automatically determining the filename. - **[Show-HttpStatus.ps1](Show-HttpStatus.ps1)**: Displays the HTTP status code info. -- **[Trace-WebRequest.ps1](Trace-WebRequest.ps1)**: Provides details about a retrieving a URI. ### Json - **[Export-Json.ps1](Export-Json.ps1)**: Exports a portion of a JSON document, recursively importing references. -- **[Export-OpenApiSchema.ps1](Export-OpenApiSchema.ps1)**: Extracts a JSON schema from an OpenAPI definition. - **[Get-OpenApiInfo.ps1](Get-OpenApiInfo.ps1)**: Returns metadata from an OpenAPI definition. - **[Merge-Json.ps1](Merge-Json.ps1)**: Create a new JSON string by recursively combining the properties of JSON strings. - **[Resolve-JsonPointer.ps1](Resolve-JsonPointer.ps1)**: Returns matching JSON Pointer paths, given a JSON Pointer path with wildcards. - **[Select-Json.ps1](Select-Json.ps1)**: Returns a value from a JSON string or file. - **[Set-Json.ps1](Set-Json.ps1)**: Sets a property in a JSON string or file. -- **[Show-OpenApiInfo.ps1](Show-OpenApiInfo.ps1)**: Displays metadata from an OpenAPI definition. - -### Markdown - -- **[Repair-MarkdownHeaders.ps1](Repair-MarkdownHeaders.ps1)**: Updates markdown content to replace level 1 & 2 ATX headers to Setext headers. ### Mermaid Diagrams - **[Export-MermaidER.ps1](Export-MermaidER.ps1)**: Generates a Mermaid entity relation diagram for database tables. -- **[Export-MermaidXY.ps1](Export-MermaidXY.ps1)**: Generates a Mermaid XY bar/line chart for the values of a series of properties. ### Notebooks @@ -200,52 +145,13 @@ PowerShell Scripts - **[Find-ProjectPackages.ps1](Find-ProjectPackages.ps1)**: Find modules used in projects. - **[Get-LibraryVulnerabilityInfo.ps1](Get-LibraryVulnerabilityInfo.ps1)**: Get the list of module/package/library vulnerabilities from the RetireJS or SafeNuGet projects. -### Parameters - -- **[Add-ParameterDefault.ps1](Add-ParameterDefault.ps1)**: Appends or creates a value to use for the specified cmdlet parameter to use when one is not specified. -- **[Remove-ParameterDefault.ps1](Remove-ParameterDefault.ps1)**: Removes a value that would have been used for a parameter if none was specified, if one existed. -- **[Set-ParameterDefault.ps1](Set-ParameterDefault.ps1)**: Assigns a value to use for the specified cmdlet parameter to use when one is not specified. - ### PowerShell -- **[Add-Counter.ps1](Add-Counter.ps1)**: Adds an incrementing integer property to each pipeline object. -- **[Add-DynamicParam.ps1](Add-DynamicParam.ps1)**: Adds a dynamic parameter to a script, within a DynamicParam block. -- :up: **[Add-NugetPackage.ps1](Add-NugetPackage.ps1)**: Loads a NuGet package DLL, downloading as needed. - **[Add-ScopeLevel.ps1](Add-ScopeLevel.ps1)**: Convert a scope level to account for another call stack level. -- **[ForEach-Progress.ps1](ForEach-Progress.ps1)**: Performs an operation against each item in a collection of input objects, with a progress bar. -- **[Format-ByteUnits.ps1](Format-ByteUnits.ps1)**: Converts bytes to largest possible units, to improve readability. -- **[Format-Permutations.ps1](Format-Permutations.ps1)**: Builds format strings using every combination of elements from multiple arrays. -- **[Get-EnumValues.ps1](Get-EnumValues.ps1)**: Returns the possible values of the specified enumeration. -- **[Get-TypeAccelerators.ps1](Get-TypeAccelerators.ps1)**: Returns the list of PowerShell type accelerators. -- **[Import-Variables.ps1](Import-Variables.ps1)**: Creates local variables from a data row or dictionary (hashtable). -- **[Invoke-WindowsPowerShell.ps1](Invoke-WindowsPowerShell.ps1)**: Runs commands in Windows PowerShell (typically from PowerShell Core). -- **[Merge-PSObject.ps1](Merge-PSObject.ps1)**: Create a new PSObject by recursively combining the properties of PSObjects. -- **[Read-Choice.ps1](Read-Choice.ps1)**: Returns choice selected from a list of options. -- **[Stop-ThrowError.ps1](Stop-ThrowError.ps1)**: Throws a better error than "throw". -- :up: **[Test-Administrator.ps1](Test-Administrator.ps1)**: Checks whether the current session has administrator privileges. -- **[Test-Interactive.ps1](Test-Interactive.ps1)**: Determines whether both the user and process are interactive. -- **[Test-Range.ps1](Test-Range.ps1)**: Returns true from an initial condition until a terminating condition; a latching test. -- **[Test-Variable.ps1](Test-Variable.ps1)**: Indicates whether a variable has been defined. -- **[Use-ProgressView.ps1](Use-ProgressView.ps1)**: Sets the progress bar display view. -- **[Use-ReasonableDefaults.ps1](Use-ReasonableDefaults.ps1)**: Sets certain cmdlet parameter defaults to rational, useful values. -- **[Write-Info.ps1](Write-Info.ps1)**: Writes to the information stream, with color support and more. - -### PowerShell Modules - -- **[Get-ModuleScope.ps1](Get-ModuleScope.ps1)**: Returns the scope of an installed module. -- **[Uninstall-OldModules.ps1](Uninstall-OldModules.ps1)**: Uninstalls old module versions. -- **[Update-Modules.ps1](Update-Modules.ps1)**: Cleans up old modules. - -### Properties - -- **[Add-NoteProperty.ps1](Add-NoteProperty.ps1)**: Adds a NoteProperty to a PSObject, calculating the value with the object in context. -- **[Compare-Properties.ps1](Compare-Properties.ps1)**: Compares the properties of two objects. -- **[Test-NoteProperty.ps1](Test-NoteProperty.ps1)**: Looks for any matching NoteProperties on an object. ### Scheduled Tasks - **[Backup-SchTasks.ps1](Backup-SchTasks.ps1)**: Exports the local list of Scheduled Tasks into a single XML file. -- **[ConvertFrom-CimInstance.ps1](ConvertFrom-CimInstance.ps1)**: Convert a CimInstance object to a PSObject. - **[ConvertTo-ICalendar.ps1](ConvertTo-ICalendar.ps1)**: Converts supported objects (Scheduled Tasks) to the RFC 5545 iCalendar format. - **[Copy-SchTasks.ps1](Copy-SchTasks.ps1)**: Copy scheduled jobs from another computer to this one, using a GUI list to choose jobs. - **[Get-SimpleSchTasks.ps1](Get-SimpleSchTasks.ps1)**: Returns simple scheduled task info. @@ -259,14 +165,10 @@ PowerShell Scripts - **[Optimize-Help.ps1](Optimize-Help.ps1)**: Cleans up comment-based help blocks by fully unindenting and capitalizing dot keywords. - **[Rename-Script.ps1](Rename-Script.ps1)**: Renames all instances of a script, and updates any usage of it. - **[Repair-ScriptStyle.ps1](Repair-ScriptStyle.ps1)**: Accepts justifications for script analysis rule violations, fixing the rest using Invoke-ScriptAnalysis. -- **[Select-ScriptCommands.ps1](Select-ScriptCommands.ps1)**: Returns the commands used by the specified script. ### Search and replace -- **[Add-CapturesToMatches.ps1](Add-CapturesToMatches.ps1)**: Adds named capture group values as note properties to Select-String MatchInfo objects. - **[Find-Lines.ps1](Find-Lines.ps1)**: Searches a specific subset of files for lines matching a pattern. -- **[Select-CapturesFromMatches.ps1](Select-CapturesFromMatches.ps1)**: Selects named capture group values as note properties from Select-String MatchInfo objects. -- **[Set-RegexReplace.ps1](Set-RegexReplace.ps1)**: Updates text found with Select-String, using a regular expression replacement template. ### Seq @@ -283,8 +185,7 @@ PowerShell Scripts - **[Get-SystemDetails.ps1](Get-SystemDetails.ps1)**: Collects some useful system hardware and operating system details via CIM. - **[Import-EdgeKeywords.ps1](Import-EdgeKeywords.ps1)**: Adds search keywords to an Edge SQLite profile configuration. - **[Read-ChocolateySummary.ps1](Read-ChocolateySummary.ps1)**: Retrieves the a summary from the Chocolatey log. -- :new: **[Show-Status.ps1](Show-Status.ps1)**: Displays requested system status values using powerline font characters. -- :up: **[Update-Everything.ps1](Update-Everything.ps1)**: Updates everything it can on the system. +- **[Update-Everything.ps1](Update-Everything.ps1)**: Updates everything it can on the system. - **[Use-Java.ps1](Use-Java.ps1)**: Switch the Java version for the current process by modifying environment variables. ### TLS/SSL @@ -293,14 +194,12 @@ PowerShell Scripts ### Unicode -- **[ConvertTo-FileName.ps1](ConvertTo-FileName.ps1)**: Returns a valid and safe filename from a given string. -- **[ConvertTo-SafeEntities.ps1](ConvertTo-SafeEntities.ps1)**: Encode text as XML/HTML, escaping all characters outside 7-bit ASCII. - **[Get-CharacterDetails.ps1](Get-CharacterDetails.ps1)**: Returns filterable categorical information about characters in the Unicode Basic Multilingual Plane. - **[Get-Unicode.ps1](Get-Unicode.ps1)**: Returns the (UTF-16) .NET string for a given Unicode codepoint, which may be a surrogate pair. - **[Get-UnicodeByName.ps1](Get-UnicodeByName.ps1)**: Returns characters based on Unicode code point name, GitHub short code, or HTML entity. - **[Get-UnicodeData.ps1](Get-UnicodeData.ps1)**: Returns the current (cached) Unicode character data. - **[Get-UnicodeName.ps1](Get-UnicodeName.ps1)**: Returns the name of a Unicode code point. -- :up: **[Import-CharConstants.ps1](Import-CharConstants.ps1)**: Imports characters by name as constants into the current scope. +- **[Import-CharConstants.ps1](Import-CharConstants.ps1)**: Imports characters by name as constants into the current scope. ### VSCode @@ -312,6 +211,11 @@ PowerShell Scripts - **[Push-WorkspaceLocation.ps1](Push-WorkspaceLocation.ps1)**: Pushes the current VS Code editor workspace location to the location stack. - **[Set-VSCodeSetting.ps1](Set-VSCodeSetting.ps1)**: Sets a VSCode setting. +### Windows Terminal + +- **[Set-TerminalProfile.ps1](Set-TerminalProfile.ps1)**: Adds or updates a Windows Terminal command profile. +- **[Test-WindowsTerminal.ps1](Test-WindowsTerminal.ps1)**: Returns true if PowerShell is running within Windows Terminal. + ### XML - **[Compare-Xml.ps1](Compare-Xml.ps1)**: Compares two XML documents and returns the differences. @@ -332,10 +236,7 @@ PowerShell Scripts - **[Backup-Workstation.ps1](Backup-Workstation.ps1)**: Adds various configuration files and exported settings to a ZIP file. - **[Connect-SshKey.ps1](Connect-SshKey.ps1)**: Uses OpenSSH to generate a key and connect it to an ssh server. -- **[ConvertTo-RomanNumeral.ps1](ConvertTo-RomanNumeral.ps1)**: Convert a number to a Roman numeral. -- **[Copy-Html.ps1](Copy-Html.ps1)**: Copies objects as an HTML table. - :up: **[Export-Readme.ps1](Export-Readme.ps1)**: Generate README.md file for the scripts repo. -- **[Format-HtmlDataTable.ps1](Format-HtmlDataTable.ps1)**: Right-aligns numeric data in an HTML table for emailing, and optionally zebra-stripes &c. - **[Get-ADServiceAccountInfo.ps1](Get-ADServiceAccountInfo.ps1)**: Lists the Global Managed Service Accounts for the domain, including the computers they are bound to. - **[Get-AspNetEvents.ps1](Get-AspNetEvents.ps1)**: Parses ASP.NET errors from the event log on the given server. - **[Get-Dns.ps1](Get-Dns.ps1)**: Looks up DNS info, given a hostname or address. @@ -343,7 +244,6 @@ PowerShell Scripts - **[Get-IisLog.ps1](Get-IisLog.ps1)**: Easily query IIS logs. - **[Get-PathUsage.ps1](Get-PathUsage.ps1)**: Returns the list of directories in the path, and the commands found in each. - **[Get-PocketArticles.ps1](Get-PocketArticles.ps1)**: Retrieves a list of saved articles from a Pocket account. -- **[Get-RandomBytes.ps1](Get-RandomBytes.ps1)**: Returns random bytes. - **[Get-Todos.ps1](Get-Todos.ps1)**: Returns the TODOs for the current git repo, which can help document technical debt. - **[Measure-Indents.ps1](Measure-Indents.ps1)**: Measures the indentation characters used in a text file. - **[Measure-StandardDeviation.ps1](Measure-StandardDeviation.ps1)**: Calculate the standard deviation of numeric values. @@ -353,11 +253,8 @@ PowerShell Scripts - **[Remove-PocketArticle.ps1](Remove-PocketArticle.ps1)**: Removes an article from a Pocket account. - **[Repair-AppxPackages.ps1](Repair-AppxPackages.ps1)**: Re-registers all installed Appx packages. - **[Restore-Workstation.ps1](Restore-Workstation.ps1)**: Restores various configuration files and exported settings from a ZIP file. -- **[Save-PodcastEpisodes.ps1](Save-PodcastEpisodes.ps1)**: Downloads enclosures from a podcast feed. - **[Send-MailMessageFile.ps1](Send-MailMessageFile.ps1)**: Sends emails from a drop folder using .NET config defaults. - **[Test-HttpSecurity.ps1](Test-HttpSecurity.ps1)**: Scan sites using Mozilla's Observatory. -- :up: **[Write-CallInfo.ps1](Write-CallInfo.ps1)**: Prints caller name and parameters to the host for debugging purposes. -- **[Write-VisibleString.ps1](Write-VisibleString.ps1)**: Displays a string, showing nonprintable characters. F# Scripts ---------- @@ -367,8 +264,8 @@ F# Scripts Office VBA Scripts ------------------ -- **[OutlookExpireTag.vba](OutlookExpireTag.vba)**: Too many emails remain beyond their period of relevance: daily personnel schedule changes, found item notices, office food notices, server reboot notices, weather/traffic warnings, &c. This Outlook script will allow specifying an expiration date as a hashtag in the subject of outgoing emails, since Outlook does such a good job of hiding the UI for that field. -BL -- **[OutlookPasteFormattedIndented.vba](OutlookPasteFormattedIndented.vba)**: Outlook will strip single-space indents when displaying emails. If you've got, for example, syntax highlighted source code that employs any indentation of only one space, you'll want to add two spaces to the each line (adding one will not appear for text that isn't indented). This Outlook script will paste formatted text, and indent it. Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work) -- **[OutlookPasteTsvTable.vba](OutlookPasteTsvTable.vba)**: This Outlook VBA Sub can be connected to a toolbar button for pasting TSV data as an attractive, formatted table. -BL Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work) +- **[OutlookExpireTag.vba](OutlookExpireTag.vba)**: Too many emails remain beyond their period of relevance: daily personnel schedule changes, found item notices, office food notices, server reboot notices, weather/traffic warnings, &c. This Outlook script will allow specifying an expiration date as a hashtag in the subject of outgoing emails, since Outlook does such a good job of hiding the UI for that field. -BL +- **[OutlookPasteFormattedIndented.vba](OutlookPasteFormattedIndented.vba)**: Outlook will strip single-space indents when displaying emails. If you've got, for example, syntax highlighted source code that employs any indentation of only one space, you'll want to add two spaces to the each line (adding one will not appear for text that isn't indented). This Outlook script will paste formatted text, and indent it. Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work) +- **[OutlookPasteTsvTable.vba](OutlookPasteTsvTable.vba)**: This Outlook VBA Sub can be connected to a toolbar button for pasting TSV data as an attractive, formatted table. -BL Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work) - + diff --git a/Remove-ConsoleHistory.ps1 b/Remove-ConsoleHistory.ps1 deleted file mode 100644 index 945591c3..00000000 --- a/Remove-ConsoleHistory.ps1 +++ /dev/null @@ -1,81 +0,0 @@ -<# -.SYNOPSIS -Removes an entry from the DOSKey-style console command history (up arrow or F8). - -.INPUTS -System.String containing exact commands to remove. - -.FUNCTIONALITY -Console - -.EXAMPLE -Remove-ConsoleHistory.ps1 -Id 42 - -Deletes the 42nd command from the history. - -.EXAMPLE -Remove-ConsoleHistory.ps1 -Duplicates - -Deletes any repeated commands from the history. - -.EXAMPLE -Remove-ConsoleHistory.ps1 -Like winget* - -Deletes any commands that start with "winget" from the history. -#> - -#Requires -Version 7 -[CmdletBinding(ConfirmImpact='High',SupportsShouldProcess=$true)] Param( -[Parameter(ParameterSetName='Id',Mandatory=$true)][int] $Id, -[Parameter(ParameterSetName='CommandLine',Position=0,Mandatory=$true,ValueFromPipeline=$true)][string] $CommandLine, -[Parameter(ParameterSetName='Like',Mandatory=$true)][string] $Like, -[Parameter(ParameterSetName='Duplicates',Mandatory=$true)][switch] $Duplicates -) -Begin -{ - $history = Get-PSReadLineOption |Select-Object -ExpandProperty HistorySavePath -} -Process -{ - switch($PSCmdlet.ParameterSetName) - { - Id - { - $cmd = Get-Content $history -TotalCount $Id |Select-Object -Last 1 - if($PSCmdlet.ShouldProcess($cmd, 'remove')) - { - $i = 1 - (Get-Content $history) |Where-Object {$i++ -ne $Id} |Out-File $history -Encoding utf8NoBOM - Write-Verbose "Removed '$cmd'" - } - } - CommandLine - { - [bool] $found = Get-Content $history |Where-Object {$_ -eq $CommandLine} |Select-Object -First 1 - if($found -and $PSCmdlet.ShouldProcess($CommandLine, 'remove')) - { - (Get-Content $history) -ne $CommandLine |Out-File $history -Encoding utf8NoBOM - if($found) {Write-Verbose "Removed '$CommandLine'"} - } - } - Like - { - $cmd = (Get-Content $history) -like $Like - if($PSCmdlet.ShouldProcess("$($cmd.Count) commands matching '$Like'", 'remove')) - { - (Get-Content $history) -notlike $Like |Out-File $history -Encoding utf8NoBOM - $cmd |ForEach-Object {Write-Verbose "Removed '$_'"} - } - } - Duplicates - { - if($PSCmdlet.ShouldProcess('duplicate commands', 'remove')) - { - $before = (Get-Content $history).Count - (Get-Content $history) |Select-Object -Unique |Out-File $history -Encoding utf8NoBOM - $after = (Get-Content $history).Count - Write-Verbose "Removed $($before - $after) duplicate entries" - } - } - } -} diff --git a/Remove-NullValues.ps1 b/Remove-NullValues.ps1 deleted file mode 100644 index f5cd0c4a..00000000 --- a/Remove-NullValues.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -<# -.SYNOPSIS -Removes dictionary entries with null vaules. - -.INPUTS -System.Collections.IDictionary to remove nulls from. - -.OUTPUTS -System.Collections.IDictionary with null-valued entries removed. - -.FUNCTIONALITY -Dictionary - -.EXAMPLE -@{ a = 1; b = $null; c = 3 } |Remove-NullValues.ps1 - -Name Value ----- ----- -c 3 -a 1 -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([Collections.IDictionary])] Param( -# A dictionary to remove the nulls from. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][Collections.IDictionary] $InputObject -) -Process -{ - $nullvaluekeys = $InputObject.Keys |Where-Object {$InputObject[$_] -eq $null} - $nullvaluekeys |ForEach-Object {$InputObject.Remove($_)} - return $InputObject -} diff --git a/Repair-MarkdownHeaders.ps1 b/Repair-MarkdownHeaders.ps1 deleted file mode 100644 index 0d32e3fe..00000000 --- a/Repair-MarkdownHeaders.ps1 +++ /dev/null @@ -1,121 +0,0 @@ -<# -.SYNOPSIS -Updates markdown content to replace level 1 & 2 ATX headers to Setext headers. - -.FUNCTIONALITY -Markdown - -.INPUTS -System.String containing markdown code to update. - -.OUTPUTS -System.String containing updated markdown code. - -.LINK -https://webcoder.info/markdown-headers.html - -.EXAMPLE -Repair-MarkdownHeaders.ps1 -Path readme.md -Style SetextWithAtx - -Updates the file with the specified header style. - -.EXAMPLE -$content = $markdown |Repair-MarkdownHeaders.ps1 -Style Atx - -Returns markdown code that uses ATX headers. -#> - -#Requires -Version 7 -[CmdletBinding()][OutputType([string],ParameterSetName='InputObject')] Param( -# Markdown file to update. -[Parameter(ParameterSetName='Path',Position=0,Mandatory=$true)][string] $Path, -# The text encoding to use when converting text to binary data. -[Parameter(ParameterSetName='Path',Position=1)] -[ValidateSet('ascii','utf16','utf16BE','utf32','utf32BE','utf7','utf8')] -[string] $Encoding = 'utf8', -# Markdown content to update. -[Parameter(ParameterSetName='InputObject',ValueFromPipeline=$true)][string] $InputObject, -# The style of headers to use. -[ValidateSet('Atx', 'AtxClosed', 'SetextWithAtx')] -[string] $Style = 'SetextWithAtx', -# The line endings to use. -[ValidatePattern('\A\r?\n\z')][string] $NewLine = [Environment]::NewLine -) -Begin -{ - filter Repair-Atx - { - [CmdletBinding()] Param( - [Parameter(ValueFromPipeline=$true)][string] $InputObject - ) - $md = ConvertFrom-Markdown -InputObject $InputObject - $value = switch($md.Tokens) - { - {$_.Span.Length -eq 0} {} - {$_ -is [Markdig.Syntax.HeadingBlock] -and $_.IsSetext} - { - $headertext = $InputObject.Substring($_.Span.Start, $_.Span.Length).TrimEnd(($_.Level -eq 1 ? '=' : '-')).Trim() - "$(New-Object string '#',$_.Level) $headertext" - } - default {$InputObject.Substring($_.Span.Start, $_.Span.Length).Trim()} - } - return $value -join "$NewLine$NewLine" - } - - filter Repair-AtxClosed - { - [CmdletBinding()] Param( - [Parameter(ValueFromPipeline=$true)][string] $InputObject - ) - $md = ConvertFrom-Markdown -InputObject $InputObject - $value = switch($md.Tokens) - { - {$_.Span.Length -eq 0} {} - {$_ -is [Markdig.Syntax.HeadingBlock] -and $_.IsSetext} - { - $headertext = $InputObject.Substring($_.Span.Start, $_.Span.Length).TrimEnd(($_.Level -eq 1 ? '=' : '-')).Trim() - $atx = (New-Object string '#',$_.Level) - "$atx $headertext $atx" - } - {$_ -is [Markdig.Syntax.HeadingBlock] -and !$_.IsSetext} - { - $headertext = $InputObject.Substring($_.Span.Start, $_.Span.Length).TrimStart($_.HeaderChar).Trim() - $atx = (New-Object string '#',$_.Level) - "$atx $headertext $atx" - } - default {$InputObject.Substring($_.Span.Start, $_.Span.Length).Trim()} - } - return $value -join "$NewLine$NewLine" - } - - filter Repair-SetextWithAtx - { - [CmdletBinding()] Param( - [Parameter(ValueFromPipeline=$true)][string] $InputObject - ) - $md = ConvertFrom-Markdown -InputObject $InputObject - $value = switch($md.Tokens) - { - {$_.Span.Length -eq 0} {} - {$_ -is [Markdig.Syntax.HeadingBlock] -and $_.Level -lt 3 -and !$_.IsSetext} - { - $headertext = $InputObject.Substring($_.Span.Start, $_.Span.Length).TrimStart($_.HeaderChar).Trim() - "$headertext$NewLine$(New-Object string ($_.Level -eq 1 ? '=' : '-'),$headertext.Length)" - } - default {$InputObject.Substring($_.Span.Start, $_.Span.Length).Trim()} - } - return $value -join "$NewLine$NewLine" - } -} -Process -{ - switch($PSCmdlet.ParameterSetName) - { - InputObject {return $InputObject |& "Repair-$Style"} - Path - { - $content = Get-Content $Path -Raw - $content |& "Repair-$Style" |Out-File $Path $Encoding - } - } -} diff --git a/Save-PodcastEpisodes.ps1 b/Save-PodcastEpisodes.ps1 index 4fc9a0d1..9527ed1e 100644 --- a/Save-PodcastEpisodes.ps1 +++ b/Save-PodcastEpisodes.ps1 @@ -11,7 +11,6 @@ Save-PodcastEpisodes.ps1 https://www.youlooknicetoday.com/rss -UseTitle Downloads podcast episodes to the current directory. #> -#Requires -Version 7 [CmdletBinding()] Param( # The URL of the podcast feed. [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][Alias('Url')][uri] $Uri, diff --git a/Save-WebRequest.ps1 b/Save-WebRequest.ps1 index bcd68e7b..703b9539 100644 --- a/Save-WebRequest.ps1 +++ b/Save-WebRequest.ps1 @@ -36,7 +36,6 @@ Saves f1040.pdf (or else a filename specified in the Content-Disposition header) #> using namespace System.Net.Mime -#Requires -Version 7 [CmdletBinding()][OutputType([void])] Param( # The URL to download. [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] diff --git a/Select-CapturesFromMatches.ps1 b/Select-CapturesFromMatches.ps1 deleted file mode 100644 index a8ed0d8e..00000000 --- a/Select-CapturesFromMatches.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -<# -.SYNOPSIS -Selects named capture group values as note properties from Select-String MatchInfo objects. - -.INPUTS -Microsoft.PowerShell.Commands.MatchInfo, output from Select-String that used a pattern -with named capture groups. - -.OUTPUTS -System.Management.Automation.PSObject containing selected capture group values. - -.FUNCTIONALITY -Search and replace - -.EXAMPLE -Select-String '^(?.*?\b)\s*(?\S+@\S+)$' addrbook.txt |Select-CapturesFromMatches.ps1 - -Name Email ----- ----- -Arthur Dent adent@example.org -Tricia McMillan trillian@example.com -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([psobject])] Param( -# The MatchInfo output from Select-String to select named capture group values from. -[Parameter(Position=0,ValueFromRemainingArguments=$true,ValueFromPipeline=$true)] -[Alias('InputObject')][Microsoft.PowerShell.Commands.MatchInfo] $MatchInfo, -# Return the capture group values without building objects. -[switch] $ValuesOnly -) -Process -{ - $value = @{} - if($ValuesOnly) - { - return $MatchInfo.Matches.Groups.Value |Select-Object -Skip 1 - } - elseif($PSVersionTable.PSEdition -eq 'Desktop' -and $PSVersionTable.CLRVersion -lt [version]4.7) - { # old CLR is really tedious to get group names - [regex]$regex = $MatchInfo.Pattern - $regex.GetGroupNames() | - Where-Object {$_ -Match '\D'} | - ForEach-Object {$value.Add($_,$MatchInfo.Matches.Groups[$regex.GroupNumberFromName($_)].Value)} - } - else - { - $MatchInfo.Matches.Groups | - Where-Object Name -Match '\D' | - ForEach-Object {$value.Add($_.Name,$_.Value)} - } - return [pscustomobject]$value -} diff --git a/Select-ScriptCommands.ps1 b/Select-ScriptCommands.ps1 deleted file mode 100644 index 68b014be..00000000 --- a/Select-ScriptCommands.ps1 +++ /dev/null @@ -1,61 +0,0 @@ -<# -.SYNOPSIS -Returns the commands used by the specified script. - -.FUNCTIONALITY -Scripts - -.INPUTS -System.String containing the path to a script file to parse. - -.OUTPUTS -System.Management.Automation.CommandInfo for each command parsed from the file. - -.LINK -https://learn.microsoft.com/dotnet/api/system.management.automation.language.parser.parsefile - -.LINK -Get-Command - -.EXAMPLE -Select-ScriptCommands.ps1 Select-ScriptCommands.ps1 - -CommandType Name Version Source ------------ ---- ------- ------ -Cmdlet Out-Null 7.5.0.500 Microsoft.PowerShell.Core -Cmdlet Where-Object 7.5.0.500 Microsoft.PowerShell.Core -Cmdlet Select-Object 7.0.0.0 Microsoft.PowerShell.Utility -Cmdlet Get-Command 7.5.0.500 Microsoft.PowerShell.Core -Cmdlet Resolve-Path 7.0.0.0 Microsoft.PowerShell.Management -Filter Get-ScriptCommands -#> - -#Requires -Version 7 -[CmdletBinding()][OutputType([System.Management.Automation.CommandInfo])] Param( -# A script file path (wildcards are accepted). -[Parameter(Position=0,ValueFromPipeline=$true)][string] $Path, -# Specifies the types of commands that this cmdlet gets. -[Management.Automation.CommandTypes] $CommandType -) -Begin -{ - $Script:parseErrors = [Management.Automation.Language.ParseError[]]@() - $Script:tokens = [Management.Automation.Language.Token[]]@() - filter Get-ScriptCommands - { - [CmdletBinding()] Param( - [Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)][string] $Path - ) - [Management.Automation.Language.Parser]::ParseFile($Path, - [ref]$Script:tokens, [ref]$Script:parseErrors) |Out-Null - $commands = $Script:tokens | - Where-Object TokenFlags -eq 'CommandName' | - Select-Object -Unique -ExpandProperty Value | - Get-Command -ErrorAction Ignore - return !$CommandType ? $commands : ($commands |Where-Object CommandType -eq $CommandType) - } -} -Process -{ - Resolve-Path $Path |Get-ScriptCommands -} diff --git a/Set-RegexReplace.ps1 b/Set-RegexReplace.ps1 deleted file mode 100644 index 149d3270..00000000 --- a/Set-RegexReplace.ps1 +++ /dev/null @@ -1,101 +0,0 @@ -<# -.SYNOPSIS -Updates text found with Select-String, using a regular expression replacement template. - -.INPUTS -Microsoft.PowerShell.Commands.MatchInfo containing a regex match than will be replaced. - -.OUTPUTS -System.String of the input string if the Select-String's input was a string instead of a file. -(File changes will be saved back to the file.) - -.FUNCTIONALITY -Search and replace - -.LINK -https://docs.microsoft.com/dotnet/standard/base-types/substitutions-in-regular-expressions - -.LINK -https://github.com/brianary/Detextive/ - -.EXAMPLE -Select-String '()' README.md |Set-RegexReplace.ps1 "`$1 $(Get-Date) `$2" - -Updates the generated date in README.md. - -.EXAMPLE -Get-Item README.md |select Name,Length |ConvertTo-Html -Fragment |Out-String |Select-String '(\d+)' |Set-RegexReplace.ps1 '$1 align="right"$2' - - - - - -
NameLength
README.md21099
-#> - -#Requires -Version 3 -#Requires -Modules Detextive -[CmdletBinding()] Param( -<# -A regular expression replacement string. - -* $$ is a literal $ -* $_ is the entire input string. -* $` is the string before the match. -* $& is the entire matching string. -* $' is the string after the match. -* $1 is the first matching group. -* $n (where n is a number) is the nth matching group. -* $name is the group named "name". -* $+ is the last matching group. -#> -[Parameter(Position=0,Mandatory=$true)][string] $Replacement, -# The output from Select-String. -[Parameter(ValueFromPipeline=$true)][Microsoft.PowerShell.Commands.MatchInfo] $InputObject -) -Begin -{ - Write-Verbose 'Begin' - $files = @{} -} -Process -{ - Write-Verbose 'Process' - if($InputObject.Path -eq 'InputStream') - { - Write-Verbose "Line: $($InputObject.Line)" - if($null -eq $InputObject.Context) - { - return ($InputObject.Line -replace $InputObject.Pattern,$Replacement) - } - else - { - return ($InputObject.Context.PreContext, - ($InputObject.Line -replace $InputObject.Pattern,$Replacement), - $InputObject.Context.PostContext |Out-String) - } - } - elseif(!$files.ContainsKey($InputObject.Path)) - { - Write-Verbose "Adding '$($InputObject.Path)'" - $files.Add($InputObject.Path,$InputObject.Pattern) - } - else - { - Write-Verbose "Already added '$($InputObject.Path)'" - } -} -End -{ - Write-Verbose 'End' - $i,$max = 0,($files.Count/100) - Write-Verbose "Updating $($files.Count) files" - foreach($file in $files.Keys) - { - $pattern = $files[$file] - Write-Progress 'Performing file replace' "$pattern" -curr $file -percent ($i++/$max) - Write-Verbose "$($InputObject.Path) : -replace '$($InputObject.Pattern)','$Replacement'" - (Get-Content $file -Raw) -replace $pattern,$Replacement |Out-File $file (Get-FileEncoding $file) - } - Write-Progress 'Performing file replace' 'Complete' -Completed -} diff --git a/Show-OpenApiInfo.ps1 b/Show-OpenApiInfo.ps1 index 98deb1b2..1e06e590 100644 --- a/Show-OpenApiInfo.ps1 +++ b/Show-OpenApiInfo.ps1 @@ -9,7 +9,7 @@ Json https://www.openapis.org/ .EXAMPLE -Show-OpenApiInfo.ps1 .\test\data\sample-openapi.json +Show-OpenApiInfo .\test\data\sample-openapi.json Sample REST API v1.0.0 An example OpenAPI definition. .\test\data\sample-openapi.json openapi v3.0.3 @@ -19,13 +19,12 @@ POST /users Creates a new user. Adds a user account. #> -#Requires -Version 7 [CmdletBinding()] Param( [Parameter(Position=0,Mandatory=$true,ValueFromPipelineByPropertyName=$true)][Alias('FullName')][string] $Path ) Process { - $api = Get-OpenApiInfo.ps1 $Path + $api = Get-OpenApiInfo $Path Write-Host $api.Title -ForegroundColor Green -NoNewline Write-Host " $($api.Version) " -ForegroundColor DarkCyan -NoNewline if($api.Description) {Write-Host $api.Description -ForegroundColor DarkGreen} diff --git a/Show-PSDriveUsage.ps1 b/Show-PSDriveUsage.ps1 deleted file mode 100644 index f24564f5..00000000 --- a/Show-PSDriveUsage.ps1 +++ /dev/null @@ -1,84 +0,0 @@ -<# -.SYNOPSIS -Displays drive usage graphically, and with a human-readable summary. - -.FUNCTIONALITY -Files - -.INPUTS -An object with a Name property that corresponds to a drive name. - -.LINK -Import-CharConstants.ps1 - -.LINK -Format-ByteUnits.ps1 - -.LINK -Write-Info.ps1 - -.EXAMPLE -Show-PSDriveUsage.ps1 C -AsAscii - -#################_______________________________________________________________________ -C:\ Windows [NTFS] 953GB = 762GB (79%) free + 191GB (20%) used - -.EXAMPLE -Show-PSDriveUsage.ps1 /home -AsAscii -###################_____________________________________________________________________ -/home [ext3] 4TB = 3TB (73%) free + 792GB (21%) used -#> - -#Requires -Version 7 -[CmdletBinding()] Param( -# A drive name to display the usage for. All ready fixed drives are displayed if none is specified. -[Parameter(Position=0,ValueFromPipelineByPropertyName=$true,ValueFromRemainingArguments=$true)][string[]] $Name = @(), -# Display the graph as ASCII. -[switch] $AsAscii -) -Begin -{ - if($AsAscii) {$usedchar, $freechar = '#', '_'} - else {Import-CharConstants.ps1 'full block' 'light shade'; $usedchar, $freechar = ${full block}, ${light shade}} - filter Show-DriveUsage - { - [CmdletBinding()] Param( - [Parameter(ValueFromPipelineByPropertyName=$true)][string] $Name, - [Parameter(ValueFromPipelineByPropertyName=$true)][string] $VolumeLabel, - [Parameter(ValueFromPipelineByPropertyName=$true)][string] $DriveFormat, - [Parameter(ValueFromPipelineByPropertyName=$true)][IO.DirectoryInfo] $RootDirectory, - [Parameter(ValueFromPipelineByPropertyName=$true)][long] $TotalSize, - [Parameter(ValueFromPipelineByPropertyName=$true)][long] $TotalFreeSpace, - [Parameter(ValueFromPipelineByPropertyName=$true)][long] $AvailableFreeSpace - ) - $blocksize, $usedspace = [long]::DivRem($TotalSize, [Console]::WindowWidth).Item1, ($TotalSize - $TotalFreeSpace) - $usedpercent, $freepercent, $size, $free, $used, $usedgraph, $freegraph = - ([long]::DivRem(100*$usedspace, $TotalSize).Item1), - ([long]::DivRem(100*$AvailableFreeSpace, $TotalSize).Item1), - ($TotalSize |Format-ByteUnits.ps1 -Precision 0), - ($AvailableFreeSpace |Format-ByteUnits.ps1 -Precision 0), - ($usedspace |Format-ByteUnits.ps1 -Precision 0), - (New-Object string ($usedchar, [long]::DivRem($usedspace, $blocksize).Item1)), - (New-Object string ($freechar, [long]::DivRem($AvailableFreeSpace, $blocksize).Item1)) - $color = switch($freepercent) - { - {$_ -lt 10} {'Red'} - {$_ -lt 20} {'Yellow'} - default {'Green'} - } - Write-Info.ps1 $usedgraph -fg Cyan -NoNewLine - Write-Info.ps1 $freegraph -fg DarkCyan - $fqdn = $Name -ne $VolumeLabel ? "$Name $VolumeLabel [$DriveFormat]" : "$Name [$DriveFormat]" - Write-Info.ps1 "$fqdn $size = $free ($freepercent%) free + $used ($usedpercent%) used" -fg $color - } -} -Process -{ - if($Name) {$Name |ForEach-Object {[IO.DriveInfo] $_} |Show-DriveUsage} - else - { - [IO.DriveInfo]::GetDrives() | - Where-Object {$_.DriveType -eq 'Fixed' -and $_.IsReady -and $_.TotalSize -gt 0} | - Show-DriveUsage - } -} diff --git a/Show-Status.ps1 b/Show-Status.ps1 deleted file mode 100644 index aaec97c0..00000000 --- a/Show-Status.ps1 +++ /dev/null @@ -1,186 +0,0 @@ -<# -.SYNOPSIS -Displays requested system status values using powerline font characters. - -.LINK -https://www.nerdfonts.com/cheat-sheet - -.LINK -Get-Unicode.ps1 - -.FUNCTIONALITY -System and updates - -.EXAMPLE -Show-Status.ps1 UserName HomeDirectory -Separator ' * ' - -( MyUserName * C:\Users\MyUserName ) -(but using powerline graphics) -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([void])] Param( -# The format to serialize the date as. -[Parameter(Position=0,Mandatory=$true,ValueFromRemainingArguments=$true)] -[ValidateSet('AdminIndicator','ComputerName','DotNetVersion','DriveUsage','ExplorerUser','GitUser','HomeDirectory', -'OSVersion','PowerShellCommand','PowerShellVersion','Updates','Uptime','UserName')] -[string[]] $Status, -# The separator to use between formatted dates. -[string] $Separator = " $(Get-Unicode.ps1 0x2022) ", -# The foreground console color to use. -[consolecolor] $ForegroundColor = $host.UI.RawUI.BackgroundColor, -# The background console color to use. -[consolecolor] $BackgroundColor = $host.UI.RawUI.ForegroundColor, -# Forces rerunning the command to update the cache. -[switch] $Force -) -Begin -{ - Import-CharConstants.ps1 -Alias @{ - USER = 'BUST IN SILHOUETTE' - HOUSE = 'HOUSE BUILDING' - COMPUTER = 'PERSONAL COMPUTER' - REDCIRCLE = 'LARGE RED CIRCLE' - BLUECIRCLE = 'LARGE BLUE CIRCLE' - POWER = 'POWER SYMBOL' - HARDDISK = 'HARD DISK' - OVERLAP = 'OVERLAP' - REDX = 'CROSS MARK' - OK = 'SQUARED OK' - WAIT = 'HOURGLASS WITH FLOWING SAND' - 'UP!' = 'SQUARED UP WITH EXCLAMATION MARK' - } -AsEmoji - if(Test-WindowsTerminal.ps1) - { - Set-Variable -Name LEFTEND -Value (Get-Unicode.ps1 0xE0B6) -Scope Script -Option Constant -EA Ignore ` - -Description 'nf-ple-left_half_circle_thick (wt)' - Set-Variable -Name RIGHTEND -Value (Get-Unicode.ps1 0xE0B4) -Scope Script -Option Constant -EA Ignore ` - -Description 'nf-ple-right_half_circle_thick (wt)' - Set-Variable -Name DOTNET -Value (Get-Unicode.ps1 0xE77F) -Scope Script -Option Constant -EA Ignore ` - -Description 'nf-dev-dotnet (wt)' - Set-Variable -Name GIT -Value (Get-Unicode.ps1 0xF1D2) -Scope Script -Option Constant -EA Ignore ` - -Description 'nf-fa-git_square (wt)' - Set-Variable -Name WINDOWS -Value (Get-Unicode.ps1 0xF17A) -Scope Script -Option Constant -EA Ignore ` - -Description 'nf-fa-windows (wt)' - Set-Variable -Name LINUX -Value (Get-Unicode.ps1 0xF17C) -Scope Script -Option Constant -EA Ignore ` - -Description 'nf-fa-linux (wt)' - Set-Variable -Name MAC -Value (Get-Unicode.ps1 0xF179) -Scope Script -Option Constant -EA Ignore ` - -Description 'nf-fa-apple (wt)' - Set-Variable -Name POWERSHELL -Value (Get-Unicode.ps1 0xE86C) -Scope Script -Option Constant -EA Ignore ` - -Description 'nf-dev-powershell (wt)' - } - else - { - Import-CharConstants.ps1 -Alias @{ - LEFTEND = 'BLACK MEDIUM LEFT-POINTING TRIANGLE' - RIGHTEND = 'BLACK MEDIUM RIGHT-POINTING TRIANGLE' - DOTNET = 'SINE WAVE' - GIT = 'CIRCLED LATIN SMALL LETTER G' - WINDOWS = 'WINDOW' - LINUX = 'PENGUIN' - MAC = 'RED APPLE' - POWERSHELL = 'SUPERHERO' - } -AsEmoji - } - - function Get-WinGetTest - { - if(Get-Module Microsoft.WinGet.Client -ListAvailable) - {{ - if(Get-WinGetPackage | - Where-Object IsUpdateAvailable | - Select-Object -First 1) {'winget'} - }} - elseif(Get-Command winget -CommandType Application -ErrorAction Ignore) - {{ - if(winget list --upgrade-available --disable-interactivity | - Select-String '^\d+ upgrades? available.$' | - Select-Object -First 1) {'winget'} - }} - else - {{$null}} - } - - function Get-ChocoTest - {{ - if(Get-Command choco -CommandType Application -ErrorAction Ignore) - { - if(choco outdated -r |Select-Object -First 1) {'choco'} - } - }} - - function Get-NpmTest - {{ - if(Get-Command npm -CommandType Application -ErrorAction Ignore) - { - if(npm outdated -g -parseable |Select-Object -First 1) {'npm'} - } - }} - - function Get-PSModulesTest - {{ - if(Get-OutdatedModules.ps1 |Select-Object -First 1) {'psmodules'} - }} - - filter Format-Status - { - [CmdletBinding()][OutputType([string])] Param( - [Parameter(ValueFromPipeline=$true)][string] $Status - ) - switch($Status) - { - AdminIndicator { (Test-Administrator.ps1) ? $REDCIRCLE : $BLUECIRCLE } - ComputerName {"$COMPUTER $([Environment]::MachineName)"} - DotNetVersion {"$DOTNET .NET $([Environment]::Version)"} - DriveUsage - { - $HARDDISK + ' ' + ((Get-PSDrive -PSProvider FileSystem |Where-Object {$null -ne $_.Free} | - ForEach-Object {"$(Get-Unicode.ps1 (0x1F311 + [math]::Round((5*$_.Used)/($_.Used+$_.Free)) ))$($_.Name)"}) -join ' ') - } - ExplorerUser - { - $euser = New-Object Management.ManagementObjectSearcher ` - "select * from Win32_Process where ProcessID = $((Get-Process explorer)[0].Id)" | - ForEach-Object {$_.Get()} | - ForEach-Object {$_.GetOwner()} | - Select-Object -ExpandProperty User - "$OVERLAP $euser" - } - GitUser {(git config user.name) ? - "$GIT $(git config user.name) <$(git config user.email)>" : - "$GIT $REDX"} - HomeDirectory {"$HOUSE $HOME"} - OSVersion - { - if($IsWindows) {"$WINDOWS $([Environment]::OSVersion.VersionString)"} - elseif($IsLinux) {"$LINUX $([Environment]::OSVersion.VersionString) $($PSVersionTable.OS)"} - elseif($IsMacOS) {"$MAC $([Environment]::OSVersion.VersionString) $($PSVersionTable.OS)"} - } - PowerShellCommand {"$POWERSHELL $([Environment]::ProcessPath) $([Environment]::CommandLine)"} - PowerShellVersion {"$POWERSHELL PS $($PSVersionTable.PSVersion) $($PSVersionTable.PSEdition)"} - Updates - { - $updates = @( - (Invoke-CachedCommand.ps1 (Get-ChocoTest) -ExpiresAfter 20:00 -Force:$Force) - (Invoke-CachedCommand.ps1 (Get-WingetTest) -ExpiresAfter 20:00 -Force:$Force) - (Invoke-CachedCommand.ps1 (Get-NpmTest) -ExpiresAfter 20:00 -Force:$Force) - (Invoke-CachedCommand.ps1 (Get-PSModulesTest) -ExpiresAfter 20:00 -Force:$Force) - ) |Where-Object {$_} - $updates ? "${UP!} $updates" : $OK - } - Uptime {"$POWER$(Get-Uptime)"} - UserName {"$USER $env:USERNAME"} - default {$_} - } - } -} -Process -{ - Write-Info.ps1 $LEFTEND -ForegroundColor $BackgroundColor -NoNewLine - Write-Info.ps1 " $WAIT " -ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor -NoNewline - Write-Info.ps1 "$RIGHTEND`r$LEFTEND" -ForegroundColor $BackgroundColor -NoNewLine - Write-Info.ps1 (($Status |Format-Status) -join $Separator) ` - -ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor -NoNewline - Write-Info.ps1 ' ' -ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor -NoNewline - Write-Info.ps1 $RIGHTEND -ForegroundColor $BackgroundColor -} diff --git a/Show-Time.ps1 b/Show-Time.ps1 deleted file mode 100644 index 739307cd..00000000 --- a/Show-Time.ps1 +++ /dev/null @@ -1,48 +0,0 @@ -<# -.SYNOPSIS -Displays a formatted date using powerline font characters. - -.LINK -Get-Unicode.ps1 - -.LINK -Format-Date.ps1 - -.LINK -Get-Date - -.FUNCTIONALITY -Date and time - -.EXAMPLE -Show-Time.ps1 Iso8601Z Iso8601WeekDate Iso8601OrdinalDate -Separator ' * ' - -( 2020-12-08T03:59:39Z * 2020-W50-1 * 2020-342 ) -(but using powerline graphics) -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([void])] Param( -# The format to serialize the date as. -[Parameter(Position=0,Mandatory=$true,ValueFromRemainingArguments=$true)] -[ValidateSet('FrenchRepublicanDateTime','Iso8601','Iso8601Date','Iso8601OrdinalDate', -'Iso8601Week','Iso8601WeekDate','Iso8601Z','LocalLongDate','LocalLongDateTime','Rfc1123','Rfc1123Gmt')] -[string[]] $Format, -# The date/time value to format. -[Parameter(ValueFromPipeline=$true)][datetime] $Date = (Get-Date), -# The separator to use between formatted dates. -[string] $Separator = " $(Get-Unicode.ps1 0x2022) ", -# The foreground console color to use. -[consolecolor] $ForegroundColor = $host.UI.RawUI.BackgroundColor, -# The background console color to use. -[consolecolor] $BackgroundColor = $host.UI.RawUI.ForegroundColor -) -Process -{ - Write-Info.ps1 (Get-Unicode.ps1 0xE0B6) -ForegroundColor $BackgroundColor -NoNewline - Write-Info.ps1 ' ' -ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor -NoNewline - Write-Info.ps1 (($Format |ForEach-Object {Format-Date.ps1 $_ -Date $Date}) -join $Separator) ` - -ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor -NoNewline - Write-Info.ps1 ' ' -ForegroundColor $ForegroundColor -BackgroundColor $BackgroundColor -NoNewline - Write-Info.ps1 (Get-Unicode.ps1 0xE0B4) -fore $BackgroundColor -} diff --git a/Split-Keys.ps1 b/Split-Keys.ps1 deleted file mode 100644 index 169a0516..00000000 --- a/Split-Keys.ps1 +++ /dev/null @@ -1,64 +0,0 @@ -<# -.SYNOPSIS -Clones a dictionary keeping only the specified keys. - -.NOTES -Only string keys are supported. - -.INPUTS -System.Collections.IDictionary, the source dictionary to select key-value pairs from by key. - -.OUTPUTS -System.Collections.Specialized.OrderedDictionary, the dictionary matching key-value pairs are copied to. - -.FUNCTIONALITY -Dictionary - -.LINK -https://msdn.microsoft.com/library/System.Collections.IDictionary.aspx - -.EXAMPLE -@{ A = 1; B = 2; C = 3 } |Split-Keys.ps1 B C D - -Name Value ----- ----- -B 2 -C 3 - -.EXAMPLE -$PSBoundParameters |Split-Keys.ps1 From To Cc Bcc Subject -SkipNullValues |Send-MailMessage - -Sends an email using selected params declared by the calling script with values. -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([Collections.IDictionary])] Param( -# List of keys to include in the new dictionary. -[Parameter(Position=0,ValueFromRemainingArguments=$true)][string[]] $Keys, -# The source dictionary to copy key-value pairs from. -[Parameter(Mandatory=$true,ValueFromPipeline=$true)][Alias('Hashtable')][Collections.IDictionary] $Dictionary, -# When present, indicates that key-value pairs with a null value should not be included. -[Alias('NoNulls')][switch] $SkipNullValues -) -Begin -{ - $getKeys = [Collections.IDictionary].GetProperty('Keys').GetGetMethod() - function Get-Key($dict) { return $getKeys.Invoke($dict, @()) } - - $removeKey = [Collections.IDictionary].GetMethod('Remove') - function Remove-Key($dict, $key) { [void]$removeKey.Invoke($dict, @($key)) } -} -Process -{ - if($null -eq $Dictionary) {return @{}} - $selected = $Dictionary.Clone() - foreach($key in Get-Key $Dictionary) - { - if($key -in $Keys) {continue} - $value = $Dictionary[$key] - if($null -eq $value) {if(!$SkipNullValues) {continue}} - elseif($value -is [switch]) {if($value.IsPresent) {continue}} - Remove-Key $selected $key - } - return $selected -} diff --git a/Split-Uri.ps1 b/Split-Uri.ps1 deleted file mode 100644 index 2fd3fd05..00000000 --- a/Split-Uri.ps1 +++ /dev/null @@ -1,179 +0,0 @@ -<# -.SYNOPSIS -Splits a URI into component parts. - -.INPUTS -System.Uri containing a URI to extract a part of. - -.OUTPUTS -System.String for various URI parts that are extracted (usually), or -System.Boolean for various tests of the URI parts, or -System.Int32 to identify the port number if requsted, or -System.UriHostNameType to identify the type of hostname if requested, or -System.Collections.Hashtable containing the querystring name and value pairs if requested, or -System.Management.Automation.PSCredential containing the username and password of the URI if requested. - -.FUNCTIONALITY -Data formats - -.EXAMPLE -Split-Uri.ps1 https://webcoder.info/wps-to-psc.html -Leaf - -wps-to-psc.html - -.EXAMPLE -Split-Uri.ps1 https://webcoder.info/wps-to-psc.html -IsAbsoluteUri - -True - -.EXAMPLE -Split-Uri.ps1 https://webcoder.info/wps-to-psc.html -Authority - -webcoder.info - -.EXAMPLE -Split-Uri.ps1 'http://example.net/q?one=something&one=another%20thing&two=second' -QueryAsDictionary - -Name Value ----- ----- -one {something, another thing} -two second -#> - -#Requires -Version 3 -[OutputType([string],ParameterSetName='AbsolutePath')] -[OutputType([string],ParameterSetName='Authority')] -[OutputType([pscredential],ParameterSetName='Credential')] -[OutputType([string],ParameterSetName='Extension')] -[OutputType([string],ParameterSetName='Filename')] -[OutputType([UriHostNameType],ParameterSetName='HostNameType')] -[OutputType([bool],ParameterSetName='IsAbsoluteUri')] -[OutputType([bool],ParameterSetName='IsDefaultPort')] -[OutputType([bool],ParameterSetName='IsFile')] -[OutputType([bool],ParameterSetName='IsLoopback')] -[OutputType([bool],ParameterSetName='IsUnc')] -[OutputType([string],ParameterSetName='Leaf')] -[OutputType([string],ParameterSetName='LeafBase')] -[OutputType([string],ParameterSetName='ParentPath')] -[OutputType([string],ParameterSetName='ParentUri')] -[OutputType([string],ParameterSetName='HostPart')] -[OutputType([string],ParameterSetName='IdnHost')] -[OutputType([string],ParameterSetName='LocalPath')] -[OutputType([string],ParameterSetName='PathAndQuery')] -[OutputType([int],ParameterSetName='Port')] -[OutputType([string],ParameterSetName='Query')] -[OutputType([hashtable],ParameterSetName='QueryAsDictionary')] -[OutputType([string],ParameterSetName='Scheme')] -[OutputType([string],ParameterSetName='Segment')] -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText','', -Justification='The data source is plaintext. SecureString benefits may be in dispute: ')] -[CmdletBinding()] Param( -# Specifies the URI to split. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] -[Alias('Url','Href','Src')][uri] $Uri, -# Indicates the absolute path of the URI should be returned. -[Parameter(ParameterSetName='AbsolutePath')][switch] $AbsolutePath, -# Indicates the host/IP and port of the URI (as used to define security contexts) should be returned. -[Parameter(ParameterSetName='Authority')][switch] $Authority, -# Indicates the credential of the URI should be returned, if a username and/or password was provided. -[Parameter(ParameterSetName='Credentials')][switch] $Credential, -# Indicates the filename extension of the URI should be returned, if one is available. -[Parameter(ParameterSetName='Extension')][switch] $Extension, -# Indicates the filename of the new URI should be returned, or the default value if one is not available. -# Supports format specifiers, {0} for the current date and time and {1} for a GUID. -[Parameter(ParameterSetName='Filename')][string] $Filename, -# Indicates the type of the hostname of the URI should be returned: Basic, Dns, IPv4, IPv6, Unknown. -[Parameter(ParameterSetName='HostNameType')][switch] $HostNameType, -# Indicates $true should be returned if the URI is absolute, $false otherwise. -[Parameter(ParameterSetName='IsAbsoluteUri')][switch] $IsAbsoluteUri, -# Indicates $true should be returned if the URI specifies a default port, $false otherwise. -[Parameter(ParameterSetName='IsDefaultPort')][switch] $IsDefaultPort, -# Indicates $true should be returned if the URI is a file: URI, $false otherwise. -[Parameter(ParameterSetName='IsFile')][switch] $IsFile, -# Indicates $true should be returned if the URI references the localhost, $false otherwise. -[Parameter(ParameterSetName='IsLoopback')][switch] $IsLoopback, -# Indicates $true should be returned if the URI is a UNC path, $false otherwise. -[Parameter(ParameterSetName='IsUnc')][switch] $IsUnc, -# Indicates the final segment of the URI should be returned. -[Parameter(ParameterSetName='Leaf')][switch] $Leaf, -# Indicates the final segment of the URI should be returned, without any filename extension. -[Parameter(ParameterSetName='LeafBase')][switch] $LeafBase, -# Indicates the path of the URI should be returned, without the final segment. -[Parameter(ParameterSetName='ParentPath')][switch] $ParentPath, -# Indicates the URI should be returned, without the final segment. -[Parameter(ParameterSetName='ParentUri')][switch] $ParentUri, -# Indicates the hostname of the URI should be returned. -[Parameter(ParameterSetName='Hostname')][switch] $Hostname, -# Indicates the IDN hostname of the URI should be returned. -[Parameter(ParameterSetName='IdnHost')][switch] $IdnHost, -# Indicates the OS-localized path of the URI should be returned. -[Parameter(ParameterSetName='LocalPath')][switch] $LocalPath, -# Indicates the absolute path and query of the URI should be returned, separated by '?'. -[Parameter(ParameterSetName='PathAndQuery')][switch] $PathAndQuery, -# Indicates the port number of the URI should be returned. -[Parameter(ParameterSetName='Port')][switch] $Port, -# Indicates the querystring of the URI should be returned, including the leading '?'. -[Parameter(ParameterSetName='Query')][switch] $Query, -# Indicates the querystring of the URI should be returned, as a Hashtable. -[Parameter(ParameterSetName='QueryAsDictionary')][switch] $QueryAsDictionary, -# Indicates the scheme of the URI should be returned (http, &c), without the trailing ':'. -[Parameter(ParameterSetName='Scheme')][switch] $Scheme, -# Indicates the specified segment index of the URI should be returned, if is available. -[Parameter(ParameterSetName='Segment')][int] $Segment -) -Begin -{ - function ConvertFrom-UserInfo - { - [CmdletBinding()][OutputType([pscredential])] Param([string] $UserInfo) - if(!$UserInfo) {return} - $username,$pw = $UserInfo -split ':',2 - $pw = if($pw) {ConvertTo-SecureString ([uri]::UnescapeDataString($pw)) -AsPlainText -Force} else {[securestring]::new()} - return New-Object pscredential ([uri]::UnescapeDataString($username)),$pw - } - function ConvertFrom-QueryString - { - [CmdletBinding()][OutputType([hashtable])] Param([string] $QueryString) - if(!$QueryString) {return @{}} - $values = @{} - foreach($pair in $QueryString.Substring(1) -split '&') - { - $key,$value = $pair -split '=',2 - $key,$value = [uri]::UnescapeDataString($key),[uri]::UnescapeDataString($value) - if(!$values.ContainsKey($key)) {$values.Add($key,$value)} - elseif($values[$key] -isnot [array]) {$values[$key] = @($values[$key],$value)} - else {$values[$key] += $value} - } - return $values - } -} -Process -{ - switch ($PSCmdlet.ParameterSetName) - { - AbsolutePath {return $Uri.AbsolutePath} - Authority {return $Uri.Authority} - Credentials {return ConvertFrom-UserInfo $Uri.UserInfo} - Extension {return Split-Path $Uri.LocalPath -Extension} - Filename {switch -Wildcard ($Uri.Segments[-1]) { '*/' {return $Filename -f (Get-Date),(New-Guid)} default {return $_} }} - HostNameType {return $Uri.HostNameType} - IsAbsoluteUri {return $Uri.IsAbsoluteUri} - IsDefaultPort {return $Uri.IsDefaultPort} - IsFile {return $Uri.IsFile} - IsLoopback {return $Uri.IsLoopback} - IsUnc {return $Uri.IsUnc} - Leaf {return $Uri.Segments[-1]} - LeafBase {return Split-Path ($Uri.Segments[-1]) -LeafBase} - ParentPath {return ($Uri.Segments |Select-Object -SkipLast 1) -join ''} - ParentUri {return New-Object uri $Uri,(($Uri.Segments |Select-Object -SkipLast 1) -join '')} - HostPart {return $Uri.Host} - IdnHost {return $Uri.IdnHost} - LocalPath {return $Uri.LocalPath} - PathAndQuery {return $Uri.PathAndQuery} - Port {return $Uri.Port} - Query {return $Uri.Query} - QueryAsDictionary {return ConvertFrom-QueryString $Uri.Query} - Scheme {return $Uri.Scheme} - Segment {return $Uri.Segments[$Segment]} - } -} diff --git a/Test-DateTime.ps1 b/Test-DateTime.ps1 deleted file mode 100644 index a9d11ef0..00000000 --- a/Test-DateTime.ps1 +++ /dev/null @@ -1,49 +0,0 @@ -<# -.SYNOPSIS -Tests whether the given string can be parsed as a date. - -.INPUTS -System.String containing a possible date to test parse. - -.OUTPUTS -System.Boolean indicating the string is a parseable date. - -.FUNCTIONALITY -Date and time - -.LINK -https://msdn.microsoft.com/library/8kb3ddd4.aspx - -.EXAMPLE -Test-DateTime.ps1 '2017-02-29T11:38:00' - -False - -.EXAMPLE -Test-DateTime.ps1 '2000-2-29T9:33:00' -Format 'yyyy-M-dTH:mm:ss' - -True - -.EXAMPLE -Test-Datetime.ps1 970313 -Format 'yyMMdd' - -True - -.EXAMPLE -Test-DateTime.ps1 '1900-02-29' - -False -#> - -[CmdletBinding()][OutputType([bool])] Param( -# The string to test for datetime parseability. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][string]$Date, -# Precise, known format(s) to use to try parsing the datetime. -[string[]]$Format -) -Process -{ - [ref]$value = [datetime]::MinValue - if(!$Format) {[datetime]::TryParse($Date,$value)} - else {[datetime]::TryParseExact($Date,$Format,[Globalization.CultureInfo]::InvariantCulture,'None',$value)} -} diff --git a/Test-FileTypeMagicNumber.ps1 b/Test-FileTypeMagicNumber.ps1 deleted file mode 100644 index 2f93f6a6..00000000 --- a/Test-FileTypeMagicNumber.ps1 +++ /dev/null @@ -1,209 +0,0 @@ -<# -.SYNOPSIS -Tests for a given common file type by magic number. - -.INPUTS -System.String path of a file to test. - -.OUTPUTS -System.Boolean affirming that the magic number for the specified file type was found. - -.FUNCTIONALITY -Data formats - -.LINK -https://en.wikipedia.org/wiki/List_of_file_signatures - -.LINK -https://blogs.msdn.microsoft.com/sergey_babkins_blog/2015/01/02/powershell-script-blocks-are-not-closures/ - -.LINK -http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 - -.LINK -http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_403 - -.LINK -Test-MagicNumber.ps1 - -.EXAMPLE -Test-FileTypeMagicNumber.ps1 utf8 README.md - -True if a utf-8 signature (or "BOM", byte-order-mark) is found. - -.EXAMPLE -Test-FileTypeMagicNumber.ps1 png avatar.png - -True if avatar.png contains the expected png magic number. -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([bool])] Param( -<# -The file type to test for. - -This is generally the MIME subtype or Unicode text encoding, with some exceptions. - -Several types require the presence of an optional header or prefix for positive identification of a file type, -such as " -[Parameter(Position=0,Mandatory=$true)] -[ValidateSet('7z','aiff','avi','bmp','cab','dataweave','exe','flac','flif','gif','gzip','ico','iso','javaclass', -'jpeg','midi','mkv','mp3','mpeg','msoffice','ogg','pdf','png','postscript','psd','raml','rar','rtf','tar','text', -'tiff','utf16','utf16be','utf32','utf32be','utf8','wasm','wav','webm','webp','wmv','xml','yaml','zip')] -[string] $FileType, -# The file to test. -[Parameter(Position=1,ValueFromPipelineByPropertyName=$true)] -[ValidateScript({Test-Path $_ -Type Leaf})][Alias('FullName')][string] $Path -) -Begin -{ - Write-Verbose "Testing for $FileType magic number" - $readbytes = - if((Get-Command Get-Content).Parameters.Encoding.ParameterType -eq [Text.Encoding]) {@{AsByteStream=$true}} - else {@{Encoding='Byte'}} - [scriptblock]$test = - switch($FileType) - { - text - {{ param($f) - return (Test-MagicNumber.ps1 0xEF,0xBB,0xBF $f) -or # UTF-8 SIG - (Test-MagicNumber.ps1 0xFE,0xFF $f) -or # UTF-16 BOM (big-endian) - (Test-MagicNumber.ps1 0xFF,0xFE $f) -or # UTF-16 BOM (little-endian) - # US-ASCII (POSIX) - ((Test-MagicNumber.ps1 0x0A $f -Offset -1) -and (0 -notin (Get-Content $f @readbytes -Total 1KB))) -or - (!(Get-Content $f @readbytes -Total 1KB |Where-Object {$_ -gt 0x7F -or $_ -eq 0})) - }} - xml - {{ param($f) - return (Test-MagicNumber.ps1 0xEF,0xBB,0xBF,0x3C,0x3F,0x78,0x6D,0x6C $f) -or - (Test-MagicNumber.ps1 0x3C,0x3F,0x78,0x6D,0x6C $f) -or - (Test-MagicNumber.ps1 0xFE,0xFF,0x00,0x3C,0x00,0x3F,0x00,0x78,0x00,0x6D,0x00,0x6C $f) -or - (Test-MagicNumber.ps1 0xFF,0xFE,0x3C,0x00,0x3F,0x00,0x78,0x00,0x6D,0x00,0x6C,0x00 $f) - }} - yaml - {{ param($f) - return (Test-MagicNumber.ps1 0xEF,0xBB,0xBF,0x25,0x59,0x41,0x4D,0x4C,0x20 $f) -or - (Test-MagicNumber.ps1 0x25,0x59,0x41,0x4D,0x4C,0x20 $f) -or - (Test-MagicNumber.ps1 0xFE,0xFF,0x00,0x25,0x00,0x59,0x00,0x41,0x00,0x4D,0x00,0x4C,0x00,0x20 $f) -or - (Test-MagicNumber.ps1 0xFF,0xFE,0x25,0x00,0x59,0x00,0x41,0x00,0x4D,0x00,0x4C,0x00,0x20,0x00 $f) - }} - raml - {{ param($f) - return (Test-MagicNumber.ps1 0xEF,0xBB,0xBF,0x23,0x25,0x52,0x41,0x4D,0x4C,0x20 $f) -or - (Test-MagicNumber.ps1 0x23,0x25,0x52,0x41,0x4D,0x4C,0x20 $f) -or - (Test-MagicNumber.ps1 0xFE,0xFF,0x00,0x23,0x00,0x25,0x00,0x52,0x00,0x41,0x00,0x4D,0x00,0x4C,0x00,0x20 $f) -or - (Test-MagicNumber.ps1 0xFF,0xFE,0x23,0x00,0x25,0x00,0x52,0x00,0x41,0x00,0x4D,0x00,0x4C,0x00,0x20,0x00 $f) - }} - dataweave - {{ param($f) - return (Test-MagicNumber.ps1 0xEF,0xBB,0xBF,0x25,0x64,0x77,0x20 $f) -or - (Test-MagicNumber.ps1 0x25,0x64,0x77,0x20 $f) -or - (Test-MagicNumber.ps1 0xFE,0xFF,0x00,0x25,0x00,0x64,0x00,0x77,0x00,0x20 $f) -or - (Test-MagicNumber.ps1 0xFF,0xFE,0x25,0x00,0x64,0x00,0x77,0x00,0x20,0x00 $f) - }} - gif - {{ param($f) - return (Test-MagicNumber.ps1 0x47,0x49,0x46,0x38,0x39,0x61 $f) -or - (Test-MagicNumber.ps1 0x47,0x49,0x46,0x38,0x37,0x61 $f) - }} - tiff - {{ param($f) - return (Test-MagicNumber.ps1 0x49,0x49,0x2A,0 $f) -or - (Test-MagicNumber.ps1 0x4D,0x4D,0,0x2A $f) - }} - mp3 - {{ param($f) - return (Test-MagicNumber.ps1 0xFF,0xFB $f) -or - (Test-MagicNumber.ps1 0x49,0x44,0x33 $f) - }} - mpeg - {{ param($f) - return (Test-MagicNumber.ps1 0,0,0x01,0xBA $f) -or - (Test-MagicNumber.ps1 0,0,0x01,0xB3 $f) -or - (Test-MagicNumber.ps1 0x47 $f) - }} - rar - {{ param($f) - return (Test-MagicNumber.ps1 0x52,0x61,0x72,0x21,0x1A,0x07,0x01,0 $f) -or - (Test-MagicNumber.ps1 0x52,0x61,0x72,0x21,0x1A,0x07,0 $f) - }} - tar - {{ param($f) - return (Test-MagicNumber.ps1 0x75,0x73,0x74,0x61,0x72,0,0x30,0x30 $f -Offset 0x101) -or - (Test-MagicNumber.ps1 0x75,0x73,0x74,0x61,0x72,0x20,0x20,0 $f -Offset 0x101) - }} - jpeg - {{ param($f) - return (Test-MagicNumber.ps1 0xFF,0xD8 $f) -and - (Test-MagicNumber.ps1 0xFF,0xD9 $f -Offset (-2)) - }} - aiff - {{ param($f) - return (Test-MagicNumber.ps1 0x46,0x4F,0x52,0x4D $f) -and - (Test-MagicNumber.ps1 0x41,0x49,0x46,0x46 $f -Offset 9) - }} - wav - {{ param($f) - return (Test-MagicNumber.ps1 0x52,0x49,0x46,0x46 $f) -and - (Test-MagicNumber.ps1 0x57,0x41,0x56,0x45 $f -Offset 9) - }} - avi - {{ param($f) - return (Test-MagicNumber.ps1 0x52,0x49,0x46,0x46 $f) -and - (Test-MagicNumber.ps1 0x41,0x56,0x49,0x20 $f -Offset 9) - }} - webp - {{ param($f) - return (Test-MagicNumber.ps1 0x52,0x49,0x46,0x46 $f) -and - (Test-MagicNumber.ps1 0x57,0x45,0x42,0x50 $f -Offset 9) - }} - iso - {{ param($f) - foreach($offset in 0x8001,0x8801,0x9001) - {if(Test-MagicNumber.ps1 0x43,0x44,0x30,0x30,0x31 $f -Offset $offset){return $true}} - return $false - }} - default - { - [int]$offset = 0 - [byte[]]$bytes = - switch($FileType) - { - utf8 {0xEF,0xBB,0xBF} - utf16 {0xFF,0xFE} - utf16be {0xFE,0xFF} - utf32 {0xFF,0xFE,0,0} - utf32be {0,0,0xFE,0xFF} - rtf {0x7B,0x5C,0x72,0x74,0x66,0x31} - msoffice {0xD0,0xCF,0x11,0xE0,0xA1,0xB1,0x1A,0xE1} - bmp {0x42,0x4D} - ico {0,0,0x01,0} - png {0x89,0x50,0x4E,0x47,0x0D,0x0A,0x1A,0x0A} - flif {0x46,0x4C,0x49,0x46} - psd {0x38,0x42,0x50,0x53} - postscript {0x25,0x21,0x50,0x53} - pdf {0x25,0x50,0x44,0x46} - midi {0x4D,0x54,0x68,0x64} - ogg {0x4F,0x67,0x67,0x53} - flac {0x66,0x4C,0x61,0x43} - wmv {0x30,0x26,0xB2,0x75,0x8E,0x66,0xCF,0x11,0xA6,0xD9,0x00,0xAA,0x00,0x62,0xCE,0x6C} - mkv {0x46,0x4C,0x49,0x46} - webm {0x46,0x4C,0x49,0x46} - zip {0x50,0x4B} # jar/war, xpi, apk, ODF, OOXML, docx/xslx/pptx/vsdx - 7z {0x37,0x7A,0xBC,0xAF,0x27,0x1C} - cab {0x4D,0x53,0x43,0x46} - gzip {0x1F,0x8B} - wasm {0,0x61,0x73,0x6d} - javaclass {0xCA,0xFE,0xBA,0xBE} - exe {0x4D,0x5A} - default {throw "Unknown file type: $FileType"} - } - {param($f); return (Test-MagicNumber.ps1 $bytes $f -Offset $offset)}.GetNewClosure() - } - } -} -Process {if($Path){&$test $Path}} diff --git a/Test-Interactive.ps1 b/Test-Interactive.ps1 deleted file mode 100644 index a7c7f923..00000000 --- a/Test-Interactive.ps1 +++ /dev/null @@ -1,20 +0,0 @@ -<# -.SYNOPSIS -Determines whether both the user and process are interactive. - -.OUTPUTS -System.Boolean indicating whether the session is interactive. - -.FUNCTIONALITY -PowerShell - -.EXAMPLE -Test-Interactive.ps1 - -True -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([bool])] Param() -[Environment]::UserInteractive -and - !([Environment]::GetCommandLineArgs() |Where-Object {$_ -ilike '-NonI*'}) diff --git a/Test-MagicNumber.ps1 b/Test-MagicNumber.ps1 deleted file mode 100644 index 62c207bc..00000000 --- a/Test-MagicNumber.ps1 +++ /dev/null @@ -1,70 +0,0 @@ -<# -.SYNOPSIS -Tests a file for a "magic number" (identifying sequence of bytes) at a given location. - -.INPUTS -System.String path of a file to read. - -.OUTPUTS -System.Boolean affirming that the bytes provided were found at the position given in the specified file. - -.FUNCTIONALITY -Data formats - -.LINK -https://en.wikipedia.org/wiki/Magic_number_(programming) - -.LINK -Get-Content - -.EXAMPLE -Test-MagicNumber.ps1 0xEF,0xBB,0xBF README.md - -True if a utf-8 signature (or "BOM", byte-order-mark) is found. - -.EXAMPLE -Test-MagicNumber.ps1 0x0D,0x0A README.md -Offset -2 - -True if README.md ends with a Windows line-ending. - -.EXAMPLE -Test-MagicNumber.ps1 0x50,0x4B download123543 - -True if download123543 starts with a PK ZIP magic number ("PK"), and is therefore likely ZIP data. -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([bool])] Param( -# A list of byte values to compare against those read from the file. -[Parameter(Position=0,Mandatory=$true)][byte[]]$Bytes, -# A file to look for the bytes in. -[Parameter(Position=2,ValueFromPipelineByPropertyName=$true)] -[ValidateScript({Test-Path $_ -Type Leaf})][Alias('FullName')][string]$Path, -<# -The number bytes into the file to begin reading the bytes to compare. -Use a negative number to count from the end of the file. -#> -[int] $Offset = 0 -) -Begin -{ - $readbytes = - if((Get-Command Get-Content).Parameters.Encoding.ParameterType -eq [Text.Encoding]) {@{AsByteStream=$true}} - else {@{Encoding='Byte'}} - Write-Verbose "Testing for magic number $(($Bytes |ForEach-Object {$_.ToString("X")}) -join ' ') at $Offset" - $GetBytes = - if(!$Offset) - {{param($f); Get-Content $f @readbytes -TotalCount $Bytes.Count}.GetNewClosure()} - elseif($Offset -gt 0) - {{param($f); Get-Content $f @readbytes -TotalCount ($Offset + $Bytes.Count) |Select-Object -Skip $Offset}.GetNewClosure()} - else - {{param($f); Get-Content $f @readbytes -Tail (-$Offset)}.GetNewClosure()} -} -Process -{ - Write-Verbose "Testing for magic number in $Path" - [byte[]]$data = &$GetBytes $Path - if(!$data -or !$data.Length) {return $false} - for($i = 0; $i -lt $Bytes.Count; $i++){if($data[$i] -ne $Bytes[$i]){return $false}} - return $true -} diff --git a/Test-NewerFile.ps1 b/Test-NewerFile.ps1 deleted file mode 100644 index 179857aa..00000000 --- a/Test-NewerFile.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -<# -.SYNOPSIS -Returns true if the difference file is newer than the reference file. - -.OUTPUTS -System.Boolean indicating the difference file is newer. - -.FUNCTIONALITY -Files -#> - -#requires -version 3 -[CmdletBinding()][OutputType([bool])] Param( -# One of two files to compare. -[Parameter(Position=0)][IO.FileInfo]$ReferenceFile, -# Another of two files to compare. -[Parameter(Position=1)][IO.FileInfo]$DifferenceFile -) - -Write-Verbose "Comparing ReferenceFile: $ReferenceFile & DifferenceFile: $DifferenceFile" -if(!$ReferenceFile -or !$ReferenceFile.Exists) {Write-Verbose 'Reference file does not exist.'; return $DifferenceFile.Exists} -if(!$DifferenceFile -or !$DifferenceFile.Exists) {Write-Verbose 'Difference file does not exist.'; return $false} -if($ReferenceFile.VersionInfo.FileVersionRaw -lt $DifferenceFile.VersionInfo.FileVersionRaw) -{Write-Verbose "Newer file version: $($ReferenceFile.VersionInfo.FileVersionRaw) < $($DifferenceFile.VersionInfo.FileVersionRaw)"; return $true} -elseif($ReferenceFile.VersionInfo.FileVersionRaw -gt $DifferenceFile.VersionInfo.FileVersionRaw) -{Write-Verbose "Older file version: $($ReferenceFile.VersionInfo.FileVersionRaw) > $($DifferenceFile.VersionInfo.FileVersionRaw)"; return $false} -if($ReferenceFile.VersionInfo.ProductVersionRaw -lt $DifferenceFile.VersionInfo.ProductVersionRaw) -{Write-Verbose "Newer product version: $($ReferenceFile.VersionInfo.ProductVersionRaw) < $($DifferenceFile.VersionInfo.ProductVersionRaw)"; return $true} -elseif($ReferenceFile.VersionInfo.ProductVersionRaw -gt $DifferenceFile.VersionInfo.ProductVersionRaw) -{Write-Verbose "Older product version: $($ReferenceFile.VersionInfo.ProductVersionRaw) > $($DifferenceFile.VersionInfo.ProductVersionRaw)"; return $false} -if($ReferenceFile.LinkType -and $DifferenceFile.LinkType) -{ - $targets = [string[]]$ReferenceFile.Target + [string[]]$DifferenceFile.Target - if($targets -and ($targets -icontains $ReferenceFile.FullName -or $target -icontains $DifferenceFile.FullName)) - {Write-Verbose 'Shared hardlink targets.'; return $false} -} -if($ReferenceFile.Length -eq $DifferenceFile.Length) -{ - $readbytes = - if((Get-Command Get-Content).Parameters.Encoding.ParameterType -eq [Text.Encoding]) {@{AsByteStream=$true}} - else {@{Encoding='Byte'}} - if(Get-Command -Verb Get -Noun FileHash) {if((Get-FileHash $ReferenceFile).Hash -eq (Get-FileHash $DifferenceFile).Hash) - {Write-Verbose 'Identical hash values.'; return $false}} - elseif(!(Compare-Object (Get-Content $ReferenceFile @readbytes) (Get-Content $DifferenceFile @readbytes))) - {Write-Verbose 'Identical contents.'; return $false} -} -if($ReferenceFile.LastWriteTimeUtc -lt $DifferenceFile.LastWriteTimeUtc) -{Write-Verbose "Newer date: $($ReferenceFile.LastWriteTimeUtc) < $($DifferenceFile.LastWriteTimeUtc)"; return $true} -Write-Verbose 'Inconclusive.' -return $false diff --git a/Test-USFederalHoliday.ps1 b/Test-USFederalHoliday.ps1 deleted file mode 100644 index 784df22c..00000000 --- a/Test-USFederalHoliday.ps1 +++ /dev/null @@ -1,129 +0,0 @@ -<# -.SYNOPSIS -Returns true if the given date is a U.S. federal holiday. - -.DESCRIPTION -The following holidays are checked: - -* New Year's Day, January 1 (± 1 day, if observed) -* Birthday of Martin Luther King, Jr., Third Monday in January -* Washington's Birthday, Third Monday in February -* Memorial Day, Last Monday in May -* Juneteenth, June 19 (± 1 day, if observed) -* Independence Day, July 4 (± 1 day, if observed) -* Labor Day, First Monday in September -* Columbus Day, Second Monday in October -* Veterans Day, November 11 (±1 day, if observed) -* Thanksgiving Day, Fourth Thursday in November -* Christmas Day, December 25 (±1 day, if observed) - -.NOTES -Thanks to the Uniform Monday Holiday Act, Washington's "Birthday" always falls -*between* Washington's birthdays. He had two, and we still decided to celebrate -a third day. - -https://en.wikipedia.org/wiki/Uniform_Monday_Holiday_Act - -https://en.wikipedia.org/wiki/Washington%27s_Birthday#History - -.INPUTS -System.DateTime values to check. - -.OUTPUTS -System.Boolean indicating whether the date is a holiday. - -.FUNCTIONALITY -Date and time - -.LINK -http://www.federalreserve.gov/aboutthefed/k8.htm - -.EXAMPLE -Test-USFederalHoliday.ps1 2016-11-11 - -Veterans Day - -.EXAMPLE -Test-USFederalHoliday.ps1 2017-02-20 - -Washington's Birthday - -.EXAMPLE -if(Test-USFederalHoliday.ps1 (Get-Date)) { return } - -Returns from a function or script if today is a holiday. -#> - -[CmdletBinding()][OutputType([bool])] Param( -# The date to check. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][datetime] $Date, -# Return the holiday name as a truthy value, rather than true. -[Parameter(HelpMessage='Return the holiday name?')][Alias('ReturnName','ReturnHolidayName')][switch] $AsHolidayName, -# Indicates Saturday holidays are observed on Fridays. -[Parameter(HelpMessage='Are Saturday holidays observed on Friday?')][switch] $SatToFri, -# Indicates Sunday holidays are observed on Mondays. -[Parameter(HelpMessage='Are Sunday holidays observed on Monday?')][switch] $SunToMon -) -Process -{ - $showdate = Get-Date $Date -f D - $MMdd= '{0:MMdd}' -f $Date - $holiday = - switch($MMdd) - { - '0101' {"New Year's Day"} - '0619' {"Juneteenth"} - '0704' {"Independence Day"} - '1111' {"Veteran's Day"} - '1225' {"Christmas Day"} - default - { - switch($Date.DayOfWeek) - { - Monday - { - switch -regex ($MMdd) - { - '^01(?:1[5-9]|2[01])$' {"Birthday of Martin Luther King, Jr."} - '^02(?:1[5-9]|2[01])$' {"Washington's Birthday"} - '^05(?:2[5-9]|3[01])$' {"Memorial Day"} - '^090[1-7]$' {"Labor Day"} - '^10(?:0[89]|1[01-4])$' {"Columbus Day"} - } - if($SunToMon) - { - switch($MMdd) - { - '0102' {"New Year's Day (Observed)"} - '0620' {"Juneteenth (Observed)"} - '0705' {"Independence Day (Observed)"} - '1112' {"Veterans Day (Observed)"} - '1226' {"Christmas Day (Observed)"} - } - } - } - Thursday - { - if($MMdd -match '^112[2-8]$') {"Thanksgiving Day"} - } - Friday - { - if($SatToFri) - { - switch($MMdd) - { - '1231' {"New Year's Day (Observed)"} - '0618' {"Juneteenth (Observed)"} - '0703' {"Independence Day (Observed)"} - '1110' {"Veteran's Day (Observed)"} - '1224' {"Christmas Day (Observed)"} - } - } - } - default {$false} - } - } - } - if($holiday) {Write-Verbose "$showdate is $holiday"} - return [bool]$holiday -} diff --git a/Test-Uri.ps1 b/Test-Uri.ps1 deleted file mode 100644 index a90caa88..00000000 --- a/Test-Uri.ps1 +++ /dev/null @@ -1,36 +0,0 @@ -<# -.SYNOPSIS -Determines whether a string is a valid URI. - -.INPUTS -System.String value to test for a valid URI format. - -.OUTPUTS -System.Boolean indicating that the string can be parsed as a URI. - -.FUNCTIONALITY -Data formats - -.EXAMPLE -Test-Uri.ps1 http://example.org - -True - -.EXAMPLE -Test-Uri.ps1 0 - -False -#> - -#Requires -Version 3 -[CmdletBinding()][OutputType([bool])] Param( -# The string to test. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][AllowEmptyString()][AllowNull()][string] $InputObject, -# What kind of URI to test for: Absolute, Relative, or RelativeOrAbsolute. -[Parameter(Position=1)][UriKind] $UriKind = 'Absolute' -) -Process -{ - if(!$InputObject) {return $false} - return [uri]::TryCreate($InputObject,$UriKind,[ref]$null) -} diff --git a/Trace-WebRequest.ps1 b/Trace-WebRequest.ps1 index 771ae4bd..338f4fb3 100644 --- a/Trace-WebRequest.ps1 +++ b/Trace-WebRequest.ps1 @@ -1,152 +1,151 @@ -<# -.SYNOPSIS -Provides details about a retrieving a URI. - -.NOTES -TODO: Add support for other Invoke-WebRequest parameters. - -.INPUTS -System.Uri to retrieve. - -.FUNCTIONALITY -HTTP - -.LINK -Import-CharConstants.ps1 - -.LINK -Write-Info.ps1 - -.LINK -Import-Variables.ps1 - -.EXAMPLE -Trace-WebRequest.ps1 g.co/p3phelp -SkipHeaders -SkipContent - -g.co is CN=*.google.com from CN=WR2, O=Google Trust Services, C=US -Valid 05/12/2025 01:42:58 to 08/04/2025 01:42:57 -GET https://g.co/p3phelp -HTTP/1.1 302 Found -Following redirect to https://support.google.com/accounts/answer/151657?hl=en -support.google.com is CN=*.google.com from CN=WR2, O=Google Trust Services, C=US -Valid 05/12/2025 01:42:58 to 08/04/2025 01:42:57 -GET https://support.google.com/accounts/answer/151657?hl=en -HTTP/1.1 301 MovedPermanently -Following redirect to https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638845176026805186-2907418293&rd=1 -GET https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638845176026805186-2907418293&rd=1 -HTTP/1.1 301 MovedPermanently -Following redirect to https://support.google.com/accounts/?hl=en&visit_id=638845176026805186-2907418293&rd=2&topic=3382252 -GET https://support.google.com/accounts/?hl=en&visit_id=638845176026805186-2907418293&rd=2&topic=3382252 -HTTP/1.1 200 OK -#> - -using namespace System.Net.Http -#Requires -Version 7 -[CmdletBinding()] Param( -# The URL to retrieve. -[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] -[Alias('Url','Href','Src')][uri] $Uri, -# The HTTP method verb to use. -[HttpMethod] $Method = 'GET', -# A file to log the request to. -[string] $LogFile, -# Indicates headers shouldn't be output. -[switch] $SkipHeaders, -# Indicates content shouldn't be output. -[switch] $SkipContent -) -Begin -{ - $certhost = @{} - Import-CharConstants.ps1 :lock: :outbox_tray: :inbox_tray: :information_source: 'timer clock' -AsEmoji - - filter Get-HttpStatusColor - { - [CmdletBinding()][OutputType([ConsoleColor])] Param( - [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][int] $Code - ) - switch([int]::DivRem($Code, 100).Item1) - { - 1 {return [ConsoleColor]::White} - 2 {return [ConsoleColor]::Green} - 3 {return [ConsoleColor]::Blue} - 4 {return [ConsoleColor]::Red} - 5 {return [ConsoleColor]::DarkRed} - } - } - - function Trace-Uri - { - [CmdletBinding()] Param( - # The URL to retrieve. - [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] - [Alias('Url','Href','Src')][uri] $Uri, - # The HTTP method verb to use. - [HttpMethod] $Method = 'GET' - ) - if(!$certhost.Contains($Uri.Host)) - { - $certinfo = Get-ServerCertificate.ps1 $Uri.Host - $certhost[$Uri.Host] = $certinfo - Write-Info.ps1 "$lock $($Uri.Host) is $($certinfo.Subject) from $($certinfo.Issuer)" -fg Magenta - Write-Info.ps1 "${timer clock} Valid $($certinfo.Issued) to $($certinfo.Expires)" -fg DarkMagenta - } - $request = New-Object Net.Http.HttpRequestMessage -ArgumentList $Method, $Uri - $requestLine, $requestRawHeaders = "$Method $Uri", ($request.Headers.ToString()) - Write-Verbose $requestLine - Write-Verbose $requestRawHeaders - Write-Info.ps1 "$outbox_tray $requestLine" -fg DarkGreen - #Write-Info.ps1 $requestRawHeaders -fg DarkGray - if($LogFile) - {@" -### -$Method $Uri -$requestRawHeaders -"@ |Add-Content $LogFile - } - Write-Debug $requestLine - $StatusCode = 0 - Invoke-WebRequest -Uri $Uri -SkipHttpErrorCheck -MaximumRedirection 0 -AllowInsecureRedirect -EA Ignore | - Import-Variables.ps1 - if(!$StatusCode) - { - if($LogFile) - {@" -### -# Response: $($_.Message) -"@ |Add-Content $LogFile - } - return - } - $statusLine, $rawHeaders = ($RawContent -replace '(?s)\r?\n\r?\n.*\z') -split '\r?\n',2 - if($null -eq $rawHeaders) {$rawHeaders = ''} - Write-Verbose $statusLine - Write-Verbose $rawHeaders - Write-Info.ps1 "$inbox_tray $statusLine" -fg (Get-HttpStatusColor $StatusCode) - if(!$SkipHeaders) {Write-Info.ps1 $rawHeaders -fg Gray} - if(!$SkipContent -and $Content) {Write-Info.ps1 $Content -fg White} - if($LogFile) - {@" -### -# Response: -$RawContent -"@ |Add-Content $LogFile - } - if([int]::DivRem($StatusCode, 100).Item1 -eq 3) - { - foreach($location in $Headers.Location |ForEach-Object {New-Object Uri $Uri,$_}) - { - Write-Info.ps1 "$information_source Following redirect to $location" -fg DarkBlue - Trace-Uri $location - } - } - } -} -Process -{ - if(!$Uri.IsAbsoluteUri -and [uri]::IsWellFormedUriString("https://$Uri", 'Absolute')) - { - [uri] $Uri = "https://$Uri" - } - Trace-Uri -Uri $Uri -Method $Method -} +<# +.SYNOPSIS +Provides details about a retrieving a URI. + +.NOTES +TODO: Add support for other Invoke-WebRequest parameters. + +.INPUTS +System.Uri to retrieve. + +.FUNCTIONALITY +HTTP + +.LINK +Import-CharConstants.ps1 + +.LINK +Write-Info.ps1 + +.LINK +Import-Variables.ps1 + +.EXAMPLE +Trace-WebRequest.ps1 g.co/p3phelp -SkipHeaders -SkipContent + +g.co is CN=*.google.com from CN=WR2, O=Google Trust Services, C=US +Valid 05/12/2025 01:42:58 to 08/04/2025 01:42:57 +GET https://g.co/p3phelp +HTTP/1.1 302 Found +Following redirect to https://support.google.com/accounts/answer/151657?hl=en +support.google.com is CN=*.google.com from CN=WR2, O=Google Trust Services, C=US +Valid 05/12/2025 01:42:58 to 08/04/2025 01:42:57 +GET https://support.google.com/accounts/answer/151657?hl=en +HTTP/1.1 301 MovedPermanently +Following redirect to https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638845176026805186-2907418293&rd=1 +GET https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638845176026805186-2907418293&rd=1 +HTTP/1.1 301 MovedPermanently +Following redirect to https://support.google.com/accounts/?hl=en&visit_id=638845176026805186-2907418293&rd=2&topic=3382252 +GET https://support.google.com/accounts/?hl=en&visit_id=638845176026805186-2907418293&rd=2&topic=3382252 +HTTP/1.1 200 OK +#> + +using namespace System.Net.Http +[CmdletBinding()] Param( +# The URL to retrieve. +[Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] +[Alias('Url','Href','Src')][uri] $Uri, +# The HTTP method verb to use. +[HttpMethod] $Method = 'GET', +# A file to log the request to. +[string] $LogFile, +# Indicates headers shouldn't be output. +[switch] $SkipHeaders, +# Indicates content shouldn't be output. +[switch] $SkipContent +) +Begin +{ + $certhost = @{} + Import-CharConstants.ps1 :lock: :outbox_tray: :inbox_tray: :information_source: 'timer clock' -AsEmoji + + filter Get-HttpStatusColor + { + [CmdletBinding()][OutputType([ConsoleColor])] Param( + [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true)][int] $Code + ) + switch([int]::DivRem($Code, 100).Item1) + { + 1 {return [ConsoleColor]::White} + 2 {return [ConsoleColor]::Green} + 3 {return [ConsoleColor]::Blue} + 4 {return [ConsoleColor]::Red} + 5 {return [ConsoleColor]::DarkRed} + } + } + + function Trace-Uri + { + [CmdletBinding()] Param( + # The URL to retrieve. + [Parameter(Position=0,Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] + [Alias('Url','Href','Src')][uri] $Uri, + # The HTTP method verb to use. + [HttpMethod] $Method = 'GET' + ) + if(!$certhost.Contains($Uri.Host)) + { + $certinfo = Get-ServerCertificate.ps1 $Uri.Host + $certhost[$Uri.Host] = $certinfo + Write-Info.ps1 "$lock $($Uri.Host) is $($certinfo.Subject) from $($certinfo.Issuer)" -fg Magenta + Write-Info.ps1 "${timer clock} Valid $($certinfo.Issued) to $($certinfo.Expires)" -fg DarkMagenta + } + $request = New-Object Net.Http.HttpRequestMessage -ArgumentList $Method, $Uri + $requestLine, $requestRawHeaders = "$Method $Uri", ($request.Headers.ToString()) + Write-Verbose $requestLine + Write-Verbose $requestRawHeaders + Write-Info.ps1 "$outbox_tray $requestLine" -fg DarkGreen + #Write-Info.ps1 $requestRawHeaders -fg DarkGray + if($LogFile) + {@" +### +$Method $Uri +$requestRawHeaders +"@ |Add-Content $LogFile + } + Write-Debug $requestLine + $StatusCode = 0 + Invoke-WebRequest -Uri $Uri -SkipHttpErrorCheck -MaximumRedirection 0 -AllowInsecureRedirect -EA Ignore | + Import-Variables.ps1 + if(!$StatusCode) + { + if($LogFile) + {@" +### +# Response: $($_.Message) +"@ |Add-Content $LogFile + } + return + } + $statusLine, $rawHeaders = ($RawContent -replace '(?s)\r?\n\r?\n.*\z') -split '\r?\n',2 + if($null -eq $rawHeaders) {$rawHeaders = ''} + Write-Verbose $statusLine + Write-Verbose $rawHeaders + Write-Info.ps1 "$inbox_tray $statusLine" -fg (Get-HttpStatusColor $StatusCode) + if(!$SkipHeaders) {Write-Info.ps1 $rawHeaders -fg Gray} + if(!$SkipContent -and $Content) {Write-Info.ps1 $Content -fg White} + if($LogFile) + {@" +### +# Response: +$RawContent +"@ |Add-Content $LogFile + } + if([int]::DivRem($StatusCode, 100).Item1 -eq 3) + { + foreach($location in $Headers.Location |ForEach-Object {New-Object Uri $Uri,$_}) + { + Write-Info.ps1 "$information_source Following redirect to $location" -fg DarkBlue + Trace-Uri $location + } + } + } +} +Process +{ + if(!$Uri.IsAbsoluteUri -and [uri]::IsWellFormedUriString("https://$Uri", 'Absolute')) + { + [uri] $Uri = "https://$Uri" + } + Trace-Uri -Uri $Uri -Method $Method +} diff --git a/Update-Files.ps1 b/Update-Files.ps1 deleted file mode 100644 index 13a0350b..00000000 --- a/Update-Files.ps1 +++ /dev/null @@ -1,37 +0,0 @@ -<# -.SYNOPSIS -Copies specified source files that exist in the destination directory. - -.INPUTS -System.String of paths to copy from, if matches exist in the destination. - -.FUNCTIONALITY -Files - -.EXAMPLE -Update-Files.ps1 C:\Source\*.txt D:\Dest - -Copies *.txt files from C:\Source to D:\Dest that exist in both. -#> - -#Requires -Version 3 -[CmdletBinding(SupportsShouldProcess=$true)][OutputType([void])] Param( -# Path(s) to copy files from, wildcards allowed. -[Parameter(Position=0,ValueFromPipelineByPropertyName=$true,ValueFromPipeline=$true,Mandatory=$true)][string[]] $Path, -# Folder to copy files to, if they already exist there. -[ValidateScript({Test-Path $_ -PathType Container})][Parameter(Position=1)][string] $Destination, -# Indicates files should only be copied if they are newer. -[switch] $NewerOnly -) - -Process -{ - foreach($file in Resolve-Path $Path) - { - $destfile = Join-Path $Destination (Split-Path $file -Leaf) - if(!(Test-Path $destfile -PathType Leaf)) {continue} - if((!$NewerOnly -or (Test-NewerFile.ps1 "$destfile" "$file")) -and - $PSCmdlet.ShouldProcess("'$file' over '$destfile'",'copy')) - {Copy-Item $file $destfile} - } -} diff --git a/docs/Add-CapturesToMatches.ps1.md b/docs/Add-CapturesToMatches.ps1.md deleted file mode 100644 index 3e1c009c..00000000 --- a/docs/Add-CapturesToMatches.ps1.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Add-CapturesToMatches.ps1 - -## SYNOPSIS -Adds named capture groups as note properties to Select-String's MatchInfo objects. - -## SYNTAX - -``` -Add-CapturesToMatches.ps1 [[-MatchInfo] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -.*?\b)\s*(?\S+@\S+)$' addrbook.txt |Add-CapturesToMatches.ps1 |select Name,Phone,Filename -``` - -Name Email Filename ----- ----- -------- -Arthur Dent adent@example.org addrbook.txt -Tricia McMillan trillian@example.com addrbook.txt - -## PARAMETERS - -### -MatchInfo -The MatchInfo output from Select-String to augment with named capture groups. - -```yaml -Type: MatchInfo -Parameter Sets: (All) -Aliases: InputObject - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### Microsoft.PowerShell.Commands.MatchInfo, output from Select-String that used a pattern -### with named capture groups. -## OUTPUTS - -### Microsoft.PowerShell.Commands.MatchInfo with additional note properties for each named -### capture group. -## NOTES - -## RELATED LINKS - -[Add-Member]() - diff --git a/docs/Add-Counter.ps1.md b/docs/Add-Counter.ps1.md deleted file mode 100644 index 2603ca47..00000000 --- a/docs/Add-Counter.ps1.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Add-Counter.ps1 - -## SYNOPSIS -Adds a incrementing integer property to each pipeline object. - -## SYNTAX - -``` -Add-Counter.ps1 [[-PropertyName] ] [[-InitialValue] ] -InputObject [-Force] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-PSProvider |Add-Counter Position |select Position,Name -``` - -Position Name --------- ---- - 1 Registry - 2 Alias - 3 Environment - 4 FileSystem - 5 Function - 6 Variable - 7 Certificate - -## PARAMETERS - -### -PropertyName -The name of the property to add. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: Counter -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InitialValue -The starting number to count from. - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: 1 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The object to add the property to. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Force -Overwrites a property if one with the same name already exists. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Management.Automation.PSObject -## NOTES - -## RELATED LINKS - -[Add-Member]() - diff --git a/docs/Add-DynamicParam.ps1.md b/docs/Add-DynamicParam.ps1.md deleted file mode 100644 index ef41f95e..00000000 --- a/docs/Add-DynamicParam.ps1.md +++ /dev/null @@ -1,367 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Add-DynamicParam.ps1 - -## SYNOPSIS -Adds a dynamic parameter to a script, within a DynamicParam block. - -## SYNTAX - -``` -Add-DynamicParam.ps1 [-Name] [[-Type] ] [-Position ] [-ParameterSetName ] - [-Alias ] [-ValidateCount ] [-ValidateDrive ] [-ValidateLength ] - [-ValidatePattern ] [-ValidateRange ] [-ValidateScript ] - [-ValidateSet ] [-NotNull] [-NotNullOrEmpty] [-TrustedData] [-UserDrive] [-Mandatory] - [-ValueFromPipeline] [-ValueFromPipelineByPropertyName] [-ValueFromRemainingArguments] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -DynamicParam { Add-DynamicParam.ps1 Path string -Mandatory; $DynamicParams } Process { Import-Variables.ps1 $PSBoundParameters; ... } -``` - -## PARAMETERS - -### -Name -The name of the parameter. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Type -The data type of the parameter. - -```yaml -Type: Type -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Position -The position of the parameter when not specifying the parameter names. - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: -2147483648 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ParameterSetName -The name of the set of parameters this parameter belongs to. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: __AllParameterSets -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Alias -{{ Fill Alias Description }} - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValidateCount -The valid number of values for a parameter that accepts a collection. -A range can be specified with a list of two integers. - -```yaml -Type: Int32[] -Parameter Sets: (All) -Aliases: Count - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValidateDrive -Valid root drive(s) for parameters that accept paths. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValidateLength -The valid length for a string parameter. -A range can be specified with a list of two integers. - -```yaml -Type: Int32[] -Parameter Sets: (All) -Aliases: Length - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValidatePattern -The valid regular expression pattern to match for a string parameter. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Match, Pattern - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValidateRange -The valid range of values for a numeric parameter. - -```yaml -Type: Int32[] -Parameter Sets: (All) -Aliases: Range - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValidateScript -A script block to validate a parameter's value. -Any true result will validate the value, any false result will reject it. - -```yaml -Type: ScriptBlock -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValidateSet -A set of valid values for the parameter. -This will enable tab-completion. - -```yaml -Type: Object[] -Parameter Sets: (All) -Aliases: Values - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -NotNull -Requires parameter to be non-null. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -NotNullOrEmpty -Requires parameter to be non-null and non-empty. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -TrustedData -Requires the parameter value to be Trusted data. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UserDrive -Requires a path parameter to be on a User drive. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Mandatory -Indicates a required parameter. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: Required - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValueFromPipeline -Indicates a parameter that can accept values from the pipeline. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: Pipeline - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValueFromPipelineByPropertyName -Indicates a parameter that can accept values from the pipeline by matching the property name of pipeline objects to the -parameter name or alias. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: PipelineProperties, PipeName - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ValueFromRemainingArguments -{{ Fill ValueFromRemainingArguments Description }} - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: RemainingArgs - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Object[] a list of possible values for this parameter to validate against. -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS diff --git a/docs/Add-NoteProperty.ps1.md b/docs/Add-NoteProperty.ps1.md deleted file mode 100644 index aeeda91f..00000000 --- a/docs/Add-NoteProperty.ps1.md +++ /dev/null @@ -1,197 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Add-NoteProperty.ps1 - -## SYNOPSIS -Adds a NoteProperty to a PSObject, calculating the value with the object in context. - -## SYNTAX - -### NameValue -``` -Add-NoteProperty.ps1 [-Name] [-Value] [-Properties ] -InputObject - [-PassThru] [-Force] [-ProgressAction ] [] -``` - -### NewProperties -``` -Add-NoteProperty.ps1 [-NewProperties] [-Properties ] -InputObject [-PassThru] - [-Force] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-ChildItem Get-*.ps1 |Add-NoteProperty.ps1 Size {Format-ByteUnits.ps1 $Length -Precision 1} -Properties Length -PassThru |Format-Table Size,Name -AutoSize -``` - -Size Name ----- ---- -8.1KB Get-AspNetEvents.ps1 -840 Get-AssemblyFramework.ps1 -7KB Get-CertificatePath.ps1 -1.5KB Get-CertificatePermissions.ps1 -38.3KB Get-CharacterDetails.ps1 -1.1KB Get-ClassicAspEvents.ps1 -1.3KB Get-CommandPath.ps1 -1.2KB Get-ConfigConnectionStringBuilders.ps1 -4.9KB Get-ConsoleColors.ps1 -1.4KB Get-ContentSecurityPolicy.ps1 -617 Get-Dns.ps1 -2.4KB Get-EnumValues.ps1 -6KB Get-IisLog.ps1 -1.9KB Get-LibraryVulnerabilityInfo.ps1 -2.7KB Get-DotNetFrameworkVersions.ps1 -969 Get-RepoName.ps1 -3.3KB Get-SslDetails.ps1 -4.2KB Get-SystemDetails.ps1 -6.8KB Get-TypeAccelerators.ps1 -1.2KB Get-XmlNamespaces.ps1 - -## PARAMETERS - -### -Name -The name of the NoteProperty to add to the object. - -```yaml -Type: String -Parameter Sets: NameValue -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Value -The expression to use to set the value of the NoteProperty. - -```yaml -Type: ScriptBlock -Parameter Sets: NameValue -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -NewProperties -A hashtable mapping names of new properties to script blocks generating the values of those properties. - -```yaml -Type: Hashtable -Parameter Sets: NewProperties -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Properties -{{ Fill Properties Description }} - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: Import - -Required: False -Position: Named -Default value: @() -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The object to add the NoteProperty to. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -PassThru -Returns the object with the NoteProperty added. -Normally there is no output. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Force -{{ Fill Force Description }} - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Void -### System.Management.Automation.PSObject -## NOTES - -## RELATED LINKS - -[Add-Member]() - diff --git a/docs/Add-NotebookCell.ps1.md b/docs/Add-NotebookCell.ps1.md index 0bffe74f..de0cd767 100644 --- a/docs/Add-NotebookCell.ps1.md +++ b/docs/Add-NotebookCell.ps1.md @@ -13,8 +13,7 @@ When run within a Polyglot Notebook, appends a cell to it. ## SYNTAX ``` -Add-NotebookCell.ps1 [-InputObject] [-ProgressAction ] [-Language ] - [] +Add-NotebookCell.ps1 [-InputObject] [-ProgressAction ] [] ``` ## DESCRIPTION @@ -46,21 +45,6 @@ Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -Language -{{ Fill Language Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -ProgressAction {{ Fill ProgressAction Description }} diff --git a/docs/Add-NugetPackage.ps1.md b/docs/Add-NugetPackage.ps1.md deleted file mode 100644 index 8dd4e364..00000000 --- a/docs/Add-NugetPackage.ps1.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://www.nuget.org/ -schema: 2.0.0 ---- - -# Add-NugetPackage.ps1 - -## SYNOPSIS -Loads a NuGet package DLL, downloading as needed. - -## SYNTAX - -``` -Add-NugetPackage.ps1 [-PackageName] [[-TypeName] ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Add-NugetPackage.ps1 Serilog ; [Serilog.Core.Logger]::None -is [Serilog.ILogger] -``` - -True - -## PARAMETERS - -### -PackageName -The name of the NuGet package to load. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -TypeName -Use this type name to test whether the package was loaded. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES -Install-Package isn't working for arbitrary NuGet packages, so this allows us access the main DLL -assembly and types within the package. - -## RELATED LINKS - -[https://www.nuget.org/](https://www.nuget.org/) - diff --git a/docs/Add-ParameterDefault.ps1.md b/docs/Add-ParameterDefault.ps1.md deleted file mode 100644 index 514a0d3a..00000000 --- a/docs/Add-ParameterDefault.ps1.md +++ /dev/null @@ -1,136 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Add-ParameterDefault.ps1 - -## SYNOPSIS -Appends or creates a value to use for the specified cmdlet parameter to use when one is not specified. - -## SYNTAX - -``` -Add-ParameterDefault.ps1 [-CommandName] [-ParameterName] [-Value] [-Scope ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Add-ParameterDefault.ps1 epcsv nti $true -Scope Global -``` - -Establishes that the -NoTypeInformation param of the Export-Csv cmdlet will be true if not otherwise specified, -globally for the PowerShell session. - -### EXAMPLE 2 -``` -Add-ParameterDefault.ps1 Select-Xml Namespace @{svg = 'http://www.w3.org/2000/svg'} -``` - -Adds the SVG namespace to any existing namespaces used by Select-Xml when none are given explicitly. - -## PARAMETERS - -### -CommandName -The name of a cmdlet, function, script, or alias to include a default parameter value for. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: CmdletName - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ParameterName -The name or alias of the parameter to include a default value for. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Value -The value to include as a default. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: True -Position: 3 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Scope -The scope of this default. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: Local -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Object containing a default value to include. -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[Add-ScopeLevel.ps1]() - -[Stop-ThrowError.ps1]() - -[Get-Command]() - -[about_Scopes]() - diff --git a/docs/Add-TimeSpan.ps1.md b/docs/Add-TimeSpan.ps1.md deleted file mode 100644 index 64e1db09..00000000 --- a/docs/Add-TimeSpan.ps1.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Add-TimeSpan.ps1 - -## SYNOPSIS -Adds a timespan to DateTime values. - -## SYNTAX - -``` -Add-TimeSpan.ps1 [-TimeSpan] [-DateTime] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-Date |Add-TimeSpan.ps1 00:00:30 -``` - -Adds 30 seconds to the current date and time value. - -## PARAMETERS - -### -TimeSpan -The TimeSpan value to add. - -```yaml -Type: TimeSpan -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DateTime -The DateTime value to add to. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.DateTime values to add the TimeSpan value to. -## OUTPUTS - -### System.DateTime values with the TimeSpan added. -## NOTES - -## RELATED LINKS diff --git a/docs/Compare-Keys.ps1.md b/docs/Compare-Keys.ps1.md deleted file mode 100644 index c31a4e3b..00000000 --- a/docs/Compare-Keys.ps1.md +++ /dev/null @@ -1,139 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Compare-Keys.ps1 - -## SYNOPSIS -Returns the differences between two dictionaries. - -## SYNTAX - -``` -Compare-Keys.ps1 [-ReferenceDictionary] [-DifferenceDictionary] [-ExcludeDifferent] - [-IncludeEqual] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Compare-Keys.ps1 @{ A = 1; B = 2; C = 3 } @{ D = 6; C = 4; B = 2 } -IncludeEqual -``` - -Key Action ReferenceValue DifferenceValue ---- ------ -------------- --------------- -A Deleted 1 -B Unchanged 2 2 -C Modified 3 4 -D Added 6 - -## PARAMETERS - -### -ReferenceDictionary -The original dictionary to compare. - -```yaml -Type: IDictionary -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DifferenceDictionary -A dictionary to compare to the original. - -```yaml -Type: IDictionary -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ExcludeDifferent -Indicates that different values should be ignored. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IncludeEqual -Indicates that identical values should be included. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Collections.IDictionary to compare to the reference dictionary. -## OUTPUTS - -### System.Management.Automation.PSObject with these properties: -### * Key: The dictionary key being compared. -### * Action: A Data.DataRowState that indicates whether the key-value pair has been -### Added, Deleted, Modified, or Unchanged. -### * ReferenceValue: The original value. -### * DifferenceValue: The new value. -## NOTES - -## RELATED LINKS - -[Compare-Object]() - -[Group-Object]() - -[ForEach-Object]() - -[Sort-Object]() - diff --git a/docs/Compare-Properties.ps1.md b/docs/Compare-Properties.ps1.md deleted file mode 100644 index c260e141..00000000 --- a/docs/Compare-Properties.ps1.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/dotnet/api/system.management.automation.psmemberset -schema: 2.0.0 ---- - -# Compare-Properties.ps1 - -## SYNOPSIS -Compares the properties of two objects. - -## SYNTAX - -``` -Compare-Properties.ps1 [[-ReferenceObject] ] [[-DifferenceObject] ] [-ExcludeDifferent] - [-IncludeEqual] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Compare-Properties.ps1 (Get-PSProvider variable) (Get-PSProvider alias) -``` - -PropertyName : ImplementingType -Reference : True -Value : Microsoft.PowerShell.Commands.VariableProvider -Difference : True -DifferentValue : Microsoft.PowerShell.Commands.AliasProvider - -PropertyName : Name -Reference : True -Value : Variable -Difference : True -DifferentValue : Alias - -PropertyName : Drives -Reference : True -Value : {Variable} -Difference : True -DifferentValue : {Alias} - -## PARAMETERS - -### -ReferenceObject -The base object to compare properties to. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DifferenceObject -The second object to compare the properties of. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ExcludeDifferent -Indicates different values should be suppressed. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IncludeEqual -Indicates equal values should be included. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Management.Automation.PSObject with properties to compare. -## OUTPUTS - -### System.Management.Automation.PSCustomObject for each relevant property comparison, -### with these fields: -### * PropertyName -### * Reference -### * Value -### * Difference -### * DifferentValue -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/dotnet/api/system.management.automation.psmemberset](https://docs.microsoft.com/dotnet/api/system.management.automation.psmemberset) - diff --git a/docs/Convert-ClipboardTsvToHtml.ps1.md b/docs/Convert-ClipboardTsvToHtml.ps1.md deleted file mode 100644 index be04cbb8..00000000 --- a/docs/Convert-ClipboardTsvToHtml.ps1.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Convert-ClipboardTsvToHtml.ps1 - -## SYNOPSIS -Parses TSV clipboard data into HTML table data which is copied back to the clipboard. - -## SYNTAX - -``` -Convert-ClipboardTsvToHtml.ps1 [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Convert-ClipboardTsvToHtml.ps1 -``` - -TSV clipboard data may now be pasted into an email or document as a table. - -## PARAMETERS - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS diff --git a/docs/ConvertFrom-Base64.ps1.md b/docs/ConvertFrom-Base64.ps1.md deleted file mode 100644 index 264ae433..00000000 --- a/docs/ConvertFrom-Base64.ps1.md +++ /dev/null @@ -1,112 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/dotnet/api/system.convert.frombase64string -schema: 2.0.0 ---- - -# ConvertFrom-Base64.ps1 - -## SYNOPSIS -Converts base64-encoded text to bytes or text. - -## SYNTAX - -``` -ConvertFrom-Base64.ps1 [-Data] [[-Encoding] ] [-UriStyle] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -ConvertFrom-Base64.ps1 dXNlcm5hbWU6QmFkUEBzc3dvcmQ= utf8 -``` - -username:BadP@ssword - -## PARAMETERS - -### -Data -The base64-encoded data. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Encoding -Uses the specified encoding to convert the bytes in the data to text. - -If no encoding is provided, the data will be returned as a byte array. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: Byte -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UriStyle -Indicates that the URI-friendly variant of the base64 algorithm should be used. -This variant, as used by JWTs, uses - instead of +, and _ instead of /, and trims the = padding at the end -to avoid extra escaping within URLs or URL-encoded data. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String of base64-encoded text to decode. -## OUTPUTS - -### System.String or System.Byte[] of decoded text or data. -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/dotnet/api/system.convert.frombase64string](https://docs.microsoft.com/dotnet/api/system.convert.frombase64string) - diff --git a/docs/ConvertFrom-CimInstance.ps1.md b/docs/ConvertFrom-CimInstance.ps1.md deleted file mode 100644 index ad1ac4fa..00000000 --- a/docs/ConvertFrom-CimInstance.ps1.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# ConvertFrom-CimInstance.ps1 - -## SYNOPSIS -Convert a CimInstance object to a PSObject. - -## SYNTAX - -``` -ConvertFrom-CimInstance.ps1 [[-InputObject] ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -$tasks = Get-ScheduledTask |ConvertFrom-CimInstance.ps1 -``` - -Gets the scheduled tasks as PSObjects that support tab completion and can be serialized and exported. - -## PARAMETERS - -### -InputObject -The CimInstance object to convert to a PSObject. - -```yaml -Type: CimInstance -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### Microsoft.Management.Infrastructure.CimInstance to convert to a PSObject. -## OUTPUTS - -### PSObject converted from the CimInstance entered. -## NOTES - -## RELATED LINKS diff --git a/docs/ConvertFrom-DataRow.ps1.md b/docs/ConvertFrom-DataRow.ps1.md deleted file mode 100644 index 6af40cc2..00000000 --- a/docs/ConvertFrom-DataRow.ps1.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# ConvertFrom-DataRow.ps1 - -## SYNOPSIS -Converts a DataRow object to a PSObject, Hashtable, or single value. - -## SYNTAX - -### AsObject (Default) -``` -ConvertFrom-DataRow.ps1 [-DataRow] [-ProgressAction ] [] -``` - -### AsValues -``` -ConvertFrom-DataRow.ps1 [-DataRow] [-AsValues] [-ProgressAction ] - [] -``` - -### AsDictionary -``` -ConvertFrom-DataRow.ps1 [-DataRow] [-AsDictionary] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Invoke-Sqlcmd "select top 3 ProductID, Name from Production.Product" -ServerInstance ServerName -Database AdventureWorks |ConvertFrom-DataRow.ps1 |ConvertTo-Html -``` - -## PARAMETERS - -### -DataRow -A record containing fields/columns to convert to an object with properties. - -```yaml -Type: DataRow -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -AsValues -Indicates a the record's values should be returned as an array. - -```yaml -Type: SwitchParameter -Parameter Sets: AsValues -Aliases: AsArray - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -AsDictionary -Indicates an ordered dictionary of fieldnames/columnnames to values should be returned -rather than an object with properties. - -```yaml -Type: SwitchParameter -Parameter Sets: AsDictionary -Aliases: AsOrderedDictionary, AsHashtable - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Data.DataRow with fields to convert into an object with properties or -### into a hash with key/value pairs. -## OUTPUTS - -### System.Management.Automation.PSObject -### or System.Object[] if -AsValues is specified -### or System.Collections.Specialized.OrderedDictionary if -AsDictionary is specified -## NOTES - -## RELATED LINKS diff --git a/docs/ConvertFrom-Duration.ps1.md b/docs/ConvertFrom-Duration.ps1.md deleted file mode 100644 index 90644876..00000000 --- a/docs/ConvertFrom-Duration.ps1.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://en.wikipedia.org/wiki/ISO_8601#Durations -schema: 2.0.0 ---- - -# ConvertFrom-Duration.ps1 - -## SYNOPSIS -Parses a Timespan from a ISO8601 duration string. - -## SYNTAX - -``` -ConvertFrom-Duration.ps1 [[-InputObject] ] [-NoWarnings] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -"$(ConvertFrom-Duration.ps1 P1D)" -``` - -1.00:00:00 - -### EXAMPLE 2 -``` -"$(ConvertFrom-Duration.ps1 P3Y6M4DT12H30M5S)" -``` - -WARNING: Adding year(s) as a mean number of days (365.2425). -WARNING: Adding month(s) as a mean number of days (30.436875). -1283.12:30:05 - -## PARAMETERS - -### -InputObject -An ISO8601 duration string in one of four formats: - - * PnYnMnDTnHnMnS - * PnW - * Pyyyy-MM-ddTHH:mm:ss - * PyyyyMMddTHHmmss - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -NoWarnings -Supresses warnings about approximate conversions. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: Quiet - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String containing an ISO8601 duration. -## OUTPUTS - -### System.Timespan containing the duration, as parsed and converted to a Timespan. -## NOTES - -## RELATED LINKS - -[https://en.wikipedia.org/wiki/ISO_8601#Durations](https://en.wikipedia.org/wiki/ISO_8601#Durations) - -[Import-Variables.ps1]() - -[Test-Variable.ps1]() - -[Stop-ThrowError.ps1]() - diff --git a/docs/ConvertFrom-EpochTime.ps1.md b/docs/ConvertFrom-EpochTime.ps1.md deleted file mode 100644 index 59468445..00000000 --- a/docs/ConvertFrom-EpochTime.ps1.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://en.wikipedia.org/wiki/Unix_time -schema: 2.0.0 ---- - -# ConvertFrom-EpochTime.ps1 - -## SYNOPSIS -Converts an integer Unix (POSIX) time (seconds since Jan 1, 1970) into a DateTime value. - -## SYNTAX - -``` -ConvertFrom-EpochTime.ps1 [-InputObject] [-UniversalTime] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -1556884381 |ConvertFrom-EpochTime.ps1 -``` - -Friday, May 3, 2019 11:53:01 - -## PARAMETERS - -### -InputObject -The Epoch time value to convert to a DateTime. - -```yaml -Type: Int64 -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: 0 -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -UniversalTime -Indicates the DateTime provided is local, and should be converted to UTC. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: UTC, Z - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Int32 value converted from date and time value. -## OUTPUTS - -### System.DateTime value to convert to integer. -## NOTES - -## RELATED LINKS - -[https://en.wikipedia.org/wiki/Unix_time](https://en.wikipedia.org/wiki/Unix_time) - -[https://stackoverflow.com/a/1860511/54323](https://stackoverflow.com/a/1860511/54323) - -[Get-Date]() - diff --git a/docs/ConvertFrom-Hex.ps1.md b/docs/ConvertFrom-Hex.ps1.md deleted file mode 100644 index 8ec2e897..00000000 --- a/docs/ConvertFrom-Hex.ps1.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/dotnet/api/system.numerics.biginteger.parse#System_Numerics_BigInteger_Parse_System_String_System_Globalization_NumberStyles_ -schema: 2.0.0 ---- - -# ConvertFrom-Hex.ps1 - -## SYNOPSIS -Convert a string of hexadecimal digits into a byte array. - -## SYNTAX - -``` -ConvertFrom-Hex.ps1 [-InputObject] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -ConvertFrom-Hex.ps1 'EF BB BF' -``` - -239 -187 -191 - -### EXAMPLE 2 -``` -[text.encoding]::UTF8.GetString((ConvertFrom-Hex.ps1 0x25504446)) -``` - -%PDF - -### EXAMPLE 3 -``` -'{0:X2} {1:X2} {2:X2}' -f (ConvertFrom-Hex.ps1 c0ffee) -``` - -C0 FF EE - -## PARAMETERS - -### -InputObject -A string of hex digits. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String of hex digits. -## OUTPUTS - -### System.Byte[] of bytes parsed from hex digits. -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/dotnet/api/system.numerics.biginteger.parse#System_Numerics_BigInteger_Parse_System_String_System_Globalization_NumberStyles_](https://docs.microsoft.com/dotnet/api/system.numerics.biginteger.parse#System_Numerics_BigInteger_Parse_System_String_System_Globalization_NumberStyles_) - -[https://docs.microsoft.com/dotnet/api/system.array.reverse#System_Array_Reverse_System_Array_](https://docs.microsoft.com/dotnet/api/system.array.reverse#System_Array_Reverse_System_Array_) - diff --git a/docs/ConvertFrom-IsoWeekDate.ps1.md b/docs/ConvertFrom-IsoWeekDate.ps1.md deleted file mode 100644 index 64350827..00000000 --- a/docs/ConvertFrom-IsoWeekDate.ps1.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# ConvertFrom-IsoWeekDate.ps1 - -## SYNOPSIS -Returns a DateTime object from an ISO week date string. - -## SYNTAX - -``` -ConvertFrom-IsoWeekDate.ps1 [[-InputObject] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### Example 1 -```powershell -PS C:\> {{ Add example code here }} -``` - -{{ Add example description here }} - -## PARAMETERS - -### -InputObject -{{ Fill InputObject Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS diff --git a/docs/ConvertFrom-XmlElement.ps1.md b/docs/ConvertFrom-XmlElement.ps1.md index 0daed649..08fc79d7 100644 --- a/docs/ConvertFrom-XmlElement.ps1.md +++ b/docs/ConvertFrom-XmlElement.ps1.md @@ -14,19 +14,19 @@ Converts named nodes of an element to properties of a PSObject, recursively. ### Document ``` -ConvertFrom-XmlElement.ps1 [-Document] [-OnlyAttributes] [-ProgressAction ] - [] +ConvertFrom-XmlElement.ps1 [-Document] [-OnlyAttributes] [-SimpleSuccession] + [-ProgressAction ] [] ``` ### Element ``` -ConvertFrom-XmlElement.ps1 [-Element] [-OnlyAttributes] [-ProgressAction ] - [] +ConvertFrom-XmlElement.ps1 [-Element] [-OnlyAttributes] [-SimpleSuccession] + [-ProgressAction ] [] ``` ### SelectXmlInfo ``` -ConvertFrom-XmlElement.ps1 [-SelectXmlInfo] [-OnlyAttributes] +ConvertFrom-XmlElement.ps1 [-SelectXmlInfo] [-OnlyAttributes] [-SimpleSuccession] [-ProgressAction ] [] ``` @@ -106,6 +106,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -SimpleSuccession +Replace any simple element that only contains one other element with its child. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: CollapseSimple + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -ProgressAction {{ Fill ProgressAction Description }} diff --git a/docs/ConvertTo-Base64.ps1.md b/docs/ConvertTo-Base64.ps1.md deleted file mode 100644 index ae22c00f..00000000 --- a/docs/ConvertTo-Base64.ps1.md +++ /dev/null @@ -1,131 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/dotnet/api/system.convert.tobase64string -schema: 2.0.0 ---- - -# ConvertTo-Base64.ps1 - -## SYNOPSIS -Converts bytes or text to base64-encoded text. - -## SYNTAX - -### BinaryData -``` -ConvertTo-Base64.ps1 [-Data] [-UriStyle] [-ProgressAction ] [] -``` - -### TextData -``` -ConvertTo-Base64.ps1 [-Text] [[-Encoding] ] [-UriStyle] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -ConvertTo-Base64.ps1 'username:BadP@ssword' utf8 -``` - -dXNlcm5hbWU6QmFkUEBzc3dvcmQ= - -## PARAMETERS - -### -Data -Binary data to convert. - -```yaml -Type: Byte[] -Parameter Sets: BinaryData -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Text -Text data to convert. - -```yaml -Type: String -Parameter Sets: TextData -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Encoding -The text encoding to use when converting text to binary data. - -```yaml -Type: String -Parameter Sets: TextData -Aliases: - -Required: False -Position: 2 -Default value: Utf8 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UriStyle -Indicates that the URI-friendly variant of the base64 algorithm should be used. -This variant, as used by JWTs, uses - instead of +, and _ instead of /, and trims the = padding at the end -to avoid extra escaping within URLs or URL-encoded data. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String or System.Byte[] of data to base64-encode. -## OUTPUTS - -### System.String containing the base64-encoded data. -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/dotnet/api/system.convert.tobase64string](https://docs.microsoft.com/dotnet/api/system.convert.tobase64string) - diff --git a/docs/ConvertTo-EpochTime.ps1.md b/docs/ConvertTo-EpochTime.ps1.md deleted file mode 100644 index 4a498ff1..00000000 --- a/docs/ConvertTo-EpochTime.ps1.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://en.wikipedia.org/wiki/Unix_time -schema: 2.0.0 ---- - -# ConvertTo-EpochTime.ps1 - -## SYNOPSIS -Converts a DateTime value into an integer Unix (POSIX) time, seconds since Jan 1, 1970. - -## SYNTAX - -``` -ConvertTo-EpochTime.ps1 [-DateTime] [-UniversalTime] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-Date |ConvertTo-EpochTime.ps1 -``` - -1556884381 - -## PARAMETERS - -### -DateTime -The DateTime value to convert to number of seconds since Jan 1, 1970. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -UniversalTime -Indicates the DateTime provided is local, and should be converted to UTC. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: UTC, Z - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.DateTime values to convert to integers. -## OUTPUTS - -### System.Int32 values converted from date and time values. -## NOTES - -## RELATED LINKS - -[https://en.wikipedia.org/wiki/Unix_time](https://en.wikipedia.org/wiki/Unix_time) - -[https://stackoverflow.com/a/1860511/54323](https://stackoverflow.com/a/1860511/54323) - -[Get-Date]() - diff --git a/docs/ConvertTo-FileName.ps1.md b/docs/ConvertTo-FileName.ps1.md deleted file mode 100644 index b2d7c06f..00000000 --- a/docs/ConvertTo-FileName.ps1.md +++ /dev/null @@ -1,196 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# ConvertTo-FileName.ps1 - -## SYNOPSIS -Returns a valid and safe filename from a given string. - -## SYNTAX - -``` -ConvertTo-FileName.ps1 [[-OutputBlock] ] [[-Replacement] ] [[-IncludeChars] ] - [[-ExcludeChars] ] [[-IncludeRunes] ] [[-ExcludeRunes] ] [-CurrentPlatformOnly] - [-InputObject] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -'app*.log' |ConvertTo-FileName.ps1 -``` - -app_.log - -### EXAMPLE 2 -``` -' |ConvertTo-FileName.ps1 -CurrentPlatformOnly -``` - -one_two-_three_ - -### EXAMPLE 3 -``` -'app-${value}.config' |ConvertTo-FileName.ps1 Ascii -ExcludeChars '%','$','{','}','`' -``` - -app-_value_.config - -## PARAMETERS - -### -OutputBlock -Allows limiting the filename to either ASCII or Basic Multilingual Plane characters, if specified. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Replacement -The character to use to replace a range of invalid characters. - -```yaml -Type: Rune -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: '_'[0] -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IncludeChars -Characters to include (overrides exclusions). - -```yaml -Type: Char[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: @() -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ExcludeChars -Characters to exclude. - -```yaml -Type: Char[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 4 -Default value: @() -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IncludeRunes -Runes to include (overrides excludes). - -```yaml -Type: Rune[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 5 -Default value: @() -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ExcludeRunes -Runes to exclude. - -```yaml -Type: Rune[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 6 -Default value: @() -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -CurrentPlatformOnly -Indicates that only characters invalid for the current platform should be excluded by default, -otherwise invalid characters from any platform will be excluded by default (unless overridden). - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The string value to sanitize for use as a filename. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 7 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String containing a filename that may contain invalid characters. -## OUTPUTS - -### System.String containing a filename without any invalid characters. -## NOTES - -## RELATED LINKS diff --git a/docs/ConvertTo-OrderedDictionary.ps1.md b/docs/ConvertTo-OrderedDictionary.ps1.md deleted file mode 100644 index 641eee17..00000000 --- a/docs/ConvertTo-OrderedDictionary.ps1.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# ConvertTo-OrderedDictionary.ps1 - -## SYNOPSIS -Converts an object to an ordered dictionary of properties and values. - -## SYNTAX - -``` -ConvertTo-OrderedDictionary.ps1 [-InputObject] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -ls *.txt |ConvertTo-OrderedDictionary.ps1 -``` - -## PARAMETERS - -### -InputObject -An object to convert to a dictionary. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### Any .NET object to convert into a properties hash. -## OUTPUTS - -### System.Collections.Specialized.OrderedDictionary of the object's property names and values. -## NOTES - -## RELATED LINKS - -[Get-Member]() - diff --git a/docs/ConvertTo-PowerShell.ps1.md b/docs/ConvertTo-PowerShell.ps1.md deleted file mode 100644 index f8fcdcd6..00000000 --- a/docs/ConvertTo-PowerShell.ps1.md +++ /dev/null @@ -1,255 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# ConvertTo-PowerShell.ps1 - -## SYNOPSIS -Serializes complex content into PowerShell literals. - -## SYNTAX - -### GenerateKey (Default) -``` -ConvertTo-PowerShell.ps1 [[-Value] ] [-Indent ] [-IndentBy ] [-Newline ] - [-SkipInitialIndent] [-Width ] [-GenerateKey] [-ProgressAction ] - [] -``` - -### SecureKey -``` -ConvertTo-PowerShell.ps1 [[-Value] ] [-Indent ] [-IndentBy ] [-Newline ] - [-SkipInitialIndent] [-Width ] -SecureKey [-ProgressAction ] - [] -``` - -### Credential -``` -ConvertTo-PowerShell.ps1 [[-Value] ] [-Indent ] [-IndentBy ] [-Newline ] - [-SkipInitialIndent] [-Width ] -Credential [-ProgressAction ] - [] -``` - -### KeyBytes -``` -ConvertTo-PowerShell.ps1 [[-Value] ] [-Indent ] [-IndentBy ] [-Newline ] - [-SkipInitialIndent] [-Width ] -KeyBytes [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -4096LMB |ConvertTo-PowerShell.ps1 -``` - -4LGB - -### EXAMPLE 2 -``` -ConvertFrom-Json '[{"a":1,"b":2,"c":{"d":"\/Date(1490216371478)\/","e":null}}]' |ConvertTo-PowerShell.ps1 -``` - -@( - \[PSCustomObject\]@{ - a = 1 - b = 2 - c = \[PSCustomObject\]@{ - d = \[datetime\]'2017-03-22T20:59:31' - e = $null - } - } -) - -## PARAMETERS - -### -Value -An array, hash, object, or value type that can be represented as a PowerShell literal. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Indent -The starting indent value. -You can probably ignore this. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IndentBy -The string to use for incremental indentation. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Newline -The line ending sequence to use. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: [environment]::NewLine -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SkipInitialIndent -Indicates the first line has already been indented. -You can probably ignore this. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Width -The maximum width of string literals. - -```yaml -Type: UInt16 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -GenerateKey -Generates a key to use for encrypting credential and secure string literals. -If this is omitted, credentials will be encrypted using DPAPI, which will only be -decryptable on the same Windows machine where they were encrypted. - -```yaml -Type: SwitchParameter -Parameter Sets: GenerateKey -Aliases: PortableKey - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SecureKey -The key to use for encrypting credentials and secure strings, as a secure string to be -encoded into UTF-8 bytes. - -```yaml -Type: SecureString -Parameter Sets: SecureKey -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Credential -A credential containing a password (the username is ignored) to be used for encrypting -credentials and secure strings, after encoding to UTF-8 bytes. - -```yaml -Type: PSCredential -Parameter Sets: Credential -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -KeyBytes -The key to use for encrypting credentials and secure strings, as a byte array. - -```yaml -Type: Byte[] -Parameter Sets: KeyBytes -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Object (any object) to serialize. -## OUTPUTS - -### System.String containing the object serialized to PowerShell literal statements. -## NOTES - -## RELATED LINKS diff --git a/docs/ConvertTo-RomanNumeral.ps1.md b/docs/ConvertTo-RomanNumeral.ps1.md deleted file mode 100644 index a4c28dec..00000000 --- a/docs/ConvertTo-RomanNumeral.ps1.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://www.c-sharpcorner.com/blogs/converting-to-and-from-roman-numerals1 -schema: 2.0.0 ---- - -# ConvertTo-RomanNumeral.ps1 - -## SYNOPSIS -Convert a number to a Roman numeral. - -## SYNTAX - -``` -ConvertTo-RomanNumeral.ps1 [-Value] [-Unicode] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -ConvertTo-RomanNumeral.ps1 2020 -``` - -MMXX - -### EXAMPLE 2 -``` -ConvertTo-RomanNumeral.ps1 8 -``` - -VIII - -## PARAMETERS - -### -Value -The numeric value to convert into a Roman numeral string. - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: 0 -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Unicode -Indicates that Unicode Roman numeral characters should be used (U+2160-U+216F). - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Int32 value to convert to a Roman numeral string. -## OUTPUTS - -### System.String containing a Roman numeral. -## NOTES - -## RELATED LINKS - -[https://www.c-sharpcorner.com/blogs/converting-to-and-from-roman-numerals1](https://www.c-sharpcorner.com/blogs/converting-to-and-from-roman-numerals1) - -[Get-Variable]() - diff --git a/docs/ConvertTo-SafeEntities.ps1.md b/docs/ConvertTo-SafeEntities.ps1.md deleted file mode 100644 index f56f82f8..00000000 --- a/docs/ConvertTo-SafeEntities.ps1.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/dotnet/api/system.char.issurrogatepair -schema: 2.0.0 ---- - -# ConvertTo-SafeEntities.ps1 - -## SYNOPSIS -Encode text as XML/HTML, escaping all characters outside 7-bit ASCII. - -## SYNTAX - -``` -ConvertTo-SafeEntities.ps1 [-InputObject] [-IncludeMarkupChars] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -"$([char]0xD83D)$([char]0xDCA1) File $([char]0x2192) Save" |ConvertTo-SafeEntities.ps1 -``` - -💡 File → Save - -This shows a UTF-16 surrogate pair, used internally by .NET strings, which is combined -into a single entity reference. - -### EXAMPLE 2 -``` -"ETA: $([char]0xBD) hour" |ConvertTo-SafeEntities.ps1 -``` - -ETA: ½ hour - -## PARAMETERS - -### -InputObject -An HTML or XML string that may include emoji or other Unicode characters outside -the 7-bit ASCII range. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -IncludeMarkupChars -Indicates that markdown characters should also be escaped. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String of HTML or XML data to encode. -## OUTPUTS - -### System.String of HTML or XML data, encoded. -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/dotnet/api/system.char.issurrogatepair](https://docs.microsoft.com/dotnet/api/system.char.issurrogatepair) - -[https://docs.microsoft.com/dotnet/api/system.char.converttoutf32](https://docs.microsoft.com/dotnet/api/system.char.converttoutf32) - diff --git a/docs/Copy-Html.ps1.md b/docs/Copy-Html.ps1.md deleted file mode 100644 index 25682d53..00000000 --- a/docs/Copy-Html.ps1.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Copy-Html.ps1 - -## SYNOPSIS -Copies objects as an HTML table. - -## SYNTAX - -``` -Copy-Html.ps1 [[-Property] ] [-InputObject ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-PSDrive |Copy-Html.ps1 Name,Description -``` - -Copies an HTML table with two columns to the clipboard as formatted text -that can be pasted into emails or other formatted documents. - -## PARAMETERS - -### -Property -Columns to include in the copied table. - -```yaml -Type: Array -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The objects to turn into table rows. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Management.Automation.PSObject to be turned into a table row. -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS - -[Format-HtmlDataTable.ps1]() - -[ConvertTo-SafeEntities.ps1]() - -[Invoke-WindowsPowerShell.ps1]() - diff --git a/docs/Disable-AnsiColor.ps1.md b/docs/Disable-AnsiColor.ps1.md deleted file mode 100644 index 26a2e698..00000000 --- a/docs/Disable-AnsiColor.ps1.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals -schema: 2.0.0 ---- - -# Disable-AnsiColor.ps1 - -## SYNOPSIS -Disables ANSI terminal colors. - -## SYNTAX - -``` -Disable-AnsiColor.ps1 [-HostOnly] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Disable-AnsiColor.ps1 -``` - -Disables ANSI terminal colors. - -## PARAMETERS - -### -HostOnly -Disable colors only for text redirected to files. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals) - diff --git a/docs/Enable-AnsiColor.ps1.md b/docs/Enable-AnsiColor.ps1.md deleted file mode 100644 index aae97a4f..00000000 --- a/docs/Enable-AnsiColor.ps1.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals -schema: 2.0.0 ---- - -# Enable-AnsiColor.ps1 - -## SYNOPSIS -Enables ANSI terminal colors. - -## SYNTAX - -``` -Enable-AnsiColor.ps1 [-HostOnly] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Enable-AnsiColor.ps1 -``` - -Enables ANSI terminal colors. - -## PARAMETERS - -### -HostOnly -Enable colors only for host console output. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_ansi_terminals) - diff --git a/docs/Expand-EnvironmentVariables.ps1.md b/docs/Expand-EnvironmentVariables.ps1.md deleted file mode 100644 index 1fec0af0..00000000 --- a/docs/Expand-EnvironmentVariables.ps1.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/dotnet/api/system.environment.expandenvironmentvariables -schema: 2.0.0 ---- - -# Expand-EnvironmentVariables.ps1 - -## SYNOPSIS -Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string. - -## SYNTAX - -``` -Expand-EnvironmentVariables.ps1 [-Value] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Expand-EnvironmentVariables.ps1 %SystemRoot%\System32\cmd.exe -``` - -C:\WINDOWS\System32\cmd.exe - -## PARAMETERS - -### -Value -{{ Fill Value Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/dotnet/api/system.environment.expandenvironmentvariables](https://docs.microsoft.com/dotnet/api/system.environment.expandenvironmentvariables) - diff --git a/docs/Export-MermaidXY.ps1.md b/docs/Export-MermaidXY.ps1.md deleted file mode 100644 index 03b71466..00000000 --- a/docs/Export-MermaidXY.ps1.md +++ /dev/null @@ -1,173 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://mermaid.js.org/syntax/xyChart.html -schema: 2.0.0 ---- - -# Export-MermaidXY.ps1 - -## SYNOPSIS -Generates a Mermaid XY bar/line chart for the values of a series of properties. - -## SYNTAX - -``` -Export-MermaidXY.ps1 [[-LabelProperty] ] [[-LineProperty] ] [[-BarProperty] ] - [[-Title] ] [[-XAxisLabel] ] [[-YAxisLabel] ] [[-InputObject] ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-Item Save-*.ps1 |Export-MermaidXY.ps1 -Title "Save scripts" -Units bytes -LabelProperty Name -BarProperty Length -``` - -xychart-beta -title "Save scripts" -x-axis "" \[Save-PodcastEpisodes.ps1, Save-Secret.ps1, Save-WebRequest.ps1\] -y-axis "bytes" 0 --\> 3239 -bar "Length" \[2754, 3239, 3112\] - -## PARAMETERS - -### -LabelProperty -The property to use as labels on the X axis. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -LineProperty -Properties to use to render a line graph. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: @() -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BarProperty -Properties to use to render a bar graph. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: @() -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Title -A title for the chart. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 4 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -XAxisLabel -The label for the X axis. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Domain, Progression - -Required: False -Position: 5 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -YAxisLabel -The label for the Y axis. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: Range, Units - -Required: False -Position: 6 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The objects with the specified properties. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: False -Position: 7 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Object with the properties requested. -## OUTPUTS - -### System.String containing Mermaid XY chart data. -## NOTES - -## RELATED LINKS - -[https://mermaid.js.org/syntax/xyChart.html](https://mermaid.js.org/syntax/xyChart.html) - diff --git a/docs/Export-OpenApiSchema.ps1.md b/docs/Export-OpenApiSchema.ps1.md deleted file mode 100644 index a8d1b2af..00000000 --- a/docs/Export-OpenApiSchema.ps1.md +++ /dev/null @@ -1,155 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://www.openapis.org/ -schema: 2.0.0 ---- - -# Export-OpenApiSchema.ps1 - -## SYNOPSIS -Extracts the JSON schema from an OpenAPI definition. - -## SYNTAX - -### ResponseStatus (Default) -``` -Export-OpenApiSchema.ps1 [[-Path] ] [[-Method] ] [[-EndpointPath] ] - [[-ResponseStatus] ] [-ProgressAction ] [] -``` - -### RequestSchema -``` -Export-OpenApiSchema.ps1 [[-Path] ] [[-Method] ] [[-EndpointPath] ] [-RequestSchema] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Export-OpenApiSchema.ps1 api.json -``` - -Returns the schema of the 200 response of any defined endpoint is returned. - -### EXAMPLE 2 -``` -Export-OpenApiSchema.ps1 api.json POST /hello -RequestSchema -``` - -Returns the schema of the request body of the POST /hello endpoint. - -## PARAMETERS - -### -Path -The path to the OpenAPI JSON file. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Method -The HTTP verb of the endpoint to extract the schema from. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: * -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -EndpointPath -The HTTP path of the endpoint to extract the schema from. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: ApiPath - -Required: False -Position: 3 -Default value: * -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -RequestSchema -Indicates that the request schema of the endpoint should be returned. - -```yaml -Type: SwitchParameter -Parameter Sets: RequestSchema -Aliases: In - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ResponseStatus -Indicates the HTTP status code of the response schema of the endpoint that should be returned. - -```yaml -Type: Int32 -Parameter Sets: ResponseStatus -Aliases: - -Required: False -Position: 4 -Default value: 200 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.String of the extracted JSON schema. -## NOTES - -## RELATED LINKS - -[https://www.openapis.org/](https://www.openapis.org/) - -[Export-Json.ps1]() - -[Set-Json.ps1]() - diff --git a/docs/Find-NewestFile.ps1.md b/docs/Find-NewestFile.ps1.md deleted file mode 100644 index 6e78a94a..00000000 --- a/docs/Find-NewestFile.ps1.md +++ /dev/null @@ -1,82 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Find-NewestFile.ps1 - -## SYNOPSIS -Finds the most recent file. - -## SYNTAX - -``` -Find-NewestFile.ps1 [[-Files] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -ls C:\java.exe -Recurse -ErrorAction Ignore |Find-NewestFile.ps1 -``` - -Directory: C:\Program Files (x86)\Minecraft\runtime\jre-x64\1.8.0_25\bin - - -Mode LastWriteTime Length Name ----- ------------- ------ ---- --a---- 2017-02-05 15:03 190888 java.exe - -## PARAMETERS - -### -Files -The list of files to search. - -```yaml -Type: FileInfo[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.IO.FileInfo[] a list of files to compare. -## OUTPUTS - -### System.IO.FileInfo representing the newest of the files compared. -## NOTES - -## RELATED LINKS - -[Test-NewerFile.ps1]() - diff --git a/docs/ForEach-Progress.ps1.md b/docs/ForEach-Progress.ps1.md deleted file mode 100644 index 56f48f96..00000000 --- a/docs/ForEach-Progress.ps1.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# ForEach-Progress.ps1 - -## SYNOPSIS -Performs an operation against each item in a collection of input objects, with a progress bar. - -## SYNTAX - -``` -ForEach-Progress.ps1 [[-Activity] ] [[-Status] ] [[-Process] ] - -InputObject [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -1..10 |ForEach-Progress.ps1 -Activity 'Testing' {"$_"} {Write-Host "item: $_"; sleep 2} -``` - -## PARAMETERS - -### -Activity -The progress title text to display. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Status -A script block to generate status text from each $PSItem ($_). - -```yaml -Type: ScriptBlock -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Process -A script block to execute for each $PSItem ($_). - -```yaml -Type: ScriptBlock -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -An item to process. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Management.Automation.PSObject to process. -## OUTPUTS - -## NOTES - -## RELATED LINKS diff --git a/docs/Format-ByteUnits.ps1.md b/docs/Format-ByteUnits.ps1.md deleted file mode 100644 index a6839d64..00000000 --- a/docs/Format-ByteUnits.ps1.md +++ /dev/null @@ -1,125 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: http://en.wikipedia.org/wiki/Binary_prefix -schema: 2.0.0 ---- - -# Format-ByteUnits.ps1 - -## SYNOPSIS -Converts bytes to largest possible units, to improve readability. - -## SYNTAX - -``` -Format-ByteUnits.ps1 [-Bytes] [-Precision ] [-UseSI] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Format-ByteUnits 65536 -64KB -``` - -### EXAMPLE 2 -``` -Format-ByteUnits 9685059 -dot 1 -si -9.2 MiB -``` - -### EXAMPLE 3 -``` -ls *.log |measure -sum Length |select -exp Sum |Format-ByteUnits -dot 2 -si -302.39 MiB -``` - -## PARAMETERS - -### -Bytes -The number of bytes to express in larger units. - -```yaml -Type: BigInteger -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Precision -The maximum number of digits after the decimal to keep. -The default is 16 (the maximum). - -```yaml -Type: Byte -Parameter Sets: (All) -Aliases: Digits, dot - -Required: False -Position: Named -Default value: 16 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UseSI -Displays unambiguous SI units (with a space). -By default, native PowerShell units are used -(without a space, to allow round-tripping the value, -though there may be significant rounding loss depending on precision). - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: si - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Numerics.BigInteger representing a number of bytes. -## OUTPUTS - -### System.String containing the number of bytes scaled to fit the appropriate units. -## NOTES - -## RELATED LINKS - -[http://en.wikipedia.org/wiki/Binary_prefix](http://en.wikipedia.org/wiki/Binary_prefix) - -[http://physics.nist.gov/cuu/Units/binary.html](http://physics.nist.gov/cuu/Units/binary.html) - diff --git a/docs/Format-Date.ps1.md b/docs/Format-Date.ps1.md deleted file mode 100644 index 4711fa53..00000000 --- a/docs/Format-Date.ps1.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Format-Date.ps1 - -## SYNOPSIS -Returns a date/time as a named format. - -## SYNTAX - -``` -Format-Date.ps1 [-Format] [[-Date] ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Format-Date Iso8601WeekDate 2021-01-20 -``` - -2021-W03-3 - -### EXAMPLE 2 -``` -'Feb 2, 2020 8:20 PM +00:00' |Format-Date Iso8601Z -``` - -2020-02-02T20:20:00Z - -## PARAMETERS - -### -Format -The format to serialize the date as. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Date -The date/time value to format. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: (Get-Date) -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.String -## NOTES - -## RELATED LINKS - -[Get-Date]() - diff --git a/docs/Format-EscapedUrl.ps1.md b/docs/Format-EscapedUrl.ps1.md deleted file mode 100644 index 83c819cd..00000000 --- a/docs/Format-EscapedUrl.ps1.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Format-EscapedUrl.ps1 - -## SYNOPSIS -Escape URLs more aggressively. - -## SYNTAX - -### Uri -``` -Format-EscapedUrl.ps1 [-Uri] [-ProgressAction ] [] -``` - -### Clipboard -``` -Format-EscapedUrl.ps1 [-Clipboard] [-ProgressAction ] [] -``` - -## DESCRIPTION -Some characters such as apostrophes and parentheses are legal for URLs, -but are a hassle within certain formats (Markdown, JSON, SQL, &c). - -This script URL-escapes these characters to %xx format. - -## EXAMPLES - -### EXAMPLE 1 -``` -Format-EscapedUrl.ps1 -Clipboard -``` - -Updates the URL on the clipboard with a more aggressively escaped version. - -### EXAMPLE 2 -``` -Format-EscapedUrl.ps1 "https://example.com/search(en-US)?q=Name%20%3D%20'System'&sort=y" -``` - -https://example.com/search%28en-US%29?q=Name%20%3D%20%27System%27&sort=y - -## PARAMETERS - -### -Uri -The URL to format for maximum compatibility. - -```yaml -Type: Uri[] -Parameter Sets: Uri -Aliases: Url - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Clipboard -Indicates that the URL comes from the clipboard, and is updated on the clipboard. - -```yaml -Type: SwitchParameter -Parameter Sets: Clipboard -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Uri to escape. -## OUTPUTS - -### System.String containing the URL escaped for maximum compatibility. -## NOTES - -## RELATED LINKS diff --git a/docs/Format-HtmlDataTable.ps1.md b/docs/Format-HtmlDataTable.ps1.md deleted file mode 100644 index ab44b962..00000000 --- a/docs/Format-HtmlDataTable.ps1.md +++ /dev/null @@ -1,180 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Format-HtmlDataTable.ps1 - -## SYNOPSIS -Right-aligns numeric data in an HTML table for emailing, and optionally zebra-stripes &c. - -## SYNTAX - -``` -Format-HtmlDataTable.ps1 [[-Caption] ] [[-OddRowBackground] ] [[-EvenRowBackground] ] - [-TableAttributes ] [-CaptionAttributes ] [-NumericFormat ] [-Html ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Invoke-Sqlcmd "..." |ConvertFrom-DataRow.ps1 |ConvertTo-Html |Format-HtmlDataTable.ps1 -``` - -Runs the query, parses each row into an HTML row, then fixes the alignment of numeric cells. - -### EXAMPLE 2 -``` -$rows |ConvertTo-Html -Fragment |Format-HtmlDataTable.ps1 'Products' '#F99' '#FFF' -``` - -Renders DataRows as an HTML table, right-aligns numeric cells, then adds a caption ("Products"), -and alternates the rows between pale yellow and white. - -## PARAMETERS - -### -Caption -{{ Fill Caption Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -OddRowBackground -The background CSS value for odd rows. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -EvenRowBackground -The background CSS value for even rows. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -TableAttributes -Any table attributes desired (cellpadding, cellspacing, style, &c.). - -```yaml -Type: String -Parameter Sets: (All) -Aliases: TableAtts - -Required: False -Position: Named -Default value: Cellpadding="2" cellspacing="0" style="font:x-small 'Lucida Console',monospace" -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -CaptionAttributes -{{ Fill CaptionAttributes Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: CaptionAtts, CapAtts - -Required: False -Position: Named -Default value: Style="font:bold small serif;border:1px inset #DDD;padding:1ex 0;background:#FFF" -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -NumericFormat -Applies a standard .NET formatting pattern to numbers, such as N or '#,##0.000;(#,##0.000);zero'. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Html -The HTML table data to be piped in. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String containing an HTML table, as produced by ConvertTo-Html. -## OUTPUTS - -### System.String containing the data-formatted HTML table. -## NOTES -Assumes only one \ element per string piped in, as produced by ConvertTo-Html. - -## RELATED LINKS - -[ConvertTo-Html]() - -[https://www.w3.org/Bugs/Public/show_bug.cgi?id=18026](https://www.w3.org/Bugs/Public/show_bug.cgi?id=18026) - diff --git a/docs/Format-Permutations.ps1.md b/docs/Format-Permutations.ps1.md deleted file mode 100644 index dc951a98..00000000 --- a/docs/Format-Permutations.ps1.md +++ /dev/null @@ -1,108 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://social.technet.microsoft.com/wiki/contents/articles/7855.powershell-using-the-f-format-operator.aspx -schema: 2.0.0 ---- - -# Format-Permutations.ps1 - -## SYNOPSIS -Builds format strings using every combination of elements from multiple arrays. - -## SYNTAX - -``` -Format-Permutations.ps1 [-Format] [-InputObject] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Format-Permutations.ps1 'srv-{0}-{1:00}' 'dev','test','stage','live' (1..4) -``` - -srv-dev-01 - srv-dev-02 - srv-dev-03 - srv-dev-04 - srv-test-01 - srv-test-02 - srv-test-03 - srv-test-04 - srv-stage-01 - srv-stage-02 - srv-stage-03 - srv-stage-04 - srv-live-01 - srv-live-02 - srv-live-03 - srv-live-04 - -## PARAMETERS - -### -Format -A standard .NET format string as used with the PowerShell -f operator. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -A list of lists to put together in all combinations (a Cartesian cross-product) and -format with the supplied format string. - -```yaml -Type: Object[][] -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.String list of all combinations -## NOTES - -## RELATED LINKS - -[https://social.technet.microsoft.com/wiki/contents/articles/7855.powershell-using-the-f-format-operator.aspx](https://social.technet.microsoft.com/wiki/contents/articles/7855.powershell-using-the-f-format-operator.aspx) - diff --git a/docs/Get-CommandParameters.ps1.md b/docs/Get-CommandParameters.ps1.md deleted file mode 100644 index 9aaa1768..00000000 --- a/docs/Get-CommandParameters.ps1.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Get-CommandParameters.ps1 - -## SYNOPSIS -Returns the parameters of the specified cmdlet. - -## SYNTAX - -``` -Get-CommandParameters.ps1 [-CommandName] [-ParameterSet ] [-NamesOnly] [-IncludeCommon] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-CommandParameters.ps1 Write-Verbose -``` - -Name : Message -ParameterType : System.String -ParameterSets : {\[__AllParameterSets, System.Management.Automation.ParameterSetMetadata\]} -IsDynamic : False -Aliases : {Msg} -Attributes : {, System.Management.Automation.AllowEmptyStringAttribute, System.Management.Automation.AliasAttribute} -SwitchParameter : False - -### EXAMPLE 2 -``` -Get-CommandParameters.ps1 Out-Default -NamesOnly -``` - -Transcript -InputObject - -## PARAMETERS - -### -CommandName -The name of a cmdlet. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ParameterSet -The name of a parameter set defined by the cmdlet. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -NamesOnly -Return only the parameter names (otherwise) - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IncludeCommon -Includes common parameters such as -Verbose and -WhatIf. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.String -## NOTES - -## RELATED LINKS - -[Stop-ThrowError.ps1]() - -[Get-Command]() - diff --git a/docs/Get-CommandPath.ps1.md b/docs/Get-CommandPath.ps1.md deleted file mode 100644 index acab56fa..00000000 --- a/docs/Get-CommandPath.ps1.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Get-CommandPath.ps1 - -## SYNOPSIS -Locates a command. - -## SYNTAX - -``` -Get-CommandPath.ps1 [-ApplicationName] [-FindAllInPath] [-ProgressAction ] - [] -``` - -## DESCRIPTION -Returns the full path to an application found in a directory in $env:Path, -optionally with an extension from $env:PathExt. - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-CommandPath.ps1 powershell -``` - -C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe - -## PARAMETERS - -### -ApplicationName -The name of the executable program to look for in the $env:Path directories, -if the extension is omitted, $env:PathExt will be used to find one. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: Name, AN - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -FindAllInPath -Indicates that every directory in the Path should be searched for the command. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String of commands to get the location details of. -## OUTPUTS - -### System.String of location details for the specified commands that were found. -## NOTES - -## RELATED LINKS - -[Get-Command]() - diff --git a/docs/Get-ConsoleHistory.ps1.md b/docs/Get-ConsoleHistory.ps1.md deleted file mode 100644 index 006d15ac..00000000 --- a/docs/Get-ConsoleHistory.ps1.md +++ /dev/null @@ -1,139 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# Get-ConsoleHistory.ps1 - -## SYNOPSIS -Returns the DOSKey-style console command history (up arrow or F8). - -## SYNTAX - -### Id -``` -Get-ConsoleHistory.ps1 -Id [-ProgressAction ] [] -``` - -### Like -``` -Get-ConsoleHistory.ps1 -Like [-ProgressAction ] [] -``` - -### Match -``` -Get-ConsoleHistory.ps1 -Match [-ProgressAction ] [] -``` - -### All -``` -Get-ConsoleHistory.ps1 [-All] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-ConsoleHistory.ps1 |where CommandLine -like *readme* -``` - -Id CommandLine --- ----------- -30 gc .\README.md -56 gc .\README.md - -## PARAMETERS - -### -Id -{{ Fill Id Description }} - -```yaml -Type: Int32 -Parameter Sets: Id -Aliases: - -Required: True -Position: Named -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Like -{{ Fill Like Description }} - -```yaml -Type: String -Parameter Sets: Like -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Match -{{ Fill Match Description }} - -```yaml -Type: String -Parameter Sets: Match -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -All -{{ Fill All Description }} - -```yaml -Type: SwitchParameter -Parameter Sets: All -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Management.Automation.PSObject with these properties: -### * Id: The position of the command in the console history. -### * CommandLine: The command entered in the history. -## NOTES - -## RELATED LINKS diff --git a/docs/Get-EnumValues.ps1.md b/docs/Get-EnumValues.ps1.md deleted file mode 100644 index 070e95f1..00000000 --- a/docs/Get-EnumValues.ps1.md +++ /dev/null @@ -1,146 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Get-EnumValues.ps1 - -## SYNOPSIS -Returns the possible values of the specified enumeration. - -## SYNTAX - -``` -Get-EnumValues.ps1 [-Type] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-EnumValues Management.Automation.ActionPreference -``` - -Value Name ------ ---- - 0 SilentlyContinue - 1 Stop - 2 Continue - 3 Inquire - 4 Ignore - 5 Suspend - -### EXAMPLE 2 -``` -Get-EnumValues ConsoleColor -``` - -Value Name ------ ---- - 0 Black - 1 DarkBlue - 2 DarkGreen - 3 DarkCyan - 4 DarkRed - 5 DarkMagenta - 6 DarkYellow - 7 Gray - 8 DarkGray - 9 Blue - 10 Green - 11 Cyan - 12 Red - 13 Magenta - 14 Yellow - 15 White - -### EXAMPLE 3 -``` -Get-EnumValues.ps1 System.Web.Security.AntiXss.MidCodeCharts -``` - -· Value Name - ----- ---- - 0 None - 1 GreekExtended - 2 GeneralPunctuation - 4 SuperscriptsAndSubscripts - 8 CurrencySymbols - 16 CombiningDiacriticalMarksForSymbols - 32 LetterlikeSymbols - 64 NumberForms - 128 Arrows - 256 MathematicalOperators - 512 MiscellaneousTechnical - 1024 ControlPictures - 2048 OpticalCharacterRecognition - 4096 EnclosedAlphanumerics - 8192 BoxDrawing - 16384 EthiopicExtended - 16384 EthiopicExtended - 32768 GeometricShapes - 65536 MiscellaneousSymbols - 131072 Dingbats - 262144 MiscellaneousMathematicalSymbolsA - 524288 SupplementalArrowsA - 1048576 BraillePatterns - 2097152 SupplementalArrowsB - 4194304 MiscellaneousMathematicalSymbolsB - 8388608 SupplementalMathematicalOperators - 16777216 MiscellaneousSymbolsAndArrows - 33554432 Glagolitic - 67108864 LatinExtendedC -134217728 Coptic -268435456 GeorgianSupplement -536870912 Tifinagh - -## PARAMETERS - -### -Type -The enumeration type name. - -```yaml -Type: Type -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Type of an Enum to get the values for. -## OUTPUTS - -### System.Management.Automation.PSCustomObject with the Value and Name for each defined -### value of the Enum. -## NOTES - -## RELATED LINKS diff --git a/docs/Get-FrenchRepublicanDate.ps1.md b/docs/Get-FrenchRepublicanDate.ps1.md deleted file mode 100644 index 9a891b57..00000000 --- a/docs/Get-FrenchRepublicanDate.ps1.md +++ /dev/null @@ -1,137 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://wikipedia.org/wiki/French_Republican_calendar -schema: 2.0.0 ---- - -# Get-FrenchRepublicanDate.ps1 - -## SYNOPSIS -Returns a date and time converted to the French Republican Calendar. - -## SYNTAX - -``` -Get-FrenchRepublicanDate.ps1 [[-Date] ] [-Method ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-FrenchRepublicanDate.ps1 2020-07-08 -``` - -Year : 228 -Annee : CCXXVIII -AnneeUnicode : ⅭⅭⅩⅩⅧ -Month : 10 -MonthName : Harvest -Mois : Messidor -Day : 21 -DayOfYear : 291 -Jour : Menthe -DayName : Mint -Decade : 30 -DayOfDecade : 1 -DecadeOrdinal : Primidi -DecimalTime : 0:00:00 -GregorianDate : 2020-07-08 00:00:00 - -## PARAMETERS - -### -Date -The Gregorian calendar date and time to convert. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: (Get-Date) -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Method -Which method to use to calculate leap years, of the competing choices. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: 128Year -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.DateTime containing the Gregorian date and time to convert. -## OUTPUTS - -### System.Management.Automation.PSCustomObject containing a French Republican Calendar -### date and time in these properties: -### * Year: the numeric year -### * Annee: the Roman numeral year -### * AnneeUnicode: the Unicode Roman numeral year -### * Month: the numeric month -### * MonthName: the English month name -### * Mois: the French month name -### * Day: the numeric day of the month -### * DayOfYear: the numeric day of the year -### * Jour: the French name of the day of the year -### * DayName: the English name of the day of the year -### * Decade: the number of the 10-day "week" of the year -### * DayOfDecade: the numeric day of the 10-day "week" -### * DecadeOrdinal: the name of the day of the 10-day "week" -### * DecimalTime: the decimal time (10 hours/day, 100 minutes/hour, 100 seconds/minute) -### * GregorianDate: the original Gregorian date, as provided -## NOTES - -## RELATED LINKS - -[https://wikipedia.org/wiki/French_Republican_calendar](https://wikipedia.org/wiki/French_Republican_calendar) - -[https://wikipedia.org/wiki/Equinox](https://wikipedia.org/wiki/Equinox) - -[https://www.timeanddate.com/calendar/seasons.html](https://www.timeanddate.com/calendar/seasons.html) - -[https://www.projectpluto.com/calendar.htm](https://www.projectpluto.com/calendar.htm) - -[https://github.com/Bill-Gray/lunar/blob/master/date.cpp#L340](https://github.com/Bill-Gray/lunar/blob/master/date.cpp#L340) - -[http://rosettacode.org/wiki/French_Republican_calendar](http://rosettacode.org/wiki/French_Republican_calendar) - -[http://www.windhorst.org/calendar/](http://www.windhorst.org/calendar/) - -[Stop-ThrowError.ps1]() - diff --git a/docs/Get-ModuleScope.ps1.md b/docs/Get-ModuleScope.ps1.md deleted file mode 100644 index 10a4288f..00000000 --- a/docs/Get-ModuleScope.ps1.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Get-ModuleScope.ps1 - -## SYNOPSIS -Returns the scope of an installed module. - -## SYNTAX - -``` -Get-ModuleScope.ps1 [[-Name] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-ModuleScope.ps1 Detextive -``` - -ModuleName Scope ----------- ----- -Detextive CurrentUser - -### EXAMPLE 2 -``` -Get-ModuleScope.ps1 Pester -``` - -ModuleName Scope ----------- ----- -Pester CurrentUser -Pester AllUsers - -## PARAMETERS - -### -Name -Specifies names or name patterns of modules that this cmdlet gets. -Wildcard characters are permitted. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: ModuleName - -Required: False -Position: 1 -Default value: * -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Object with a "Name" or "ModuleName" property containing a module name. -## OUTPUTS - -### System.Management.Automation.PSObject with the following properties: -### * ModuleName: The name of the module. -### * Scope: The value "CurrentUser" if the module is found within $HOME\Documents\PowerShell\Modules, "AllUsers" if found anywhere else. -## NOTES - -## RELATED LINKS diff --git a/docs/Get-RandomBytes.ps1.md b/docs/Get-RandomBytes.ps1.md deleted file mode 100644 index c71cd342..00000000 --- a/docs/Get-RandomBytes.ps1.md +++ /dev/null @@ -1,83 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/dotnet/api/system.security.cryptography.rngcryptoserviceprovider -schema: 2.0.0 ---- - -# Get-RandomBytes.ps1 - -## SYNOPSIS -Returns random bytes. - -## SYNTAX - -``` -Get-RandomBytes.ps1 [-Count] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-RandomBytes.ps1 8 -``` - -103 -235 -194 -199 -151 -83 -240 -152 - -## PARAMETERS - -### -Count -The number of random bytes to return. - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Byte[] of random bytes. -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/dotnet/api/system.security.cryptography.rngcryptoserviceprovider](https://docs.microsoft.com/dotnet/api/system.security.cryptography.rngcryptoserviceprovider) - diff --git a/docs/Get-SecretDetails.ps1.md b/docs/Get-SecretDetails.ps1.md index f6592518..9cf9a142 100644 --- a/docs/Get-SecretDetails.ps1.md +++ b/docs/Get-SecretDetails.ps1.md @@ -13,8 +13,7 @@ Returns secret info from the secret vaults, including metadata as properties. ## SYNTAX ``` -Get-SecretDetails.ps1 [-ProgressAction ] [-Name ] [-Vault ] - [] +Get-SecretDetails.ps1 [-ProgressAction ] [] ``` ## DESCRIPTION @@ -39,21 +38,6 @@ Expires : 2036-01-01 00:00:00 ## PARAMETERS -### -Name -{{ Fill Name Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -ProgressAction {{ Fill ProgressAction Description }} @@ -69,21 +53,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Vault -{{ Fill Vault Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/docs/Get-TypeAccelerators.ps1.md b/docs/Get-TypeAccelerators.ps1.md deleted file mode 100644 index 7f184440..00000000 --- a/docs/Get-TypeAccelerators.ps1.md +++ /dev/null @@ -1,167 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Get-TypeAccelerators.ps1 - -## SYNOPSIS -Returns the list of PowerShell type accelerators. - -## SYNTAX - -``` -Get-TypeAccelerators.ps1 [[-DictionaryKey] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-TypeAccelerators.ps1 -``` - -Key Value ---- ----- -Alias System.Management.Automation.AliasAttribute -AllowEmptyCollection System.Management.Automation.AllowEmptyCollectionAttribute -AllowEmptyString System.Management.Automation.AllowEmptyStringAttribute -AllowNull System.Management.Automation.AllowNullAttribute -ArgumentCompleter System.Management.Automation.ArgumentCompleterAttribute -array System.Array -bool System.Boolean -byte System.Byte -char System.Char -CmdletBinding System.Management.Automation.CmdletBindingAttribute -datetime System.DateTime -decimal System.Decimal -double System.Double -DscResource System.Management.Automation.DscResourceAttribute -float System.Single -single System.Single -guid System.Guid -hashtable System.Collections.Hashtable -int System.Int32 -int32 System.Int32 -int16 System.Int16 -long System.Int64 -int64 System.Int64 -ciminstance Microsoft.Management.Infrastructure.CimInstance -cimclass Microsoft.Management.Infrastructure.CimClass -cimtype Microsoft.Management.Infrastructure.CimType -cimconverter Microsoft.Management.Infrastructure.CimConverter -IPEndpoint System.Net.IPEndPoint -NullString System.Management.Automation.Language.NullString -OutputType System.Management.Automation.OutputTypeAttribute -ObjectSecurity System.Security.AccessControl.ObjectSecurity -Parameter System.Management.Automation.ParameterAttribute -PhysicalAddress System.Net.NetworkInformation.PhysicalAddress -pscredential System.Management.Automation.PSCredential -PSDefaultValue System.Management.Automation.PSDefaultValueAttribute -pslistmodifier System.Management.Automation.PSListModifier -psobject System.Management.Automation.PSObject -pscustomobject System.Management.Automation.PSObject -psprimitivedictionary System.Management.Automation.PSPrimitiveDictionary -ref System.Management.Automation.PSReference -PSTypeNameAttribute System.Management.Automation.PSTypeNameAttribute -regex System.Text.RegularExpressions.Regex -DscProperty System.Management.Automation.DscPropertyAttribute -sbyte System.SByte -string System.String -SupportsWildcards System.Management.Automation.SupportsWildcardsAttribute -switch System.Management.Automation.SwitchParameter -cultureinfo System.Globalization.CultureInfo -bigint System.Numerics.BigInteger -securestring System.Security.SecureString -timespan System.TimeSpan -uint16 System.UInt16 -uint32 System.UInt32 -uint64 System.UInt64 -uri System.Uri -ValidateCount System.Management.Automation.ValidateCountAttribute -ValidateDrive System.Management.Automation.ValidateDriveAttribute -ValidateLength System.Management.Automation.ValidateLengthAttribute -ValidateNotNull System.Management.Automation.ValidateNotNullAttribute -ValidateNotNullOrEmpty System.Management.Automation.ValidateNotNullOrEmptyAttribute -ValidatePattern System.Management.Automation.ValidatePatternAttribute -ValidateRange System.Management.Automation.ValidateRangeAttribute -ValidateScript System.Management.Automation.ValidateScriptAttribute -ValidateSet System.Management.Automation.ValidateSetAttribute -ValidateUserDrive System.Management.Automation.ValidateUserDriveAttribute -version System.Version -void System.Void -ipaddress System.Net.IPAddress -DscLocalConfigurationManager System.Management.Automation.DscLocalConfigurationManagerAttribute -WildcardPattern System.Management.Automation.WildcardPattern -X509Certificate System.Security.Cryptography.X509Certificates.X509Certificate -X500DistinguishedName System.Security.Cryptography.X509Certificates.X500DistinguishedName -xml System.Xml.XmlDocument -CimSession Microsoft.Management.Infrastructure.CimSession -adsi System.DirectoryServices.DirectoryEntry -adsisearcher System.DirectoryServices.DirectorySearcher -wmiclass System.Management.ManagementClass -wmi System.Management.ManagementObject -wmisearcher System.Management.ManagementObjectSearcher -mailaddress System.Net.Mail.MailAddress -scriptblock System.Management.Automation.ScriptBlock -psvariable System.Management.Automation.PSVariable -type System.Type -psmoduleinfo System.Management.Automation.PSModuleInfo -powershell System.Management.Automation.PowerShell -runspacefactory System.Management.Automation.Runspaces.RunspaceFactory -runspace System.Management.Automation.Runspaces.Runspace -initialsessionstate System.Management.Automation.Runspaces.InitialSessionState -psscriptmethod System.Management.Automation.PSScriptMethod -psscriptproperty System.Management.Automation.PSScriptProperty -psnoteproperty System.Management.Automation.PSNoteProperty -psaliasproperty System.Management.Automation.PSAliasProperty -psvariableproperty System.Management.Automation.PSVariableProperty - -## PARAMETERS - -### -DictionaryKey -{{ Fill DictionaryKey Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### Collections.Generic.Dictionary[string,type] -## NOTES - -## RELATED LINKS diff --git a/docs/Import-ClipboardTsv.ps1.md b/docs/Import-ClipboardTsv.ps1.md deleted file mode 100644 index ae1b3b2c..00000000 --- a/docs/Import-ClipboardTsv.ps1.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Import-ClipboardTsv.ps1 - -## SYNOPSIS -Parses TSV clipboard data into objects. - -## SYNTAX - -``` -Import-ClipboardTsv.ps1 [[-Delimiter] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Import-ClipboardTsv.ps1 |Format-Table -AutoSize -``` - -Name Alias Actor ----- ----- ----- -Rita Farr Elasti-Girl April Bowlby -Larry Trainor Negative Man Matt Bomer/Mathew Zuk -Kay Challis Crazy Jane Diane Guerrero -Cliff Steele Robotman Brendan Fraser/Riley Shanahan -Victor Stone Cyborg Joivan Wade -Dr. -Niles Caulder The Chief Timothy Dalton -Eric Morden Mr. -Nobody Alan Tudyk - -## PARAMETERS - -### -Delimiter -The field separator character. - -```yaml -Type: Char -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[Get-Clipboard]() - -[ConvertFrom-Csv]() - diff --git a/docs/Import-Variables.ps1.md b/docs/Import-Variables.ps1.md deleted file mode 100644 index 0b278923..00000000 --- a/docs/Import-Variables.ps1.md +++ /dev/null @@ -1,149 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Import-Variables.ps1 - -## SYNOPSIS -Creates local variables from a data row or dictionary (hashtable). - -## SYNTAX - -``` -Import-Variables.ps1 [-InputObject] [-MemberType ] [-Scope ] [-Private] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -[^"]+)"\)') {Import-Variables.ps1 $Matches} -``` - -Copies $Matches.TypeGuid to $TypeGuid if a match is found. - -### EXAMPLE 2 -``` -Invoke-Sqlcmd "select ProductID, Name, ListPrice from Production.Product where ProductID = 1;" -Server 'Server\instance' -Database AdventureWorks |Import-Variables.ps1 -``` - -Copies field values into $ProductID, $Name, and $ListPrice. - -### EXAMPLE 3 -``` -.*?\\)(?[^\\]+$)'){Import-Variables.ps1 $Matches -Verbose} -``` - -Sets $ComPath and $ComExe from the regex captures if the regex matches. - -### EXAMPLE 4 -``` -Invoke-RestMethod https://api.github.com/ |Import-Variables.ps1 ; Invoke-RestMethod $emojis_url -``` - -Sets variables from the fields returned by the web service: $current_user_url, $emojis_url, &c. -Then fetches the list of GitHub emojis. - -## PARAMETERS - -### -InputObject -A hash of string names to any values to set as variables, -or a DataRow or object with properties to set as variables. -Works with DataRows. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -MemberType -The type of object members to convert to variables. - -```yaml -Type: PSMemberTypes -Parameter Sets: (All) -Aliases: Type -Accepted values: AliasProperty, CodeProperty, Property, NoteProperty, ScriptProperty, PropertySet, Method, CodeMethod, ScriptMethod, Methods, ParameterizedProperty, MemberSet, Event, Dynamic, InferredProperty, Properties, All - -Required: False -Position: Named -Default value: Properties -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Scope -The scope of the variables to create. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: Local -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Private -Indicates that created variables should be hidden from child scopes. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Collections.IDictionary with keys and values to import as variables, -### or System.Management.Automation.PSCustomObject with properties to import as variables. -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS - -[Add-ScopeLevel.ps1]() - diff --git a/docs/Invoke-CachedCommand.ps1.md b/docs/Invoke-CachedCommand.ps1.md deleted file mode 100644 index 8db5a46c..00000000 --- a/docs/Invoke-CachedCommand.ps1.md +++ /dev/null @@ -1,146 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Invoke-CachedCommand.ps1 - -## SYNOPSIS -Caches the output of a command for recall if called again. - -## SYNTAX - -### ExpiresAfter -``` -Invoke-CachedCommand.ps1 [-Expression] [[-BlockArgs] ] [-ExpiresAfter ] - [-ProgressAction ] [] -``` - -### Expires -``` -Invoke-CachedCommand.ps1 [-Expression] [[-BlockArgs] ] [-Expires ] - [-ProgressAction ] [] -``` - -### Session -``` -Invoke-CachedCommand.ps1 [-Expression] [[-BlockArgs] ] [-Session] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Invoke-CachedCommand.ps1 {Invoke-RestMethod https://example.org/endpoint} -Session -``` - -Returns the result of executing the script block, or the previous cached output if available. - -## PARAMETERS - -### -Expression -Specifies the expression to cache the output of. - -```yaml -Type: ScriptBlock -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BlockArgs -Parameters to the script block. - -```yaml -Type: PSObject[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: @() -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ExpiresAfter -The rolling duration to cache the output for (updated with each call). - -```yaml -Type: TimeSpan -Parameter Sets: ExpiresAfter -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Expires -Point in time to cache the output until. - -```yaml -Type: DateTime -Parameter Sets: Expires -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Session -Caches the output for this session. - -```yaml -Type: SwitchParameter -Parameter Sets: Session -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS diff --git a/docs/Invoke-WindowsPowerShell.ps1.md b/docs/Invoke-WindowsPowerShell.ps1.md deleted file mode 100644 index 8b7b18cf..00000000 --- a/docs/Invoke-WindowsPowerShell.ps1.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Invoke-WindowsPowerShell.ps1 - -## SYNOPSIS -Runs commands in Windows PowerShell (typically from PowerShell Core). - -## SYNTAX - -### CommandBlock -``` -Invoke-WindowsPowerShell.ps1 [-CommandBlock] [[-BlockArgs] ] - [-ProgressAction ] [] -``` - -### CommandText -``` -Invoke-WindowsPowerShell.ps1 [-CommandText] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Invoke-WindowsPowerShell.ps1 '$PSVersionTable.PSEdition' -``` - -Desktop - -### EXAMPLE 2 -``` -Invoke-WindowsPowerShell.ps1 {Param($n); Get-WmiObject Win32_Process -Filter "Name like '$n'" |foreach ProcessName} power% -``` - -PowerToys.exe -PowerToys.Awake.exe -PowerToys.FancyZones.exe -PowerToys.KeyboardManagerEngine.exe -PowerLauncher.exe -powershell.exe -powershell.exe - -## PARAMETERS - -### -CommandBlock -A script block to run. - -```yaml -Type: ScriptBlock -Parameter Sets: CommandBlock -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BlockArgs -Parameters to the script block. - -```yaml -Type: PSObject[] -Parameter Sets: CommandBlock -Aliases: - -Required: False -Position: 2 -Default value: @() -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -CommandText -The text of the command to run. - -```yaml -Type: String -Parameter Sets: CommandText -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[Use-Command.ps1]() - -[ConvertTo-Base64.ps1]() - -[Stop-ThrowError.ps1]() - diff --git a/docs/Join-Keys.ps1.md b/docs/Join-Keys.ps1.md deleted file mode 100644 index 3d38c856..00000000 --- a/docs/Join-Keys.ps1.md +++ /dev/null @@ -1,153 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# Join-Keys.ps1 - -## SYNOPSIS -Combines dictionaries together into a single dictionary. - -## SYNTAX - -``` -Join-Keys.ps1 [[-ReferenceObject] ] [-InputObject] [-Accumulate] [-Force] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Join-Keys.ps1 @{a=1;b=2} @{b=0;c=3} -``` - -Name Value ----- ----- -b 2 -c 3 -a 1 - -### EXAMPLE 2 -``` -@{b=0;c=3},@{c=4;d=5} |Join-Keys.ps1 @{a=1;b=2} -Force |foreach {$_ |ConvertTo-Json -Compress} -``` - -{"c":3,"b":0,"a":1} -{"d":5,"b":2,"c":4,"a":1} - -### EXAMPLE 3 -``` -@{b=0;c=3},@{c=4;d=5} |Join-Keys.ps1 @{a=1;b=2} -Force -Accumulate |foreach {$_ |ConvertTo-Json -Compress} -``` - -{"c":3,"b":0,"a":1} -{"c":4,"b":0,"d":5,"a":1} - -### EXAMPLE 4 -``` -@{b=0;c=3},@{c=4;d=5} |Join-Keys.ps1 -Accumulate |select -Last 1 -``` - -Name Value ----- ----- -c 3 -b 0 -d 5 - -## PARAMETERS - -### -ReferenceObject -Initial dictionary value to combine. - -```yaml -Type: IDictionary -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: @{} -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -Hashtables or other dictionaries to combine. - -```yaml -Type: IDictionary -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Accumulate -Indicates that the ReferenceObject should be updated with each input dictionary, -rather than the default behavior of combining the original ReferenceObject with each. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Force -For matching keys, overwrites old values with new ones. -By default, only new keys are added. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Collections.IDictionary to combine. -## OUTPUTS - -### System.Collections.IDictionary combining the inputs. -## NOTES - -## RELATED LINKS diff --git a/docs/Limit-Digits.ps1.md b/docs/Limit-Digits.ps1.md deleted file mode 100644 index f9533b44..00000000 --- a/docs/Limit-Digits.ps1.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# Limit-Digits.ps1 - -## SYNOPSIS -Rounds off a number to the requested number of digits. - -## SYNTAX - -``` -Limit-Digits.ps1 [[-Digits] ] [-InputObject] [-Mode ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -[math]::PI |Limit-Digits.ps1 4 -``` - -3.1416 - -### EXAMPLE 2 -``` -1.5 |Limit-Digits.ps1 -Mode ToZero -``` - -1 - -## PARAMETERS - -### -Digits -The number of digits following the decimal to truncate the value to. - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -A numeric value to round off. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Mode -The rounding methodology to use. - -```yaml -Type: MidpointRounding -Parameter Sets: (All) -Aliases: -Accepted values: ToEven, AwayFromZero, ToZero, ToNegativeInfinity, ToPositiveInfinity - -Required: False -Position: Named -Default value: ToEven -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Decimal or System.Double or other numeric type that is implicitly convertible -### to those types. -## OUTPUTS - -### System.Decimal or System.Double depending on input type. -## NOTES - -## RELATED LINKS diff --git a/docs/Measure-Properties.ps1.md b/docs/Measure-Properties.ps1.md deleted file mode 100644 index 73b86a83..00000000 --- a/docs/Measure-Properties.ps1.md +++ /dev/null @@ -1,97 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Measure-Properties.ps1 - -## SYNOPSIS -Provides frequency details about the properties across objects in the pipeline. - -## SYNTAX - -``` -Measure-Properties.ps1 [[-InputObject] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Get-PSDrive |Measure-Properties.ps1 |Format-Table -AutoSize -``` - -Type: System.Management.Automation.PSDriveInfo -Count: 13 - -PropertyName Type Unique Nulls Values Minimum Maximum ------------- ---- ------ ----- ------ ------- ------- -Used System.Object False 12 1 219129761792.00 219129761792.00 -Free System.Object False 12 1 803764846592.00 803764846592.00 -CurrentLocation System.String False 11 2 Users\brian -Name System.String True 0 13 A WSMan -Root System.String False 4 9 \ SQLSERVER:\ -Description System.String False 1 12 X509 Certificate Provider -VolumeSeparatedByColon System.Boolean False 12 1 1.00 1.00 - -## PARAMETERS - -### -InputObject -{{ Fill InputObject Description }} - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Object values to be analyzed in aggregate. -## OUTPUTS - -### System.Management.Automation.PSCustomObject that describes the properties of the objects: -### * PropertyName -### * Type -### * Unique -### * Nulls -### * Values -### * Minimum -### * Maximum -## NOTES - -## RELATED LINKS - -[Write-Info.ps1]() - -[Stop-ThrowError.ps1]() - diff --git a/docs/Measure-Values.ps1.md b/docs/Measure-Values.ps1.md deleted file mode 100644 index e5f75643..00000000 --- a/docs/Measure-Values.ps1.md +++ /dev/null @@ -1,151 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# Measure-Values.ps1 - -## SYNOPSIS -Provides analysis of supplied values. - -## SYNTAX - -``` -Measure-Values.ps1 [[-InputObject] ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -1..54 |ForEach-Object {Get-Random} |Measure-Values.ps1 -``` - -Type : System.Int32 -Values : 54 -NullValues : 0 -IsUnique : True -UniqueValues : 54 -Minimum : 94194382 -Maximum : 2128816298 -MeanAverage : 1088097395.2963 -MedianAverage : 1223934436 -ModeAverage : 1088097395.2963 -Variance : 3.74619103093056E+17 -StandardDeviation : 612061355.660571 - -### EXAMPLE 2 -``` -1..127 |ForEach-Object {Get-Date -UnixTimeSeconds (Get-Random)} |Measure-Values.ps1 -``` - -Type : System.DateTime -Values : 127 -NullValues : 0 -IsUnique : True -UniqueValues : 127 -IsDateOnly : False -DateOnlyValues : 0 -DateTimeValues : 127 -Minimum : 1970-12-23 12:18:33 -Maximum : 2037-10-28 21:09:37 -MostCommonValue : 1970-12-23 12:18:33 -MeanAverage : 2002-09-23 09:03:30 -MedianAverage : 2002-07-23 06:51:20 -ModeAverage : 2002-09-23 09:03:30 -UniqueYears : 59 -MeanAverageYear : 2002 -MedianAverageYear : 2002 -ModeAverageYear : 1979 -StandardDeviationYear : 20.9125879067699 -UniqueMonths : 12 -MinimumMonth : January -MaximumMonth : December -MeanAverageMonth : July -MedianAverageMonth : June -ModeAverageMonth : May -StandardDeviationMonth : 3.45228333389263 -January : 10 -Febuary : 6 -March : 16 -April : 7 -May : 19 -June : 11 -July : 6 -August : 7 -September : 14 -October : 10 -November : 7 -December : 14 -UniqueDays : 29 -MinimumDay : 1 -MaximumDay : 30 -MeanAverageDay : 15.4645669291339 -MedianAverageDay : 15 -ModeAverageDay : 7 -StandardDeviationDay : 8.53172908617298 -UniqueWeekdays : 7 -MinimumWeekday : Sunday -MaximumWeekday : Saturday -MeanAverageWeekday : Wednesday -MedianAverageWeekday : Wednesday -ModeAverageWeekday : Wednesday -StandardDeviationWeekday : 1.92091482392633 -Sunday : 13 -Monday : 20 -Tuesday : 21 -Wednesday : 23 -Thursday : 16 -Friday : 15 -Saturday : 19 - -## PARAMETERS - -### -InputObject -The values to analyze. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Object values to be analyzed in aggregate. -## OUTPUTS - -### System.Management.Automation.PSCustomObject that describes the values with properties like -### MeanAverage and StandardDeviation. -## NOTES - -## RELATED LINKS diff --git a/docs/Merge-PSObject.ps1.md b/docs/Merge-PSObject.ps1.md deleted file mode 100644 index ddbac9a1..00000000 --- a/docs/Merge-PSObject.ps1.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Merge-PSObject.ps1 - -## SYNOPSIS -Create a new PSObject by recursively combining the properties of PSObjects. - -## SYNTAX - -``` -Merge-PSObject.ps1 [[-ReferenceObject] ] [-InputObject] [-Accumulate] [-Force] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Merge-PSObject.ps1 ([pscustomobject]@{a=1;b=2}) ([pscustomobject]@{b=0;c=3}) -``` - -a b c -- - - -1 0 3 - -### EXAMPLE 2 -``` -'{"a":1,"b":{"u":3},"c":{"v":5}}','{"a":{"w":8},"b":2,"c":{"x":6}}' |ConvertFrom-Json |Merge-PSObject.ps1 -Force |ConvertTo-Json -``` - -{ - "a": { - "w": 8 - }, - "b": 2, - "c": { - "v": 5, - "x": 6 - } -} - -## PARAMETERS - -### -ReferenceObject -Initial PSObject to combine. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: [pscustomobject]@{} -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -PSObjects to combine. -PSObject descendant properties are recursively merged. -Primitive values are overwritten by any matching ones in the new PSObject. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Accumulate -{{ Fill Accumulate Description }} - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Force -{{ Fill Force Description }} - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Management.Automation.PSObject to combine. -## OUTPUTS - -### System.Management.Automation.PSObject combining the inputs. -## NOTES - -## RELATED LINKS - -[Get-Member]() - -[Add-Member]() - diff --git a/docs/New-Script.ps1.md b/docs/New-Script.ps1.md index bcfe9bac..a9f6f638 100644 --- a/docs/New-Script.ps1.md +++ b/docs/New-Script.ps1.md @@ -19,7 +19,7 @@ New-Script.ps1 [-NameNoun] [-Synopsis ] [-Parameters ] [-RequiresModule ] [-ConfirmImpact ] [-DefaultParameterSetName ] [-HelpUri ] [-Indent ] [-RequiresRunAsAdmin] [-SupportsPaging] [-SupportsShouldProcess] [-PositionalBinding] [-ProgressAction ] - -NameVerb [] + [] ``` ## DESCRIPTION @@ -366,21 +366,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -NameVerb -{{ Fill NameVerb Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -ProgressAction {{ Fill ProgressAction Description }} diff --git a/docs/Read-Choice.ps1.md b/docs/Read-Choice.ps1.md deleted file mode 100644 index 56ae2848..00000000 --- a/docs/Read-Choice.ps1.md +++ /dev/null @@ -1,164 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://msdn.microsoft.com/library/system.management.automation.host.pshostuserinterface.promptforchoice.aspx -schema: 2.0.0 ---- - -# Read-Choice.ps1 - -## SYNOPSIS -Returns choice selected from a list of options. - -## SYNTAX - -### ChoicesArray -``` -Read-Choice.ps1 [-Choices] [-Caption ] [-Message ] [-DefaultIndex ] - [-ProgressAction ] [] -``` - -### ChoicesHash -``` -Read-Choice.ps1 [-ChoiceHash] [-Caption ] [-Message ] [-DefaultIndex ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Read-Choice.ps1 one,two,three -``` - -Please select: -\[\] one \[\] two \[\] three \[?\] Help (default is "one"): -one - -### EXAMPLE 2 -``` -Read-Choice.ps1 ([ordered]@{'&one'='first thing';'&two'='second thing';'t&hree'='third thing'}) -Message 'Pick:' -``` - -Pick: -\[O\] one \[T\] two \[H\] three \[?\] Help (default is "O"): ? -O - first thing -T - second thing -H - third thing -\[O\] one \[T\] two \[H\] three \[?\] Help (default is "O"): -&one - -## PARAMETERS - -### -Choices -A list of choice strings. -Use & in front of a letter to make it a hotkey. - -```yaml -Type: String[] -Parameter Sets: ChoicesArray -Aliases: Options - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ChoiceHash -An ordered hash of choices mapped to help text descriptions. -Use & in front of a letter to make it a hotkey. - -```yaml -Type: IDictionary -Parameter Sets: ChoicesHash -Aliases: Menu - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Caption -A title to use for the prompt. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Message -Instructional text to provide in the prompt. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: Please select: -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DefaultIndex -The index of the default choice. -Use -1 to for no default. -Otherwise, the first item (index 0) is the default. - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String containing a choice to offer. -## OUTPUTS - -### System.String containing the choice that was selected. -## NOTES - -## RELATED LINKS - -[https://msdn.microsoft.com/library/system.management.automation.host.pshostuserinterface.promptforchoice.aspx](https://msdn.microsoft.com/library/system.management.automation.host.pshostuserinterface.promptforchoice.aspx) - diff --git a/docs/Remove-ConsoleHistory.ps1.md b/docs/Remove-ConsoleHistory.ps1.md deleted file mode 100644 index 5a9c833d..00000000 --- a/docs/Remove-ConsoleHistory.ps1.md +++ /dev/null @@ -1,183 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Remove-ConsoleHistory.ps1 - -## SYNOPSIS -Removes an entry from the DOSKey-style console command history (up arrow or F8). - -## SYNTAX - -### Id -``` -Remove-ConsoleHistory.ps1 -Id [-ProgressAction ] [-WhatIf] [-Confirm] - [] -``` - -### CommandLine -``` -Remove-ConsoleHistory.ps1 [-CommandLine] [-ProgressAction ] [-WhatIf] [-Confirm] - [] -``` - -### Like -``` -Remove-ConsoleHistory.ps1 -Like [-ProgressAction ] [-WhatIf] [-Confirm] - [] -``` - -### Duplicates -``` -Remove-ConsoleHistory.ps1 [-Duplicates] [-ProgressAction ] [-WhatIf] [-Confirm] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Remove-ConsoleHistory.ps1 -Id 42 -``` - -Deletes the 42nd command from the history. - -### EXAMPLE 2 -``` -Remove-ConsoleHistory.ps1 -Duplicates -``` - -Deletes any repeated commands from the history. - -### EXAMPLE 3 -``` -Remove-ConsoleHistory.ps1 -Like winget* -``` - -Deletes any commands that start with "winget" from the history. - -## PARAMETERS - -### -Id -{{ Fill Id Description }} - -```yaml -Type: Int32 -Parameter Sets: Id -Aliases: - -Required: True -Position: Named -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -CommandLine -{{ Fill CommandLine Description }} - -```yaml -Type: String -Parameter Sets: CommandLine -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Like -{{ Fill Like Description }} - -```yaml -Type: String -Parameter Sets: Like -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Duplicates -{{ Fill Duplicates Description }} - -```yaml -Type: SwitchParameter -Parameter Sets: Duplicates -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WhatIf -Shows what would happen if the cmdlet runs. -The cmdlet is not run. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: wi - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String containing exact commands to remove. -## OUTPUTS - -## NOTES - -## RELATED LINKS diff --git a/docs/Remove-NullValues.ps1.md b/docs/Remove-NullValues.ps1.md deleted file mode 100644 index 5d38af31..00000000 --- a/docs/Remove-NullValues.ps1.md +++ /dev/null @@ -1,77 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Remove-NullValues.ps1 - -## SYNOPSIS -Removes dictionary entries with null vaules. - -## SYNTAX - -``` -Remove-NullValues.ps1 [-InputObject] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -@{ a = 1; b = $null; c = 3 } |Remove-NullValues.ps1 -``` - -Name Value ----- ----- -c 3 -a 1 - -## PARAMETERS - -### -InputObject -A dictionary to remove the nulls from. - -```yaml -Type: IDictionary -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Collections.IDictionary to remove nulls from. -## OUTPUTS - -### System.Collections.IDictionary with null-valued entries removed. -## NOTES - -## RELATED LINKS diff --git a/docs/Remove-ParameterDefault.ps1.md b/docs/Remove-ParameterDefault.ps1.md deleted file mode 100644 index e258582b..00000000 --- a/docs/Remove-ParameterDefault.ps1.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Remove-ParameterDefault.ps1 - -## SYNOPSIS -Removes a value that would have been used for a parameter if none was specified, if one existed. - -## SYNTAX - -``` -Remove-ParameterDefault.ps1 [-CommandName] [-ParameterName] [-Scope ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Remove-ParameterDefault.ps1 epcsv nti -Scope Global -``` - -Establishes that the -NoTypeInformation param of the Export-Csv cmdlet will revert to false -(as established by the cmdlet) if not otherwise specified, globally for the PowerShell session. - -### EXAMPLE 2 -``` -Remove-ParameterDefault.ps1 Select-Xml Namespace -``` - -Removes any namespaces used by Select-Xml when none are given explicitly. - -## PARAMETERS - -### -CommandName -The name of a cmdlet, function, script, or alias to remove a default parameter value from. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: CmdletName - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ParameterName -The name or alias of the parameter to remove a default value from. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Scope -The scope of this default. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: Local -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### An object with a ParameterName property that identifies a property to remove a default for. -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[Add-ScopeLevel.ps1]() - -[Stop-ThrowError.ps1]() - -[Get-Command]() - -[about_Scopes]() - diff --git a/docs/Repair-MarkdownHeaders.ps1.md b/docs/Repair-MarkdownHeaders.ps1.md deleted file mode 100644 index 6336db9c..00000000 --- a/docs/Repair-MarkdownHeaders.ps1.md +++ /dev/null @@ -1,152 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://webcoder.info/markdown-headers.html -schema: 2.0.0 ---- - -# Repair-MarkdownHeaders.ps1 - -## SYNOPSIS -Updates markdown content to replace level 1 & 2 ATX headers to Setext headers. - -## SYNTAX - -### Path -``` -Repair-MarkdownHeaders.ps1 [-Path] [[-Encoding] ] [-Style ] [-NewLine ] - [-ProgressAction ] [] -``` - -### InputObject -``` -Repair-MarkdownHeaders.ps1 [-InputObject ] [-Style ] [-NewLine ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Repair-MarkdownHeaders.ps1 -Path readme.md -Style SetextWithAtx -``` - -Updates the file with the specified header style. - -### EXAMPLE 2 -``` -$content = $markdown |Repair-MarkdownHeaders.ps1 -Style Atx -``` - -Returns markdown code that uses ATX headers. - -## PARAMETERS - -### -Path -Markdown file to update. - -```yaml -Type: String -Parameter Sets: Path -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Encoding -The text encoding to use when converting text to binary data. - -```yaml -Type: String -Parameter Sets: Path -Aliases: - -Required: False -Position: 2 -Default value: Utf8 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -Markdown content to update. - -```yaml -Type: String -Parameter Sets: InputObject -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Style -The style of headers to use. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: SetextWithAtx -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -NewLine -The line endings to use. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: [Environment]::NewLine -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String containing markdown code to update. -## OUTPUTS - -### System.String containing updated markdown code. -## NOTES - -## RELATED LINKS - -[https://webcoder.info/markdown-headers.html](https://webcoder.info/markdown-headers.html) - diff --git a/docs/Save-PodcastEpisodes.ps1.md b/docs/Save-PodcastEpisodes.ps1.md deleted file mode 100644 index 03442d9f..00000000 --- a/docs/Save-PodcastEpisodes.ps1.md +++ /dev/null @@ -1,166 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Save-PodcastEpisodes.ps1 - -## SYNOPSIS -Saves enclosures from a podcast feed. - -## SYNTAX - -``` -Save-PodcastEpisodes.ps1 [-Uri] [-After ] [-Before ] [-First ] [-Last ] - [-UseTitle] [-CreateFolder] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Save-PodcastEpisodes.ps1 https://www.youlooknicetoday.com/rss -UseTitle -``` - -Saves podcast episodes to the current directory. - -## PARAMETERS - -### -Uri -The URL of the podcast feed. - -```yaml -Type: Uri -Parameter Sets: (All) -Aliases: Url - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -After -Episodes before this date will be ignored. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Before -Episodes after this date will be ignored. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -First -Includes only the given number of initial episodes, by publish date. - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Last -Includes only the given number of most recent episodes, by publish date. - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UseTitle -Use episode titles for filenames. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -CreateFolder -Saves the episodes into a folder with the podcast name. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[Save-WebRequest.ps1]() - diff --git a/docs/Save-WebRequest.ps1.md b/docs/Save-WebRequest.ps1.md deleted file mode 100644 index 09697fe5..00000000 --- a/docs/Save-WebRequest.ps1.md +++ /dev/null @@ -1,150 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://tools.ietf.org/html/rfc2183 -schema: 2.0.0 ---- - -# Save-WebRequest.ps1 - -## SYNOPSIS -Downloads a given URL to a file, automatically determining the filename. - -## SYNTAX - -``` -Save-WebRequest.ps1 [-Uri] [-OutDirectory ] [-CreationTime ] - [-LastWriteTime ] [-Open] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Save-WebRequest.ps1 https://www.irs.gov/pub/irs-pdf/f1040.pdf -Open -``` - -Saves f1040.pdf (or else a filename specified in the Content-Disposition header) and opens it. - -## PARAMETERS - -### -Uri -The URL to download. - -```yaml -Type: Uri -Parameter Sets: (All) -Aliases: Url, Href, Src - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### -OutDirectory -The directory to save the file into. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -CreationTime -Sets the creation time on the file to the given value. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -LastWriteTime -Sets the creation time on the file to the given value. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Open -When present, invokes the file after it is downloaded. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### Object with System.Uri property named Uri. -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS - -[https://tools.ietf.org/html/rfc2183](https://tools.ietf.org/html/rfc2183) - -[http://test.greenbytes.de/tech/tc2231/](http://test.greenbytes.de/tech/tc2231/) - -[https://msdn.microsoft.com/library/system.net.mime.contentdisposition.filename.aspx](https://msdn.microsoft.com/library/system.net.mime.contentdisposition.filename.aspx) - -[https://msdn.microsoft.com/library/system.io.path.getinvalidfilenamechars.aspx](https://msdn.microsoft.com/library/system.io.path.getinvalidfilenamechars.aspx) - -[Invoke-WebRequest]() - -[Invoke-Item]() - -[Move-Item]() - diff --git a/docs/Select-CapturesFromMatches.ps1.md b/docs/Select-CapturesFromMatches.ps1.md deleted file mode 100644 index 8cc8c927..00000000 --- a/docs/Select-CapturesFromMatches.ps1.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Select-CapturesFromMatches.ps1 - -## SYNOPSIS -Selects named capture group values as note properties from Select-String MatchInfo objects. - -## SYNTAX - -``` -Select-CapturesFromMatches.ps1 [[-MatchInfo] ] [-ValuesOnly] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -.*?\b)\s*(?\S+@\S+)$' addrbook.txt |Select-CapturesFromMatches.ps1 -``` - -Name Email ----- ----- -Arthur Dent adent@example.org -Tricia McMillan trillian@example.com - -## PARAMETERS - -### -MatchInfo -The MatchInfo output from Select-String to select named capture group values from. - -```yaml -Type: MatchInfo -Parameter Sets: (All) -Aliases: InputObject - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ValuesOnly -Return the capture group values without building objects. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### Microsoft.PowerShell.Commands.MatchInfo, output from Select-String that used a pattern -### with named capture groups. -## OUTPUTS - -### System.Management.Automation.PSObject containing selected capture group values. -## NOTES - -## RELATED LINKS diff --git a/docs/Select-ScriptCommands.ps1.md b/docs/Select-ScriptCommands.ps1.md deleted file mode 100644 index 76dbde6e..00000000 --- a/docs/Select-ScriptCommands.ps1.md +++ /dev/null @@ -1,103 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://learn.microsoft.com/dotnet/api/system.management.automation.language.parser.parsefile -schema: 2.0.0 ---- - -# Select-ScriptCommands.ps1 - -## SYNOPSIS -Returns the commands used by the specified script. - -## SYNTAX - -``` -Select-ScriptCommands.ps1 [[-Path] ] [-CommandType ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Select-ScriptCommands.ps1 Select-ScriptCommands.ps1 -``` - -CommandType Name Version Source ------------ ---- ------- ------ -Cmdlet Out-Null 7.5.0.500 Microsoft.PowerShell.Core -Cmdlet Where-Object 7.5.0.500 Microsoft.PowerShell.Core -Cmdlet Select-Object 7.0.0.0 Microsoft.PowerShell.Utility -Cmdlet Get-Command 7.5.0.500 Microsoft.PowerShell.Core -Cmdlet Resolve-Path 7.0.0.0 Microsoft.PowerShell.Management -Filter Get-ScriptCommands - -## PARAMETERS - -### -Path -A script file path (wildcards are accepted). - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -CommandType -Specifies the types of commands that this cmdlet gets. - -```yaml -Type: CommandTypes -Parameter Sets: (All) -Aliases: -Accepted values: Alias, Function, Filter, Cmdlet, ExternalScript, Application, Script, Configuration, All - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String containing the path to a script file to parse. -## OUTPUTS - -### System.Management.Automation.CommandInfo for each command parsed from the file. -## NOTES - -## RELATED LINKS - -[https://learn.microsoft.com/dotnet/api/system.management.automation.language.parser.parsefile](https://learn.microsoft.com/dotnet/api/system.management.automation.language.parser.parsefile) - -[Get-Command]() - diff --git a/docs/Set-ParameterDefault.ps1.md b/docs/Set-ParameterDefault.ps1.md deleted file mode 100644 index 5b7ed544..00000000 --- a/docs/Set-ParameterDefault.ps1.md +++ /dev/null @@ -1,136 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Set-ParameterDefault.ps1 - -## SYNOPSIS -Assigns a value to use for the specified cmdlet parameter to use when one is not specified. - -## SYNTAX - -``` -Set-ParameterDefault.ps1 [-CommandName] [-ParameterName] [-Value] [-Scope ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Set-ParameterDefault.ps1 epcsv nti $true -Scope Global -``` - -Establishes that the -NoTypeInformation param of the Export-Csv cmdlet will be true if not otherwise specified, -globally for the PowerShell session. - -### EXAMPLE 2 -``` -Set-ParameterDefault.ps1 Select-Xml Namespace @{svg = 'http://www.w3.org/2000/svg'} -``` - -Uses only the SVG namespace for Select-Xml when none are given explicitly. - -## PARAMETERS - -### -CommandName -The name of a cmdlet, function, script, or alias to assign a default parameter value to. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: CmdletName - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ParameterName -The name or alias of the parameter to assign a default value to. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Value -The value to assign as a default. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: True -Position: 3 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Scope -The scope of this default. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: Local -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Object containing the default value to assign. -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[Add-ScopeLevel.ps1]() - -[Stop-ThrowError.ps1]() - -[Get-Command]() - -[about_Scopes]() - diff --git a/docs/Set-RegexReplace.ps1.md b/docs/Set-RegexReplace.ps1.md deleted file mode 100644 index 77566799..00000000 --- a/docs/Set-RegexReplace.ps1.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/dotnet/standard/base-types/substitutions-in-regular-expressions -schema: 2.0.0 ---- - -# Set-RegexReplace.ps1 - -## SYNOPSIS -Updates text found with Select-String, using a regular expression replacement template. - -## SYNTAX - -``` -Set-RegexReplace.ps1 [-Replacement] [-InputObject ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -)' README.md |Set-RegexReplace.ps1 "`$1 $(Get-Date) `$2" -``` - -Updates the generated date in README.md. - -### EXAMPLE 2 -``` -\d+)' |Set-RegexReplace.ps1 '$1 align="right"$2' -``` - -\ -\\\\ -\\Name\\Length\\ -\\README.md\\21099\\ -\ - -## PARAMETERS - -### -Replacement -A regular expression replacement string. - -* $$ is a literal $ -* $_ is the entire input string. -* $\` is the string before the match. -* $& is the entire matching string. -* $' is the string after the match. -* $1 is the first matching group. -* $n (where n is a number) is the nth matching group. -* $name is the group named "name". -* $+ is the last matching group. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The output from Select-String. - -```yaml -Type: MatchInfo -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### Microsoft.PowerShell.Commands.MatchInfo containing a regex match than will be replaced. -## OUTPUTS - -### System.String of the input string if the Select-String's input was a string instead of a file. -### (File changes will be saved back to the file.) -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/dotnet/standard/base-types/substitutions-in-regular-expressions](https://docs.microsoft.com/dotnet/standard/base-types/substitutions-in-regular-expressions) - -[Get-Encoding.ps1]() - diff --git a/docs/Set-TerminalProfile.ps1.md b/docs/Set-TerminalProfile.ps1.md new file mode 100644 index 00000000..df1d88eb --- /dev/null +++ b/docs/Set-TerminalProfile.ps1.md @@ -0,0 +1,82 @@ +--- +external help file: -help.xml +Module Name: +online version: https://aka.ms/terminal-documentation +schema: 2.0.0 +--- + +# Set-TerminalProfile.ps1 + +## SYNOPSIS +Adds or updates a Windows Terminal command profile. + +## SYNTAX + +``` +Set-TerminalProfile.ps1 [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### EXAMPLE 1 +``` +Set-TerminalProfile.ps1 pwsh +``` + +Adds a default profile for PowerShell Core. + +### EXAMPLE 2 +``` +Set-TerminalProfile.ps1 fsi +``` + +Adds a default profile for F# Interactive. + +### EXAMPLE 3 +``` +Set-TerminalProfile.ps1 ssh servername 'ssh username@servername' +``` + +Adds an ssh profile named "servername", using the specified command line. + +## PARAMETERS + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[https://aka.ms/terminal-documentation](https://aka.ms/terminal-documentation) + +[https://aka.ms/terminal-profiles-schema](https://aka.ms/terminal-profiles-schema) + +[https://gist.github.com/shanselman/4d954449914664024ee20ba10c2aaa0d](https://gist.github.com/shanselman/4d954449914664024ee20ba10c2aaa0d) + +[https://learn.microsoft.com/en-us/windows/terminal/json-fragment-extensions](https://learn.microsoft.com/en-us/windows/terminal/json-fragment-extensions) + +[https://github.com/microsoft/terminal/issues/1918#issuecomment-2452815871](https://github.com/microsoft/terminal/issues/1918#issuecomment-2452815871) + diff --git a/docs/Show-OpenApiInfo.ps1.md b/docs/Show-OpenApiInfo.ps1.md deleted file mode 100644 index 66e7ebb1..00000000 --- a/docs/Show-OpenApiInfo.ps1.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://www.openapis.org/ -schema: 2.0.0 ---- - -# Show-OpenApiInfo.ps1 - -## SYNOPSIS -Displays metadata from an OpenAPI definition. - -## SYNTAX - -``` -Show-OpenApiInfo.ps1 [-Path] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Show-OpenApiInfo.ps1 .\test\data\sample-openapi.json -``` - -Sample REST API v1.0.0 An example OpenAPI definition. -.\test\data\sample-openapi.json openapi v3.0.3 -GET /users/{userId} Returns a user by ID. -Gets a user's details. -POST /users Creates a new user. -Adds a user account. - -## PARAMETERS - -### -Path -{{ Fill Path Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: FullName - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://www.openapis.org/](https://www.openapis.org/) - diff --git a/docs/Show-PSDriveUsage.ps1.md b/docs/Show-PSDriveUsage.ps1.md deleted file mode 100644 index d41ecae9..00000000 --- a/docs/Show-PSDriveUsage.ps1.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Show-OpenApiInfo.ps1 - -## SYNOPSIS -Displays metadata from an OpenAPI definition. - -## SYNTAX - -``` -Show-OpenApiInfo.ps1 [-Path] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Show-OpenApiInfo.ps1 .\test\data\sample-openapi.json -``` - -Sample REST API v1.0.0 An example OpenAPI definition. -.\test\data\sample-openapi.json openapi v3.0.3 -GET /users/{userId} Returns a user by ID. -Gets a user's details. -POST /users Creates a new user. -Adds a user account. - -## PARAMETERS - -### -Path -{{ Fill Path Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: FullName - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[https://www.openapis.org/](https://www.openapis.org/) - diff --git a/docs/Show-Status.ps1.md b/docs/Show-Status.ps1.md deleted file mode 100644 index 8a3cfa78..00000000 --- a/docs/Show-Status.ps1.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://www.nerdfonts.com/cheat-sheet -schema: 2.0.0 ---- - -# Show-Status.ps1 - -## SYNOPSIS -Displays requested system status values using powerline font characters. - -## SYNTAX - -``` -Show-Status.ps1 [-Status] [-Separator ] [-ForegroundColor ] - [-BackgroundColor ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Show-Status.ps1 UserName HomeDirectory -Separator ' * ' -``` - -( MyUserName * C:\Users\MyUserName ) -(but using powerline graphics) - -## PARAMETERS - -### -Status -The format to serialize the date as. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Separator -The separator to use between formatted dates. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: " $(Get-Unicode.ps1 0x2022) " -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ForegroundColor -The foreground console color to use. - -```yaml -Type: ConsoleColor -Parameter Sets: (All) -Aliases: -Accepted values: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White - -Required: False -Position: Named -Default value: $host.UI.RawUI.BackgroundColor -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BackgroundColor -The background console color to use. - -```yaml -Type: ConsoleColor -Parameter Sets: (All) -Aliases: -Accepted values: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White - -Required: False -Position: Named -Default value: $host.UI.RawUI.ForegroundColor -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS - -[https://www.nerdfonts.com/cheat-sheet](https://www.nerdfonts.com/cheat-sheet) - -[Get-Unicode.ps1]() - diff --git a/docs/Show-Time.ps1.md b/docs/Show-Time.ps1.md deleted file mode 100644 index 1409afd0..00000000 --- a/docs/Show-Time.ps1.md +++ /dev/null @@ -1,144 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Show-Time.ps1 - -## SYNOPSIS -Displays a formatted date using powerline font characters. - -## SYNTAX - -``` -Show-Time.ps1 [-Format] [-Date ] [-Separator ] [-ForegroundColor ] - [-BackgroundColor ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Show-Time.ps1 Iso8601Z Iso8601WeekDate Iso8601OrdinalDate -Separator ' * ' -``` - -( 2020-12-08T03:59:39Z * 2020-W50-1 * 2020-342 ) -(but using powerline graphics) - -## PARAMETERS - -### -Format -The format to serialize the date as. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Date -The date/time value to format. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: (Get-Date) -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Separator -The separator to use between formatted dates. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: " $(Get-Unicode.ps1 0x2022) " -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ForegroundColor -The foreground console color to use. - -```yaml -Type: ConsoleColor -Parameter Sets: (All) -Aliases: -Accepted values: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White - -Required: False -Position: Named -Default value: $host.UI.RawUI.BackgroundColor -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BackgroundColor -The background console color to use. - -```yaml -Type: ConsoleColor -Parameter Sets: (All) -Aliases: -Accepted values: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White - -Required: False -Position: Named -Default value: $host.UI.RawUI.ForegroundColor -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS - -[Get-Unicode.ps1]() - -[Format-Date.ps1]() - -[Get-Date]() - diff --git a/docs/Split-Keys.ps1.md b/docs/Split-Keys.ps1.md deleted file mode 100644 index 956392d3..00000000 --- a/docs/Split-Keys.ps1.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://msdn.microsoft.com/library/System.Collections.IDictionary.aspx -schema: 2.0.0 ---- - -# Split-Keys.ps1 - -## SYNOPSIS -Clones a dictionary keeping only the specified keys. - -## SYNTAX - -``` -Split-Keys.ps1 [[-Keys] ] -Dictionary [-SkipNullValues] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -@{ A = 1; B = 2; C = 3 } |Split-Keys.ps1 B C D -``` - -Name Value ----- ----- -B 2 -C 3 - -### EXAMPLE 2 -``` -$PSBoundParameters |Split-Keys.ps1 From To Cc Bcc Subject -SkipNullValues |Send-MailMessage -``` - -Sends an email using selected params declared by the calling script with values. - -## PARAMETERS - -### -Keys -List of keys to include in the new dictionary. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Dictionary -The source dictionary to copy key-value pairs from. - -```yaml -Type: IDictionary -Parameter Sets: (All) -Aliases: Hashtable - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -SkipNullValues -When present, indicates that key-value pairs with a null value should not be included. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: NoNulls - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Collections.IDictionary, the source dictionary to select key-value pairs from by key. -## OUTPUTS - -### System.Collections.Specialized.OrderedDictionary, the dictionary matching key-value pairs are copied to. -## NOTES -Only string keys are supported. - -## RELATED LINKS - -[https://msdn.microsoft.com/library/System.Collections.IDictionary.aspx](https://msdn.microsoft.com/library/System.Collections.IDictionary.aspx) - diff --git a/docs/Split-Uri.ps1.md b/docs/Split-Uri.ps1.md deleted file mode 100644 index 9d371ffb..00000000 --- a/docs/Split-Uri.ps1.md +++ /dev/null @@ -1,580 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# Split-Uri.ps1 - -## SYNOPSIS -Splits a URI into component parts. - -## SYNTAX - -### AbsolutePath -``` -Split-Uri.ps1 [-Uri] [-AbsolutePath] [-ProgressAction ] [] -``` - -### Authority -``` -Split-Uri.ps1 [-Uri] [-Authority] [-ProgressAction ] [] -``` - -### Credentials -``` -Split-Uri.ps1 [-Uri] [-Credential] [-ProgressAction ] [] -``` - -### Extension -``` -Split-Uri.ps1 [-Uri] [-Extension] [-ProgressAction ] [] -``` - -### Filename -``` -Split-Uri.ps1 [-Uri] [-Filename ] [-ProgressAction ] [] -``` - -### HostNameType -``` -Split-Uri.ps1 [-Uri] [-HostNameType] [-ProgressAction ] [] -``` - -### IsAbsoluteUri -``` -Split-Uri.ps1 [-Uri] [-IsAbsoluteUri] [-ProgressAction ] [] -``` - -### IsDefaultPort -``` -Split-Uri.ps1 [-Uri] [-IsDefaultPort] [-ProgressAction ] [] -``` - -### IsFile -``` -Split-Uri.ps1 [-Uri] [-IsFile] [-ProgressAction ] [] -``` - -### IsLoopback -``` -Split-Uri.ps1 [-Uri] [-IsLoopback] [-ProgressAction ] [] -``` - -### IsUnc -``` -Split-Uri.ps1 [-Uri] [-IsUnc] [-ProgressAction ] [] -``` - -### Leaf -``` -Split-Uri.ps1 [-Uri] [-Leaf] [-ProgressAction ] [] -``` - -### LeafBase -``` -Split-Uri.ps1 [-Uri] [-LeafBase] [-ProgressAction ] [] -``` - -### ParentPath -``` -Split-Uri.ps1 [-Uri] [-ParentPath] [-ProgressAction ] [] -``` - -### ParentUri -``` -Split-Uri.ps1 [-Uri] [-ParentUri] [-ProgressAction ] [] -``` - -### Hostname -``` -Split-Uri.ps1 [-Uri] [-Hostname] [-ProgressAction ] [] -``` - -### IdnHost -``` -Split-Uri.ps1 [-Uri] [-IdnHost] [-ProgressAction ] [] -``` - -### LocalPath -``` -Split-Uri.ps1 [-Uri] [-LocalPath] [-ProgressAction ] [] -``` - -### PathAndQuery -``` -Split-Uri.ps1 [-Uri] [-PathAndQuery] [-ProgressAction ] [] -``` - -### Port -``` -Split-Uri.ps1 [-Uri] [-Port] [-ProgressAction ] [] -``` - -### Query -``` -Split-Uri.ps1 [-Uri] [-Query] [-ProgressAction ] [] -``` - -### QueryAsDictionary -``` -Split-Uri.ps1 [-Uri] [-QueryAsDictionary] [-ProgressAction ] [] -``` - -### Scheme -``` -Split-Uri.ps1 [-Uri] [-Scheme] [-ProgressAction ] [] -``` - -### Segment -``` -Split-Uri.ps1 [-Uri] [-Segment ] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Split-Uri.ps1 https://webcoder.info/wps-to-psc.html -Leaf -``` - -wps-to-psc.html - -### EXAMPLE 2 -``` -Split-Uri.ps1 https://webcoder.info/wps-to-psc.html -IsAbsoluteUri -``` - -True - -### EXAMPLE 3 -``` -Split-Uri.ps1 https://webcoder.info/wps-to-psc.html -Authority -``` - -webcoder.info - -### EXAMPLE 4 -``` -Split-Uri.ps1 'http://example.net/q?one=something&one=another%20thing&two=second' -QueryAsDictionary -``` - -Name Value ----- ----- -one {something, another thing} -two second - -## PARAMETERS - -### -Uri -Specifies the URI to split. - -```yaml -Type: Uri -Parameter Sets: (All) -Aliases: Url, Href, Src - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### -AbsolutePath -Indicates the absolute path of the URI should be returned. - -```yaml -Type: SwitchParameter -Parameter Sets: AbsolutePath -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Authority -Indicates the host/IP and port of the URI (as used to define security contexts) should be returned. - -```yaml -Type: SwitchParameter -Parameter Sets: Authority -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Credential -Indicates the credential of the URI should be returned, if a username and/or password was provided. - -```yaml -Type: SwitchParameter -Parameter Sets: Credentials -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Extension -Indicates the filename extension of the URI should be returned, if one is available. - -```yaml -Type: SwitchParameter -Parameter Sets: Extension -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Filename -Indicates the filename of the new URI should be returned, or the default value if one is not available. -Supports format specifiers, {0} for the current date and time and {1} for a GUID. - -```yaml -Type: String -Parameter Sets: Filename -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -HostNameType -Indicates the type of the hostname of the URI should be returned: Basic, Dns, IPv4, IPv6, Unknown. - -```yaml -Type: SwitchParameter -Parameter Sets: HostNameType -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IsAbsoluteUri -Indicates $true should be returned if the URI is absolute, $false otherwise. - -```yaml -Type: SwitchParameter -Parameter Sets: IsAbsoluteUri -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IsDefaultPort -Indicates $true should be returned if the URI specifies a default port, $false otherwise. - -```yaml -Type: SwitchParameter -Parameter Sets: IsDefaultPort -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IsFile -Indicates $true should be returned if the URI is a file: URI, $false otherwise. - -```yaml -Type: SwitchParameter -Parameter Sets: IsFile -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IsLoopback -Indicates $true should be returned if the URI references the localhost, $false otherwise. - -```yaml -Type: SwitchParameter -Parameter Sets: IsLoopback -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IsUnc -Indicates $true should be returned if the URI is a UNC path, $false otherwise. - -```yaml -Type: SwitchParameter -Parameter Sets: IsUnc -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Leaf -Indicates the final segment of the URI should be returned. - -```yaml -Type: SwitchParameter -Parameter Sets: Leaf -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -LeafBase -Indicates the final segment of the URI should be returned, without any filename extension. - -```yaml -Type: SwitchParameter -Parameter Sets: LeafBase -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ParentPath -Indicates the path of the URI should be returned, without the final segment. - -```yaml -Type: SwitchParameter -Parameter Sets: ParentPath -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ParentUri -Indicates the URI should be returned, without the final segment. - -```yaml -Type: SwitchParameter -Parameter Sets: ParentUri -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Hostname -Indicates the hostname of the URI should be returned. - -```yaml -Type: SwitchParameter -Parameter Sets: Hostname -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IdnHost -Indicates the IDN hostname of the URI should be returned. - -```yaml -Type: SwitchParameter -Parameter Sets: IdnHost -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -LocalPath -Indicates the OS-localized path of the URI should be returned. - -```yaml -Type: SwitchParameter -Parameter Sets: LocalPath -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -PathAndQuery -Indicates the absolute path and query of the URI should be returned, separated by '?'. - -```yaml -Type: SwitchParameter -Parameter Sets: PathAndQuery -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Port -Indicates the port number of the URI should be returned. - -```yaml -Type: SwitchParameter -Parameter Sets: Port -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Query -Indicates the querystring of the URI should be returned, including the leading '?'. - -```yaml -Type: SwitchParameter -Parameter Sets: Query -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -QueryAsDictionary -Indicates the querystring of the URI should be returned, as a Hashtable. - -```yaml -Type: SwitchParameter -Parameter Sets: QueryAsDictionary -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Scheme -Indicates the scheme of the URI should be returned (http, &c), without the trailing ':'. - -```yaml -Type: SwitchParameter -Parameter Sets: Scheme -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Segment -Indicates the specified segment index of the URI should be returned, if is available. - -```yaml -Type: Int32 -Parameter Sets: Segment -Aliases: - -Required: False -Position: Named -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Uri containing a URI to extract a part of. -## OUTPUTS - -### System.String for various URI parts that are extracted (usually), or -### System.Boolean for various tests of the URI parts, or -### System.Int32 to identify the port number if requsted, or -### System.UriHostNameType to identify the type of hostname if requested, or -### System.Collections.Hashtable containing the querystring name and value pairs if requested, or -### System.Management.Automation.PSCredential containing the username and password of the URI if requested. -## NOTES - -## RELATED LINKS diff --git a/docs/Stop-ThrowError.ps1.md b/docs/Stop-ThrowError.ps1.md deleted file mode 100644 index de1eba30..00000000 --- a/docs/Stop-ThrowError.ps1.md +++ /dev/null @@ -1,357 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://docs.microsoft.com/dotnet/api/system.management.automation.cmdlet.throwterminatingerror -schema: 2.0.0 ---- - -# Stop-ThrowError.ps1 - -## SYNOPSIS -Throws a better error than "throw". - -## SYNTAX - -### Detailed -``` -Stop-ThrowError.ps1 [-ExceptionType] [-ExceptionArguments] [-ErrorCategory] - [-TargetObject] [[-ErrorId] ] [-ProgressAction ] [] -``` - -### CatchBlock -``` -Stop-ThrowError.ps1 [[-ExceptionType] ] [[-ExceptionArguments] ] - [-ProgressAction ] [] -``` - -### NotImplemented -``` -Stop-ThrowError.ps1 [-Message] [-NotImplemented] [-ProgressAction ] - [] -``` - -### ItemNotFound -``` -Stop-ThrowError.ps1 [-Message] -SearchContext [-ProgressAction ] - [] -``` - -### ObjectNotFound -``` -Stop-ThrowError.ps1 [-Message] [-ProgressAction ] [] -``` - -### InvalidOperation -``` -Stop-ThrowError.ps1 [-Message] -OperationContext [-ProgressAction ] - [] -``` - -### InvalidArgument -``` -Stop-ThrowError.ps1 [-Message] -Argument [-ProgressAction ] - [] -``` - -### Format -``` -Stop-ThrowError.ps1 [-Message] -Format -InputString - [-ProgressAction ] [] -``` - -## DESCRIPTION -The PowerShell "throw" keyword doesn't do a good job of providing actionable -detail or context: - - Unable to remove root node. - At C:\Scripts\Remove-Xml.ps1:34 char:37 - + ... -if($node.ParentNode -eq $null) {throw 'Unable to remove root node.'} - + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + CategoryInfo : OperationStopped: (Unable to remove root node.:String) \[\], RuntimeException - + FullyQualifiedErrorId : Unable to remove root node. - -It only shows where the "throw" was used in the called script! - -Using $PSCmdlet.ThrowTerminatingError() does a much better job: - - C:\Scripts\Remove-Xml.ps1 : Unable to remove root node - Parameter name: SelectXmlInfo - At C:\Scripts\Test-Error.ps1:2 char:23 - + '\' |Select-Xml / |Remove-Xml.ps1 - + ~~~~~~~~~~~~~~ - + CategoryInfo : InvalidArgument: (\:SelectXmlInfo) \[Remove-Xml.ps1\], ArgumentException - + FullyQualifiedErrorId : RootRequired,Remove-Xml.ps1 - -Now you can see where the trouble is in the calling script! - -However, contructing an exception, then using that to construct an error with the right ID & category & -target object, then using that to call ThrowTerminatingError() is pretty inconvenient. - -This script combines that process into a few simple parameters. - -## EXAMPLES - -### EXAMPLE 1 -``` -Stop-ThrowError.ps1 'Unable to remove root node' -Argument SelectXmlInfo -``` - -C:\Scripts\Remove-Xml.ps1 : Unable to remove root node -Parameter name: SelectXmlInfo -At C:\Scripts\Test-Error.ps1:2 char:23 -+ '\' |Select-Xml / |Remove-Xml.ps1 -+ ~~~~~~~~~~~~~~ - + CategoryInfo : InvalidArgument: (\:SelectXmlInfo) \[Remove-Xml.ps1\], ArgumentException - + FullyQualifiedErrorId : SelectXmlInfo,Remove-Xml.ps1 - -### EXAMPLE 2 -``` -if(Test-Uri.ps1 $u) {[uri]$u} else {Stop-ThrowError.ps1 'Bad URL' -Format URL -InputString $u} -``` - -(Fails for non-uri values of $u.) - -## PARAMETERS - -### -ExceptionType -The type of a Exception class to instantiate as part of the error. - -```yaml -Type: Type -Parameter Sets: Detailed -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: Type -Parameter Sets: CatchBlock -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ExceptionArguments -The constructor parameters for the exception class specified by ExceptionTypeName. - -```yaml -Type: Object[] -Parameter Sets: Detailed -Aliases: - -Required: True -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: Object[] -Parameter Sets: CatchBlock -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ErrorCategory -The error's category, as an enumeration value. - -```yaml -Type: ErrorCategory -Parameter Sets: Detailed -Aliases: -Accepted values: NotSpecified, OpenError, CloseError, DeviceError, DeadlockDetected, InvalidArgument, InvalidData, InvalidOperation, InvalidResult, InvalidType, MetadataError, NotImplemented, NotInstalled, ObjectNotFound, OperationStopped, OperationTimeout, SyntaxError, ParserError, PermissionDenied, ResourceBusy, ResourceExists, ResourceUnavailable, ReadError, WriteError, FromStdErr, SecurityError, ProtocolError, ConnectionError, AuthenticationError, LimitsExceeded, QuotaExceeded, NotEnabled - -Required: True -Position: 3 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -TargetObject -The object in context when the error happened. - -```yaml -Type: Object -Parameter Sets: Detailed -Aliases: - -Required: True -Position: 4 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ErrorId -An string unique to the script that identifies the error. -By default this will use the line number it is called from. - -```yaml -Type: String -Parameter Sets: Detailed -Aliases: - -Required: False -Position: 5 -Default value: "L$(Get-PSCallStack |select -First 1 |% ScriptLineNumber)" -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Message -{{ Fill Message Description }} - -```yaml -Type: String -Parameter Sets: NotImplemented, ItemNotFound, ObjectNotFound, InvalidOperation, InvalidArgument, Format -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Format -The data format the string failed to parse as. - -```yaml -Type: String -Parameter Sets: Format -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputString -The string that failed to parse. - -```yaml -Type: String -Parameter Sets: Format -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Argument -The parameter name that had a bad value. - -```yaml -Type: String -Parameter Sets: InvalidArgument -Aliases: InvalidArgument - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -OperationContext -An object containing the state that failed to process. - -```yaml -Type: Object -Parameter Sets: InvalidOperation -Aliases: InvalidOperation - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SearchContext -An object containing the search detail that failed. - -```yaml -Type: Object -Parameter Sets: ItemNotFound -Aliases: ObjectNotFound - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -NotImplemented -Indicates that the exception represents incomplete functionality. - -```yaml -Type: SwitchParameter -Parameter Sets: NotImplemented -Aliases: - -Required: True -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS - -[https://docs.microsoft.com/dotnet/api/system.management.automation.cmdlet.throwterminatingerror](https://docs.microsoft.com/dotnet/api/system.management.automation.cmdlet.throwterminatingerror) - -[https://docs.microsoft.com/dotnet/api/system.management.automation.errorrecord.-ctor](https://docs.microsoft.com/dotnet/api/system.management.automation.errorrecord.-ctor) - -[Get-Variable]() - -[New-Object]() - diff --git a/docs/Test-Administrator.ps1.md b/docs/Test-Administrator.ps1.md deleted file mode 100644 index 8d2fe013..00000000 --- a/docs/Test-Administrator.ps1.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# Test-Administrator.ps1 - -## SYNOPSIS -Checks whether the current session has administrator privileges. - -## SYNTAX - -``` -Test-Administrator.ps1 [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### Example 1 -```powershell -PS C:\> {{ Add example code here }} -``` - -{{ Add example description here }} - -## PARAMETERS - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS diff --git a/docs/Test-DateTime.ps1.md b/docs/Test-DateTime.ps1.md deleted file mode 100644 index e84a6ed1..00000000 --- a/docs/Test-DateTime.ps1.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://msdn.microsoft.com/library/8kb3ddd4.aspx -schema: 2.0.0 ---- - -# Test-DateTime.ps1 - -## SYNOPSIS -Tests whether the given string can be parsed as a date. - -## SYNTAX - -``` -Test-DateTime.ps1 [-Date] [-Format ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Test-DateTime.ps1 '2017-02-29T11:38:00' -``` - -False - -### EXAMPLE 2 -``` -Test-DateTime.ps1 '2000-2-29T9:33:00' -Format 'yyyy-M-dTH:mm:ss' -``` - -True - -### EXAMPLE 3 -``` -Test-Datetime.ps1 970313 -Format 'yyMMdd' -``` - -True - -### EXAMPLE 4 -``` -Test-DateTime.ps1 '1900-02-29' -``` - -False - -## PARAMETERS - -### -Date -The string to test for datetime parseability. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Format -Precise, known format(s) to use to try parsing the datetime. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String containing a possible date to test parse. -## OUTPUTS - -### System.Boolean indicating the string is a parseable date. -## NOTES - -## RELATED LINKS - -[https://msdn.microsoft.com/library/8kb3ddd4.aspx](https://msdn.microsoft.com/library/8kb3ddd4.aspx) - diff --git a/docs/Test-FileTypeMagicNumber.ps1.md b/docs/Test-FileTypeMagicNumber.ps1.md deleted file mode 100644 index 4f0479a7..00000000 --- a/docs/Test-FileTypeMagicNumber.ps1.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: https://en.wikipedia.org/wiki/List_of_file_signatures -schema: 2.0.0 ---- - -# Test-FileTypeMagicNumber.ps1 - -## SYNOPSIS -Tests for a given common file type by magic number. - -## SYNTAX - -``` -Test-FileTypeMagicNumber.ps1 [-FileType] [[-Path] ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Test-FileTypeMagicNumber.ps1 utf8 README.md -``` - -True if a utf-8 signature (or "BOM", byte-order-mark) is found. - -### EXAMPLE 2 -``` -Test-FileTypeMagicNumber.ps1 png avatar.png -``` - -True if avatar.png contains the expected png magic number. - -## PARAMETERS - -### -FileType -The file type to test for. - -This is generally the MIME subtype or Unicode text encoding, with some exceptions. - -Several types require the presence of an optional header or prefix for positive identification of a file type, -such as "\ [[-Path] ] [-Offset ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Test-MagicNumber.ps1 0xEF,0xBB,0xBF README.md -``` - -True if a utf-8 signature (or "BOM", byte-order-mark) is found. - -### EXAMPLE 2 -``` -Test-MagicNumber.ps1 0x0D,0x0A README.md -Offset -2 -``` - -True if README.md ends with a Windows line-ending. - -### EXAMPLE 3 -``` -Test-MagicNumber.ps1 0x50,0x4B download123543 -``` - -True if download123543 starts with a PK ZIP magic number ("PK"), and is therefore likely ZIP data. - -## PARAMETERS - -### -Bytes -A list of byte values to compare against those read from the file. - -```yaml -Type: Byte[] -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Path -A file to look for the bytes in. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: FullName - -Required: False -Position: 3 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Offset -The number bytes into the file to begin reading the bytes to compare. -Use a negative number to count from the end of the file. - -```yaml -Type: Int32 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: 0 -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String path of a file to read. -## OUTPUTS - -### System.Boolean affirming that the bytes provided were found at the position given in the specified file. -## NOTES - -## RELATED LINKS - -[https://en.wikipedia.org/wiki/Magic_number_(programming)](https://en.wikipedia.org/wiki/Magic_number_(programming)) - -[Get-Content]() - diff --git a/docs/Test-NewerFile.ps1.md b/docs/Test-NewerFile.ps1.md deleted file mode 100644 index 807d5756..00000000 --- a/docs/Test-NewerFile.ps1.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Test-NewerFile.ps1 - -## SYNOPSIS -Returns true if the difference file is newer than the reference file. - -## SYNTAX - -``` -Test-NewerFile.ps1 [[-ReferenceFile] ] [[-DifferenceFile] ] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### Example 1 -```powershell -PS C:\> {{ Add example code here }} -``` - -{{ Add example description here }} - -## PARAMETERS - -### -ReferenceFile -One of two files to compare. - -```yaml -Type: FileInfo -Parameter Sets: (All) -Aliases: - -Required: False -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DifferenceFile -Another of two files to compare. - -```yaml -Type: FileInfo -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Boolean indicating the difference file is newer. -## NOTES - -## RELATED LINKS diff --git a/docs/Test-NoteProperty.ps1.md b/docs/Test-NoteProperty.ps1.md deleted file mode 100644 index 805c68c9..00000000 --- a/docs/Test-NoteProperty.ps1.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Test-NoteProperty.ps1 - -## SYNOPSIS -Looks for any matching NoteProperties on an object. - -## SYNTAX - -``` -Test-NoteProperty.ps1 [-Name] -InputObject [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -$r = Invoke-RestMethod @args; if(Test-NoteProperty.ps1 -Name Status -InputObject $r) { … } -``` - -Executes the "if" block if there is a status NoteProperty present. - -### EXAMPLE 2 -``` -Get-Content records.json |ConvertFrom-Json |? {$_ |Test-NoteProperty.ps1 *Addr*} |… -``` - -Passes objects through the pipeline that have a property containing "Addr" in the name. - -## PARAMETERS - -### -Name -The name of the property to look for. -Wildcards are supported. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The object to examine. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Management.Automation.PSObject, perhaps created via [PSCustomObject]@{ … } -### or ConvertFrom-Json or Invoke-RestMethod that may have NoteProperties. -## OUTPUTS - -### System.Boolean indicating at least one matching NoteProperty was found. -## NOTES - -## RELATED LINKS diff --git a/docs/Test-Range.ps1.md b/docs/Test-Range.ps1.md deleted file mode 100644 index 17dc83b3..00000000 --- a/docs/Test-Range.ps1.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# Test-NoteProperty.ps1 - -## SYNOPSIS -Looks for any matching NoteProperties on an object. - -## SYNTAX - -``` -Test-NoteProperty.ps1 [-Name] -InputObject [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -$r = Invoke-RestMethod @args; if(Test-NoteProperty.ps1 -Name Status -InputObject $r) { … } -``` - -Executes the "if" block if there is a status NoteProperty present. - -### EXAMPLE 2 -``` -Get-Content records.json |ConvertFrom-Json |? {$_ |Test-NoteProperty.ps1 *Addr*} |… -``` - -Passes objects through the pipeline that have a property containing "Addr" in the name. - -## PARAMETERS - -### -Name -The name of the property to look for. -Wildcards are supported. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The object to examine. - -```yaml -Type: PSObject -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Management.Automation.PSObject, perhaps created via [PSCustomObject]@{ … } -### or ConvertFrom-Json or Invoke-RestMethod that may have NoteProperties. -## OUTPUTS - -### System.Boolean indicating at least one matching NoteProperty was found. -## NOTES - -## RELATED LINKS diff --git a/docs/Test-USFederalHoliday.ps1.md b/docs/Test-USFederalHoliday.ps1.md deleted file mode 100644 index 4a771c37..00000000 --- a/docs/Test-USFederalHoliday.ps1.md +++ /dev/null @@ -1,158 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: http://www.federalreserve.gov/aboutthefed/k8.htm -schema: 2.0.0 ---- - -# Test-USFederalHoliday.ps1 - -## SYNOPSIS -Returns true if the given date is a U.S. -federal holiday. - -## SYNTAX - -``` -Test-USFederalHoliday.ps1 [-Date] [-AsHolidayName] [-SatToFri] [-SunToMon] - [-ProgressAction ] [] -``` - -## DESCRIPTION -The following holidays are checked: - - * New Year's Day, January 1 (± 1 day, if observed) - * Birthday of Martin Luther King, Jr., Third Monday in January - * Washington's Birthday, Third Monday in February - * Memorial Day, Last Monday in May - * Juneteenth, June 19 (± 1 day, if observed) - * Independence Day, July 4 (± 1 day, if observed) - * Labor Day, First Monday in September - * Columbus Day, Second Monday in October - * Veterans Day, November 11 (±1 day, if observed) - * Thanksgiving Day, Fourth Thursday in November - * Christmas Day, December 25 (±1 day, if observed) - -## EXAMPLES - -### EXAMPLE 1 -``` -Test-USFederalHoliday.ps1 2016-11-11 -``` - -Veterans Day - -### EXAMPLE 2 -``` -Test-USFederalHoliday.ps1 2017-02-20 -``` - -Washington's Birthday - -### EXAMPLE 3 -``` -if(Test-USFederalHoliday.ps1 (Get-Date)) { return } -``` - -Returns from a function or script if today is a holiday. - -## PARAMETERS - -### -Date -The date to check. - -```yaml -Type: DateTime -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -AsHolidayName -Return the holiday name? - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: ReturnName, ReturnHolidayName - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SatToFri -Indicates Saturday holidays are observed on Fridays. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SunToMon -Indicates Sunday holidays are observed on Mondays. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.DateTime values to check. -## OUTPUTS - -### System.Boolean indicating whether the date is a holiday. -## NOTES -Thanks to the Uniform Monday Holiday Act, Washington's "Birthday" always falls -*between* Washington's birthdays. -He had two, and we still decided to celebrate -a third day. - -https://en.wikipedia.org/wiki/Uniform_Monday_Holiday_Act - -https://en.wikipedia.org/wiki/Washington%27s_Birthday#History - -## RELATED LINKS - -[http://www.federalreserve.gov/aboutthefed/k8.htm](http://www.federalreserve.gov/aboutthefed/k8.htm) - diff --git a/docs/Test-Uri.ps1.md b/docs/Test-Uri.ps1.md deleted file mode 100644 index 376d9f15..00000000 --- a/docs/Test-Uri.ps1.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Test-Uri.ps1 - -## SYNOPSIS -Determines whether a string is a valid URI. - -## SYNTAX - -``` -Test-Uri.ps1 [-InputObject] [[-UriKind] ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Test-Uri.ps1 http://example.org -``` - -True - -### EXAMPLE 2 -``` -Test-Uri.ps1 0 -``` - -False - -## PARAMETERS - -### -InputObject -The string to test. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -UriKind -What kind of URI to test for: Absolute, Relative, or RelativeOrAbsolute. - -```yaml -Type: UriKind -Parameter Sets: (All) -Aliases: -Accepted values: RelativeOrAbsolute, Absolute, Relative - -Required: False -Position: 2 -Default value: Absolute -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String value to test for a valid URI format. -## OUTPUTS - -### System.Boolean indicating that the string can be parsed as a URI. -## NOTES - -## RELATED LINKS diff --git a/docs/Test-Variable.ps1.md b/docs/Test-Variable.ps1.md deleted file mode 100644 index 5efbcd0e..00000000 --- a/docs/Test-Variable.ps1.md +++ /dev/null @@ -1,136 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Test-Variable.ps1 - -## SYNOPSIS -Indicates whether a variable has been defined. - -## SYNTAX - -``` -Test-Variable.ps1 [-Name] [[-Scope] ] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Test-Variable.ps1 true -``` - -True - -### EXAMPLE 2 -``` -Test-Variable.ps1 '' -``` - -False - -A variable can't have an empty string for a name. - -### EXAMPLE 3 -``` -Test-Variable.ps1 $null -``` - -False - -A variable can't have a null name. - -### EXAMPLE 4 -``` -Test-Variable.ps1 null -``` - -True - -### EXAMPLE 5 -``` -'PSVersionTable','false' |Test-Variable.ps1 -``` - -True -True - -### EXAMPLE 6 -``` -'PWD','PID' |Test-Variable.ps1 -Scope Global -``` - -True -True - -## PARAMETERS - -### -Name -A variable name to test the existence of. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Scope -{{ Fill Scope Description }} - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String name of a variable. -## OUTPUTS - -### System.Boolean indicating whether the variable name is defined. -## NOTES - -## RELATED LINKS - -[Add-ScopeLevel.ps1]() - -[Get-Variable]() - diff --git a/docs/Test-Interactive.ps1.md b/docs/Test-WindowsTerminal.ps1.md similarity index 67% rename from docs/Test-Interactive.ps1.md rename to docs/Test-WindowsTerminal.ps1.md index 034ccb8c..eaf65899 100644 --- a/docs/Test-Interactive.ps1.md +++ b/docs/Test-WindowsTerminal.ps1.md @@ -1,19 +1,19 @@ --- external help file: -help.xml Module Name: -online version: +online version: https://aka.ms/terminal-documentation schema: 2.0.0 --- -# Test-Interactive.ps1 +# Test-WindowsTerminal.ps1 ## SYNOPSIS -Determines whether both the user and process are interactive. +Returns true if PowerShell is running within Windows Terminal. ## SYNTAX ``` -Test-Interactive.ps1 [-ProgressAction ] [] +Test-WindowsTerminal.ps1 [-ProgressAction ] [] ``` ## DESCRIPTION @@ -23,7 +23,7 @@ Test-Interactive.ps1 [-ProgressAction ] [] ### EXAMPLE 1 ``` -Test-Interactive.ps1 +Test-WindowsTerminal.ps1 ``` True @@ -52,7 +52,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## OUTPUTS -### System.Boolean indicating whether the session is interactive. +### System.Boolean ## NOTES ## RELATED LINKS + +[https://aka.ms/terminal-documentation](https://aka.ms/terminal-documentation) + diff --git a/docs/Trace-WebRequest.ps1.md b/docs/Trace-WebRequest.ps1.md deleted file mode 100644 index 970e4464..00000000 --- a/docs/Trace-WebRequest.ps1.md +++ /dev/null @@ -1,235 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Trace-WebRequest.ps1 - -## SYNOPSIS -Provides details about a retrieving a URI. - -## SYNTAX - -``` -Trace-WebRequest.ps1 [-Uri] [-Method ] [-LogFile ] [-SkipHeaders] [-SkipContent] - [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Trace-WebRequest.ps1 g.co/p3phelp -SkipContent -``` - -📤️ GET g.co/p3phelp - -📥️ HTTP/1.1 301 MovedPermanently -Cache-Control: no-store, must-revalidate, no-cache, max-age=0 -Pragma: no-cache -Date: Thu, 26 Dec 2024 21:08:21 GMT -Location: https://g.co/p3phelp -Server: ESF -X-XSS-Protection: 0 -X-Frame-Options: SAMEORIGIN -X-Content-Type-Options: nosniff -Content-Type: application/binary -Expires: Mon, 01 Jan 1990 00:00:00 GMT -Content-Length: 0 -ℹ️ Following redirect to https://g.co/p3phelp -📤️ GET https://g.co/p3phelp - -📥️ HTTP/1.1 302 Found -Vary: Sec-Fetch-Dest -Vary: Sec-Fetch-Mode -Vary: Sec-Fetch-Site -Cache-Control: no-store, must-revalidate, no-cache, max-age=0 -Pragma: no-cache -Date: Thu, 26 Dec 2024 21:08:22 GMT -Location: https://support.google.com/accounts/answer/151657?hl=en -Strict-Transport-Security: max-age=31536000 -Cross-Origin-Opener-Policy: unsafe-none -Cross-Origin-Resource-Policy: same-site -Server: ESF -X-XSS-Protection: 0 -X-Frame-Options: SAMEORIGIN -X-Content-Type-Options: nosniff -Alt-Svc: h3=":443"; ma=2592000 -Alt-Svc: h3-29=":443"; ma=2592000 -Content-Type: application/binary -Expires: Mon, 01 Jan 1990 00:00:00 GMT -Content-Length: 0 -ℹ️ Following redirect to https://support.google.com/accounts/answer/151657?hl=en -📤️ GET https://support.google.com/accounts/answer/151657?hl=en - -📥️ HTTP/1.1 301 MovedPermanently -Location: https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638708441023370154-2201542783&rd=1 -X-Robots-Tag: follow,index -Date: Thu, 26 Dec 2024 21:08:22 GMT -Cache-Control: max-age=0, private -X-Content-Type-Options: nosniff -Server: support-content-ui -X-XSS-Protection: 0 -X-Frame-Options: SAMEORIGIN -Alt-Svc: h3=":443"; ma=2592000 -Alt-Svc: h3-29=":443"; ma=2592000 -Expires: Thu, 26 Dec 2024 21:08:22 GMT -Content-Type: text/html; charset=UTF-8 -Content-Length: 304 -ℹ️ Following redirect to https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638708441023370154-2201542783&rd=1 -📤️ GET https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638708441023370154-2201542783&rd=1 - -📥️ HTTP/1.1 301 MovedPermanently -Location: https://support.google.com/accounts/?hl=en&visit_id=638708441023370154-2201542783&rd=2&topic=3382252 -X-Robots-Tag: follow,noindex -Date: Thu, 26 Dec 2024 21:08:22 GMT -Cache-Control: max-age=0, private -X-Content-Type-Options: nosniff -Server: support-content-ui -X-XSS-Protection: 0 -X-Frame-Options: SAMEORIGIN -Alt-Svc: h3=":443"; ma=2592000 -Alt-Svc: h3-29=":443"; ma=2592000 -Expires: Thu, 26 Dec 2024 21:08:22 GMT -Content-Type: text/html; charset=UTF-8 -Content-Length: 309 -ℹ️ Following redirect to https://support.google.com/accounts/?hl=en&visit_id=638708441023370154-2201542783&rd=2&topic=3382252 -📤️ GET https://support.google.com/accounts/?hl=en&visit_id=638708441023370154-2201542783&rd=2&topic=3382252 - -📥️ HTTP/1.1 200 OK -P3P: CP="This is not a P3P policy! -See g.co/p3phelp for more info." -P3P: CP="This is not a P3P policy! -See g.co/p3phelp for more info." -P3P: CP="This is not a P3P policy! -See g.co/p3phelp for more info." -Strict-Transport-Security: max-age=31536000; includeSubdomains -Date: Thu, 26 Dec 2024 21:08:23 GMT -Cache-Control: max-age=0, private -Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-69sNhX1vigTzFtuMUufk' 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http: 'report-sample';report-uri https://csp.withgoogle.com/csp/scfe -X-Content-Type-Options: nosniff -Server: support-content-ui -X-XSS-Protection: 0 -X-Frame-Options: SAMEORIGIN -Alt-Svc: h3=":443"; ma=2592000 -Alt-Svc: h3-29=":443"; ma=2592000 -Transfer-Encoding: chunked -Content-Type: text/html; charset=UTF-8 -Expires: Thu, 26 Dec 2024 21:08:23 GMT - -## PARAMETERS - -### -Uri -The URL to retrieve. - -```yaml -Type: Uri -Parameter Sets: (All) -Aliases: Url, Href, Src - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### -Method -The HTTP method verb to use. - -```yaml -Type: HttpMethod -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: GET -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -LogFile -A file to log the request to. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SkipHeaders -Indicates headers shouldn't be output. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SkipContent -Indicates content shouldn't be output. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Uri to retrieve. -## OUTPUTS - -## NOTES -TODO: Add support for other Invoke-WebRequest parameters. - -## RELATED LINKS - -[Import-CharConstants.ps1]() - -[Write-Info.ps1]() - -[Import-Variables.ps1]() - diff --git a/docs/Uninstall-OldModules.ps1.md b/docs/Uninstall-OldModules.ps1.md deleted file mode 100644 index 8a926146..00000000 --- a/docs/Uninstall-OldModules.ps1.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Uninstall-OldModules.ps1 - -## SYNOPSIS -Uninstalls old module versions. - -## SYNTAX - -``` -Uninstall-OldModules.ps1 [-Force] [-ProgressAction ] [-WhatIf] [-Confirm] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### Example 1 -```powershell -PS C:\> {{ Add example code here }} -``` - -{{ Add example description here }} - -## PARAMETERS - -### -Force -Indicates the modules should be forced to uninstall. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WhatIf -Shows what would happen if the cmdlet runs. -The cmdlet is not run. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: wi - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS diff --git a/docs/Update-Files.ps1.md b/docs/Update-Files.ps1.md deleted file mode 100644 index 045b4295..00000000 --- a/docs/Update-Files.ps1.md +++ /dev/null @@ -1,136 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Update-Files.ps1 - -## SYNOPSIS -Copies specified source files that exist in the destination directory. - -## SYNTAX - -``` -Update-Files.ps1 [-Path] [[-Destination] ] [-NewerOnly] [-ProgressAction ] - [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Update-Files.ps1 C:\Source\*.txt D:\Dest -``` - -Copies *.txt files from C:\Source to D:\Dest that exist in both. - -## PARAMETERS - -### -Path -Path(s) to copy files from, wildcards allowed. - -```yaml -Type: String[] -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByPropertyName, ByValue) -Accept wildcard characters: False -``` - -### -Destination -Folder to copy files to, if they already exist there. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -NewerOnly -Indicates files should only be copied if they are newer. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WhatIf -Shows what would happen if the cmdlet runs. -The cmdlet is not run. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: wi - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String of paths to copy from, if matches exist in the destination. -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS diff --git a/docs/Update-Modules.ps1.md b/docs/Update-Modules.ps1.md deleted file mode 100644 index 113be69d..00000000 --- a/docs/Update-Modules.ps1.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Update-Modules.ps1 - -## SYNOPSIS -Cleans up old modules. - -## SYNTAX - -``` -Update-Modules.ps1 [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### Example 1 -```powershell -PS C:\> {{ Add example code here }} -``` - -{{ Add example description here }} - -## PARAMETERS - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS diff --git a/docs/Use-ProgressView.ps1.md b/docs/Use-ProgressView.ps1.md deleted file mode 100644 index 2bed3ead..00000000 --- a/docs/Use-ProgressView.ps1.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Use-ProgressView.ps1 - -## SYNOPSIS -Sets the progress bar display view. - -## SYNTAX - -``` -Use-ProgressView.ps1 [-View] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Use-ProgressView.ps1 Classic -``` - -Restores the Windows PowerShell 5.x-style top progress banner for Write-Progress. - -## PARAMETERS - -### -View -The progress view to use. - -```yaml -Type: ProgressView -Parameter Sets: (All) -Aliases: -Accepted values: Minimal, Classic - -Required: True -Position: 1 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS - -[about_ANSI_Terminals]() - diff --git a/docs/Use-ReasonableDefaults.ps1.md b/docs/Use-ReasonableDefaults.ps1.md deleted file mode 100644 index 66f5daf8..00000000 --- a/docs/Use-ReasonableDefaults.ps1.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Use-ReasonableDefaults.ps1 - -## SYNOPSIS -Sets certain cmdlet parameter defaults to rational, useful values. - -## SYNTAX - -``` -Use-ReasonableDefaults.ps1 [-LatestSecurityProtocol] [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Use-ReasonableDefaults.ps1 -``` - -Sets the security protocol to TLS 1.2. - -Sets default values: - Out-File -Encoding UTF8 -Width (\[int\]::MaxValue) - Export-Csv -NoTypeInformation - Invoke-WebRequest -UseBasicParsing - Select-Xml -Namespace @{ a bunch of standard namespaces } - -## PARAMETERS - -### -LatestSecurityProtocol -Use the greatest value of the System.Net.SecurityProtocolType enum. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS - -[Use-NetMailConfig.ps1]() - -[Set-ParameterDefault.ps1]() - -[Get-EnumValues.ps1]() - diff --git a/docs/Write-CallInfo.ps1.md b/docs/Write-CallInfo.ps1.md deleted file mode 100644 index b0998693..00000000 --- a/docs/Write-CallInfo.ps1.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# Write-CallInfo.ps1 - -## SYNOPSIS -Prints caller name and parameters to the host for debugging purposes. - -## SYNTAX - -``` -Write-CallInfo.ps1 [-ProgressAction ] [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### Example 1 -```powershell -PS C:\> {{ Add example code here }} -``` - -{{ Add example description here }} - -## PARAMETERS - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS diff --git a/docs/Write-Info.ps1.md b/docs/Write-Info.ps1.md deleted file mode 100644 index fb94d3fb..00000000 --- a/docs/Write-Info.ps1.md +++ /dev/null @@ -1,154 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: True -schema: 2.0.0 ---- - -# Write-Info.ps1 - -## SYNOPSIS -Writes to the information stream, with color support and more. - -## SYNTAX - -``` -Write-Info.ps1 [-Message] [-ForegroundColor ] [-BackgroundColor ] - [-LogFile ] [-NoNewLine] [-UseInformationPreference] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### Example 1 -```powershell -PS C:\> {{ Add example code here }} -``` - -{{ Add example description here }} - -## PARAMETERS - -### -Message -Message to write to the information stream. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ForegroundColor -Specifies the text color. -There is no default. - -```yaml -Type: ConsoleColor -Parameter Sets: (All) -Aliases: fg - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -BackgroundColor -Specifies the background color. -There is no default. - -```yaml -Type: ConsoleColor -Parameter Sets: (All) -Aliases: bg - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -LogFile -Specifies a log file to write the information string to. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -NoNewLine -The string representations of the input objects are concatenated to form the output. -No spaces or newlines are inserted between the output strings. -No newline is added after the last output string. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UseInformationPreference -By default, uses -InformationAction Continue. -This uses the standard $InformationPreference instead. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -## OUTPUTS - -## NOTES - -## RELATED LINKS diff --git a/docs/Write-VisibleString.ps1.md b/docs/Write-VisibleString.ps1.md deleted file mode 100644 index 0af06318..00000000 --- a/docs/Write-VisibleString.ps1.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -external help file: -help.xml -Module Name: -online version: -schema: 2.0.0 ---- - -# Write-VisibleString.ps1 - -## SYNOPSIS -Displays a string, showing nonprintable characters. - -## SYNTAX - -``` -Write-VisibleString.ps1 [-InputObject] [-AsRunes] [-UseSymbols] [-ProgressAction ] - [] -``` - -## DESCRIPTION -{{ Fill in the Description }} - -## EXAMPLES - -### EXAMPLE 1 -``` -Write-VisibleString.ps1 "a`tb`nc" -``` - -a 09 b 0a c - -## PARAMETERS - -### -InputObject -The string to show. - -```yaml -Type: Object -Parameter Sets: (All) -Aliases: - -Required: True -Position: 1 -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -AsRunes -Parse Runes from the string rather than Chars. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UseSymbols -Print control characters as control picture symbols rather than hex values. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ProgressAction -{{ Fill ProgressAction Description }} - -```yaml -Type: ActionPreference -Parameter Sets: (All) -Aliases: proga - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Object to serialize with nonprintable characters made visible as a hex pair. -## OUTPUTS - -### System.Void -## NOTES - -## RELATED LINKS diff --git a/docs/index.md b/docs/index.md index fcbcd79c..43f5b492 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@ [![Pester tests status](https://github.com/brianary/scripts/actions/workflows/pester.yml/badge.svg)][pester.yml] [![Pester tests results](https://gist.githubusercontent.com/brianary/4642e5c804aa1b40738def5a7c03607a/raw/badge.svg)][pester.yml] -[![Pester tests coverage](https://img.shields.io/badge/Pester_coverage-3334_%E2%80%B1-orange +[![Pester tests coverage](https://img.shields.io/badge/Pester_coverage-3471_%E2%80%B1-orange red)](https://github.com/brianary/scripts/tree/main/test) [![GitHub license badge](https://badgen.net/github/license/brianary/Scripts?icon=github)](https://mit-license.org/ "MIT License") [![GitHub stars badge](https://badgen.net/github/stars/brianary/Scripts?icon=github)](https://github.com/brianary/scripts/stargazers "Stars") @@ -18,340 +18,229 @@ red)](https://github.com/brianary/scripts/tree/main/test) Scripts from the [Scripts](https://github.com/brianary/Scripts/) repo. - -### Clipboard - -- **[Convert-ClipboardTsvToHtml.ps1](Convert-ClipboardTsvToHtml.ps1.md)**: Parses TSV clipboard data into HTML table data which is copied back to the clipboard. -- **[Import-ClipboardTsv.ps1](Import-ClipboardTsv.ps1.md)**: Parses TSV clipboard data into objects. - -### Command - -- **[Get-CommandParameters.ps1](Get-CommandParameters.ps1.md)**: Returns the parameters of the specified cmdlet. -- **[Get-CommandPath.ps1](Get-CommandPath.ps1.md)**: Locates a command. -- **[Hide-Command.ps1](Hide-Command.ps1.md)**: Make a command unavailable. -- **[Invoke-CachedCommand.ps1](Invoke-CachedCommand.ps1.md)**: Caches the output of a command for recall if called again. -- **[Invoke-CommandWithParams.ps1](Invoke-CommandWithParams.ps1.md)**: Execute a command by using matching dictionary entries as parameters. -- **[Use-Command.ps1](Use-Command.ps1.md)**: Checks for the existence of the given command, and adds if missing and a source is defined. - -### Configuration - -- **[Get-ConfigConnectionStringBuilders.ps1](Get-ConfigConnectionStringBuilders.ps1.md)**: Return named connection string builders for connection strings in a config file. -- **[Get-NuGetConfigs.ps1](Get-NuGetConfigs.ps1.md)**: Returns the available NuGet configuration files, in order of preference. -- **[Use-NetMailConfig.ps1](Use-NetMailConfig.ps1.md)**: Use .NET configuration to set defaults for Send-MailMessage. - -### Console - -- **[Disable-AnsiColor.ps1](Disable-AnsiColor.ps1.md)**: Disables ANSI terminal colors. -- **[Enable-AnsiColor.ps1](Enable-AnsiColor.ps1.md)**: Enables ANSI terminal colors. -- **[Get-ConsoleHistory.ps1](Get-ConsoleHistory.ps1.md)**: Returns the DOSKey-style console command history (up arrow or F8). -- **[Remove-ConsoleHistory.ps1](Remove-ConsoleHistory.ps1.md)**: Removes an entry from the DOSKey-style console command history (up arrow or F8). -- **[Set-ConsoleColorTheme.ps1](Set-ConsoleColorTheme.ps1.md)**: Overrides ConsoleClass window color palette entries with a preset color theme. - -### Credential - -- **[Export-SecretVault.ps1](Export-SecretVault.ps1.md)**: Exports secret vault content. -- **[Get-CachedCredential.ps1](Get-CachedCredential.ps1.md)**: Return a credential from secure storage, or prompt the user for it if not found. -- **[Get-SecretDetails.ps1](Get-SecretDetails.ps1.md)**: Returns secret info from the secret vaults, including metadata as properties. -- **[Import-SecretVault.ps1](Import-SecretVault.ps1.md)**: Imports secrets into secret vaults. -- **[Remove-CachedCredential.ps1](Remove-CachedCredential.ps1.md)**: Removes a credential from secure storage. -- **[Save-Secret.ps1](Save-Secret.ps1.md)**: Sets a secret in a secret vault with metadata. - -### Data - -- **[Limit-Digits.ps1](Limit-Digits.ps1.md)**: Rounds off a number to the requested number of digits. -- **[Measure-Properties.ps1](Measure-Properties.ps1.md)**: Provides frequency details about the properties across objects in the pipeline. -- **[Measure-Values.ps1](Measure-Values.ps1.md)**: Provides analysis of supplied values. - -### Data encoding - -- **[ConvertFrom-Base64.ps1](ConvertFrom-Base64.ps1.md)**: Converts base64-encoded text to bytes or text. -- **[ConvertFrom-Hex.ps1](ConvertFrom-Hex.ps1.md)**: Convert a string of hexadecimal digits into a byte array. -- **[ConvertTo-Base64.ps1](ConvertTo-Base64.ps1.md)**: Converts bytes or text to base64-encoded text. - -### Data formats - -- **[ConvertTo-PowerShell.ps1](ConvertTo-PowerShell.ps1.md)**: Serializes complex content into PowerShell literals. -- **[Format-EscapedUrl.ps1](Format-EscapedUrl.ps1.md)**: Escape URLs more aggressively. -- **[New-Jwt.ps1](New-Jwt.ps1.md)**: Generates a JSON Web Token (JWT) -- **[Split-Uri.ps1](Split-Uri.ps1.md)**: Splits a URI into component parts. -- **[Test-FileTypeMagicNumber.ps1](Test-FileTypeMagicNumber.ps1.md)**: Tests for a given common file type by magic number. -- **[Test-Jwt.ps1](Test-Jwt.ps1.md)**: Determines whether a string is a valid JWT. -- **[Test-MagicNumber.ps1](Test-MagicNumber.ps1.md)**: Tests a file for a "magic number" (identifying sequence of bytes) at a given location. -- **[Test-Uri.ps1](Test-Uri.ps1.md)**: Determines whether a string is a valid URI. -- **[Test-Windows1252.ps1](Test-Windows1252.ps1.md)**: Determines whether a file contains Windows-1252 bytes that are invalid UTF-8 bytes. - -### Database - -- **[ConvertFrom-DataRow.ps1](ConvertFrom-DataRow.ps1.md)**: Converts a DataRow object to a PSObject, Hashtable, or single value. -- **[Export-DatabaseScripts.ps1](Export-DatabaseScripts.ps1.md)**: Exports MS SQL database objects from the given server and database as files, into a consistent folder structure. -- **[Export-TableMerge.ps1](Export-TableMerge.ps1.md)**: Exports table data as a T-SQL MERGE statement. -- **[Find-DatabaseValue.ps1](Find-DatabaseValue.ps1.md)**: Searches an entire database for a field value. -- **[Find-DbColumn.ps1](Find-DbColumn.ps1.md)**: Searches for database columns. -- **[Find-DbIndexes.ps1](Find-DbIndexes.ps1.md)**: Returns indexes using a column with the given name. -- **[Initialize-DatabaseNotebook.ps1](Initialize-DatabaseNotebook.ps1.md)**: Populates a new notebook with details about a database. -- **[Measure-DbColumn.ps1](Measure-DbColumn.ps1.md)**: Provides statistics about SQL Server column data. -- **[Measure-DbColumnValues.ps1](Measure-DbColumnValues.ps1.md)**: Provides sorted counts of SQL Server column values. -- **[Measure-DbTable.ps1](Measure-DbTable.ps1.md)**: Provides frequency details about SQL Server table data. -- **[New-DbProviderObject.ps1](New-DbProviderObject.ps1.md)**: Create a common database object. -- **[Repair-DatabaseConstraintNames.ps1](Repair-DatabaseConstraintNames.ps1.md)**: Finds database constraints with system-generated names and gives them deterministic names. -- **[Repair-DatabaseUntrustedConstraints.ps1](Repair-DatabaseUntrustedConstraints.ps1.md)**: Finds database constraints that have been incompletely re-enabled. -- **[Send-SqlReport.ps1](Send-SqlReport.ps1.md)**: Execute a SQL statement and email the results. -- **[Test-ConnectionString.ps1](Test-ConnectionString.ps1.md)**: Test a given connection string and provide details about the connection. -- **[Use-SqlcmdParams.ps1](Use-SqlcmdParams.ps1.md)**: Use the calling script parameters to set Invoke-Sqlcmd defaults. - -### Date and time - -- **[Add-TimeSpan.ps1](Add-TimeSpan.ps1.md)**: Adds a timespan to DateTime values. -- **[ConvertFrom-Duration.ps1](ConvertFrom-Duration.ps1.md)**: Parses a Timespan from a ISO8601 duration string. -- **[ConvertFrom-EpochTime.ps1](ConvertFrom-EpochTime.ps1.md)**: Converts an integer Unix (POSIX) time (seconds since Jan 1, 1970) into a DateTime value. -- **[ConvertFrom-IsoWeekDate.ps1](ConvertFrom-IsoWeekDate.ps1.md)**: Returns a DateTime object from an ISO week date string. -- **[ConvertTo-EpochTime.ps1](ConvertTo-EpochTime.ps1.md)**: Converts a DateTime value into an integer Unix (POSIX) time, seconds since Jan 1, 1970. -- **[ConvertTo-LogParserTimestamp.ps1](ConvertTo-LogParserTimestamp.ps1.md)**: Formats a datetime as a LogParser literal. -- **[Format-Date.ps1](Format-Date.ps1.md)**: Returns a date/time as a named format. -- **[Get-FrenchRepublicanDate.ps1](Get-FrenchRepublicanDate.ps1.md)**: Returns a date and time converted to the French Republican Calendar. -- **[Show-Time.ps1](Show-Time.ps1.md)**: Displays a formatted date using powerline font characters. -- **[Test-DateTime.ps1](Test-DateTime.ps1.md)**: Tests whether the given string can be parsed as a date. -- **[Test-USFederalHoliday.ps1](Test-USFederalHoliday.ps1.md)**: Returns true if the given date is a U.S. federal holiday. - -### Dictionary - -- **[Compare-Keys.ps1](Compare-Keys.ps1.md)**: Returns the differences between two dictionaries. -- **[ConvertTo-OrderedDictionary.ps1](ConvertTo-OrderedDictionary.ps1.md)**: Converts an object to an ordered dictionary of properties and values. -- **[Join-Keys.ps1](Join-Keys.ps1.md)**: Combines dictionaries together into a single dictionary. -- **[Remove-NullValues.ps1](Remove-NullValues.ps1.md)**: Removes dictionary entries with null vaules. -- **[Split-Keys.ps1](Split-Keys.ps1.md)**: Clones a dictionary keeping only the specified keys. - -### DotNet - -- **[Find-DotNetTools.ps1](Find-DotNetTools.ps1.md)**: Returns a list of matching dotnet tools. -- **[Get-AssemblyFramework.ps1](Get-AssemblyFramework.ps1.md)**: Gets the framework version an assembly was compiled for. -- **[Get-DotNetFrameworkVersions.ps1](Get-DotNetFrameworkVersions.ps1.md)**: Determine which .NET Frameworks are installed on the requested system. -- **[Get-DotNetGlobalTools.ps1](Get-DotNetGlobalTools.ps1.md)**: Returns a list of global dotnet tools. -- **[Get-DotNetVersions.ps1](Get-DotNetVersions.ps1.md)**: Determine which .NET Core & Framework versions are installed. -- **[Update-DotNetPackages.ps1](Update-DotNetPackages.ps1.md)**: Updates NuGet packages for a .NET solution or project. - -### EnvironmentVariables - -- **[Compress-EnvironmentVariables.ps1](Compress-EnvironmentVariables.ps1.md)**: Replaces each of the longest matching parts of a string with an embedded environment variable with that value. -- **[Expand-EnvironmentVariables.ps1](Expand-EnvironmentVariables.ps1.md)**: Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string. - -### Files - -- **[Backup-File.ps1](Backup-File.ps1.md)**: Create a backup as a sibling to a file, with date and time values in the name. -- **[Find-NewestFile.ps1](Find-NewestFile.ps1.md)**: Finds the most recent file. -- **[Join-FileName.ps1](Join-FileName.ps1.md)**: Combines a filename with a string. -- **[Measure-Caches.ps1](Measure-Caches.ps1.md)**: Returns a list of matching cache directories, and their sizes, sorted. -- **[New-Shortcut.ps1](New-Shortcut.ps1.md)**: Create a Windows shortcut. -- **[Remove-LockyFile.ps1](Remove-LockyFile.ps1.md)**: Removes a file that may be prone to locking. -- **[Show-PSDriveUsage.ps1](Show-PSDriveUsage.ps1.md)**: Displays drive usage graphically, and with a human-readable summary. -- **[Test-LockedFile.ps1](Test-LockedFile.ps1.md)**: Returns true if the specified file is locked. -- **[Test-NewerFile.ps1](Test-NewerFile.ps1.md)**: Returns true if the difference file is newer than the reference file. -- **[Update-Files.ps1](Update-Files.ps1.md)**: Copies specified source files that exist in the destination directory. - -### Git and GitHub - -- **[Add-GitHubMetadata.ps1](Add-GitHubMetadata.ps1.md)**: Adds GitHub Linguist overrides to a repo's .gitattributes. -- **[Copy-GitHubLabels.ps1](Copy-GitHubLabels.ps1.md)**: Copies configured issue labels from one repo to another. -- **[Get-GitFileMetadata.ps1](Get-GitFileMetadata.ps1.md)**: Returns the creation and last modification metadata for a file in a git repo. -- **[Get-GitFirstCommit.ps1](Get-GitFirstCommit.ps1.md)**: Gets the SHA-1 hash of the first commit of the current repo. -- **[Get-RepoName.ps1](Get-RepoName.ps1.md)**: Gets the name of the repo. -- **[Rename-GitHubLocalBranch.ps1](Rename-GitHubLocalBranch.ps1.md)**: Rename a git repository branch. -- **[Trace-GitRepoTest.ps1](Trace-GitRepoTest.ps1.md)**: Uses git bisect to search for the point in the repo history that the test script starts returning true. - -### HTTP - -- **[ConvertTo-BasicAuthentication.ps1](ConvertTo-BasicAuthentication.ps1.md)**: Produces a basic authentication header string from a credential. -- **[ConvertTo-MultipartFormData.ps1](ConvertTo-MultipartFormData.ps1.md)**: Creates multipart/form-data to send as a request body. -- **[Get-ContentSecurityPolicy.ps1](Get-ContentSecurityPolicy.ps1.md)**: Returns the content security policy at from the given URL. -- **[Get-SslDetails.ps1](Get-SslDetails.ps1.md)**: Enumerates the SSL protocols that the client is able to successfully use to connect to a server. -- **[Save-WebRequest.ps1](Save-WebRequest.ps1.md)**: Downloads a given URL to a file, automatically determining the filename. -- **[Show-HttpStatus.ps1](Show-HttpStatus.ps1.md)**: Displays the HTTP status code info. -- **[Trace-WebRequest.ps1](Trace-WebRequest.ps1.md)**: Provides details about a retrieving a URI. - -### Json - -- **[Export-Json.ps1](Export-Json.ps1.md)**: Exports a portion of a JSON document, recursively importing references. -- **[Export-OpenApiSchema.ps1](Export-OpenApiSchema.ps1.md)**: Extracts a JSON schema from an OpenAPI definition. -- **[Get-OpenApiInfo.ps1](Get-OpenApiInfo.ps1.md)**: Returns metadata from an OpenAPI definition. -- **[Merge-Json.ps1](Merge-Json.ps1.md)**: Create a new JSON string by recursively combining the properties of JSON strings. -- **[Resolve-JsonPointer.ps1](Resolve-JsonPointer.ps1.md)**: Returns matching JSON Pointer paths, given a JSON Pointer path with wildcards. -- **[Select-Json.ps1](Select-Json.ps1.md)**: Returns a value from a JSON string or file. -- **[Set-Json.ps1](Set-Json.ps1.md)**: Sets a property in a JSON string or file. -- **[Show-OpenApiInfo.ps1](Show-OpenApiInfo.ps1.md)**: Displays metadata from an OpenAPI definition. - -### Markdown - -- **[Repair-MarkdownHeaders.ps1](Repair-MarkdownHeaders.ps1.md)**: Updates markdown content to replace level 1 & 2 ATX headers to Setext headers. - -### Mermaid Diagrams - -- **[Export-MermaidER.ps1](Export-MermaidER.ps1.md)**: Generates a Mermaid entity relation diagram for database tables. -- **[Export-MermaidXY.ps1](Export-MermaidXY.ps1.md)**: Generates a Mermaid XY bar/line chart for the values of a series of properties. - -### Notebooks - -- **[Add-NotebookCell.ps1](Add-NotebookCell.ps1.md)**: When run within a Polyglot Notebook, appends a cell to it. - -### Packages and libraries - -- **[Find-ProjectPackages.ps1](Find-ProjectPackages.ps1.md)**: Find modules used in projects. -- **[Get-LibraryVulnerabilityInfo.ps1](Get-LibraryVulnerabilityInfo.ps1.md)**: Get the list of module/package/library vulnerabilities from the RetireJS or SafeNuGet projects. - -### Parameters - -- **[Add-ParameterDefault.ps1](Add-ParameterDefault.ps1.md)**: Appends or creates a value to use for the specified cmdlet parameter to use when one is not specified. -- **[Remove-ParameterDefault.ps1](Remove-ParameterDefault.ps1.md)**: Removes a value that would have been used for a parameter if none was specified, if one existed. -- **[Set-ParameterDefault.ps1](Set-ParameterDefault.ps1.md)**: Assigns a value to use for the specified cmdlet parameter to use when one is not specified. - -### PowerShell - -- **[Add-Counter.ps1](Add-Counter.ps1.md)**: Adds an incrementing integer property to each pipeline object. -- **[Add-DynamicParam.ps1](Add-DynamicParam.ps1.md)**: Adds a dynamic parameter to a script, within a DynamicParam block. -- 🆙 **[Add-NugetPackage.ps1](Add-NugetPackage.ps1.md)**: Loads a NuGet package DLL, downloading as needed. -- **[Add-ScopeLevel.ps1](Add-ScopeLevel.ps1.md)**: Convert a scope level to account for another call stack level. -- **[ForEach-Progress.ps1](ForEach-Progress.ps1.md)**: Performs an operation against each item in a collection of input objects, with a progress bar. -- **[Format-ByteUnits.ps1](Format-ByteUnits.ps1.md)**: Converts bytes to largest possible units, to improve readability. -- **[Format-Permutations.ps1](Format-Permutations.ps1.md)**: Builds format strings using every combination of elements from multiple arrays. -- **[Get-EnumValues.ps1](Get-EnumValues.ps1.md)**: Returns the possible values of the specified enumeration. -- **[Get-TypeAccelerators.ps1](Get-TypeAccelerators.ps1.md)**: Returns the list of PowerShell type accelerators. -- **[Import-Variables.ps1](Import-Variables.ps1.md)**: Creates local variables from a data row or dictionary (hashtable). -- **[Invoke-WindowsPowerShell.ps1](Invoke-WindowsPowerShell.ps1.md)**: Runs commands in Windows PowerShell (typically from PowerShell Core). -- **[Merge-PSObject.ps1](Merge-PSObject.ps1.md)**: Create a new PSObject by recursively combining the properties of PSObjects. -- **[Read-Choice.ps1](Read-Choice.ps1.md)**: Returns choice selected from a list of options. -- **[Stop-ThrowError.ps1](Stop-ThrowError.ps1.md)**: Throws a better error than "throw". -- 🆙 **[Test-Administrator.ps1](Test-Administrator.ps1.md)**: Checks whether the current session has administrator privileges. -- **[Test-Interactive.ps1](Test-Interactive.ps1.md)**: Determines whether both the user and process are interactive. -- **[Test-Range.ps1](Test-Range.ps1.md)**: Returns true from an initial condition until a terminating condition; a latching test. -- **[Test-Variable.ps1](Test-Variable.ps1.md)**: Indicates whether a variable has been defined. -- **[Use-ProgressView.ps1](Use-ProgressView.ps1.md)**: Sets the progress bar display view. -- **[Use-ReasonableDefaults.ps1](Use-ReasonableDefaults.ps1.md)**: Sets certain cmdlet parameter defaults to rational, useful values. -- **[Write-Info.ps1](Write-Info.ps1.md)**: Writes to the information stream, with color support and more. - -### PowerShell Modules - -- **[Get-ModuleScope.ps1](Get-ModuleScope.ps1.md)**: Returns the scope of an installed module. -- **[Uninstall-OldModules.ps1](Uninstall-OldModules.ps1.md)**: Uninstalls old module versions. -- **[Update-Modules.ps1](Update-Modules.ps1.md)**: Cleans up old modules. - -### Properties - -- **[Add-NoteProperty.ps1](Add-NoteProperty.ps1.md)**: Adds a NoteProperty to a PSObject, calculating the value with the object in context. -- **[Compare-Properties.ps1](Compare-Properties.ps1.md)**: Compares the properties of two objects. -- **[Test-NoteProperty.ps1](Test-NoteProperty.ps1.md)**: Looks for any matching NoteProperties on an object. - -### Scheduled Tasks - -- **[Backup-SchTasks.ps1](Backup-SchTasks.ps1.md)**: Exports the local list of Scheduled Tasks into a single XML file. -- **[ConvertFrom-CimInstance.ps1](ConvertFrom-CimInstance.ps1.md)**: Convert a CimInstance object to a PSObject. -- **[ConvertTo-ICalendar.ps1](ConvertTo-ICalendar.ps1.md)**: Converts supported objects (Scheduled Tasks) to the RFC 5545 iCalendar format. -- **[Copy-SchTasks.ps1](Copy-SchTasks.ps1.md)**: Copy scheduled jobs from another computer to this one, using a GUI list to choose jobs. -- **[Get-SimpleSchTasks.ps1](Get-SimpleSchTasks.ps1.md)**: Returns simple scheduled task info. -- **[Restore-SchTasks.ps1](Restore-SchTasks.ps1.md)**: Imports from a single XML file into the local Scheduled Tasks. -- **[Set-SchTaskMsa.ps1](Set-SchTaskMsa.ps1.md)**: Sets a Scheduled Task's runtime user as the given gMSA/MSA. - -### Scripts - -- **[New-PesterTests.ps1](New-PesterTests.ps1.md)**: Creates a new Pester testing script from a script's examples and parameter sets. -- **[New-Script.ps1](New-Script.ps1.md)**: Creates a simple boilerplate script. -- **[Optimize-Help.ps1](Optimize-Help.ps1.md)**: Cleans up comment-based help blocks by fully unindenting and capitalizing dot keywords. -- **[Rename-Script.ps1](Rename-Script.ps1.md)**: Renames all instances of a script, and updates any usage of it. -- **[Repair-ScriptStyle.ps1](Repair-ScriptStyle.ps1.md)**: Accepts justifications for script analysis rule violations, fixing the rest using Invoke-ScriptAnalysis. -- **[Select-ScriptCommands.ps1](Select-ScriptCommands.ps1.md)**: Returns the commands used by the specified script. - -### Search and replace - -- **[Add-CapturesToMatches.ps1](Add-CapturesToMatches.ps1.md)**: Adds named capture group values as note properties to Select-String MatchInfo objects. -- **[Find-Lines.ps1](Find-Lines.ps1.md)**: Searches a specific subset of files for lines matching a pattern. -- **[Select-CapturesFromMatches.ps1](Select-CapturesFromMatches.ps1.md)**: Selects named capture group values as note properties from Select-String MatchInfo objects. -- **[Set-RegexReplace.ps1](Set-RegexReplace.ps1.md)**: Updates text found with Select-String, using a regular expression replacement template. - -### Seq - -- **[Send-SeqEvent.ps1](Send-SeqEvent.ps1.md)**: Send an event to a Seq server. -- **[Send-SeqScriptEvent.ps1](Send-SeqScriptEvent.ps1.md)**: Sends an event (often an error) from a script to a Seq server, including script info. -- **[Use-SeqServer.ps1](Use-SeqServer.ps1.md)**: Set the default Server and ApiKey for Send-SeqEvent.ps1 - -### System and updates - -- **[Convert-ChocolateyToWinget.ps1](Convert-ChocolateyToWinget.ps1.md)**: Change from managing various packages with Chocolatey to WinGet. -- **[Export-EdgeKeywords.ps1](Export-EdgeKeywords.ps1.md)**: Returns the configured search keywords from an Edge SQLite file. -- **[Export-InstalledPackages.ps1](Export-InstalledPackages.ps1.md)**: Exports the list of packages installed by various tools. -- **[Find-InstalledPrograms.ps1](Find-InstalledPrograms.ps1.md)**: Searches installed programs. -- **[Get-SystemDetails.ps1](Get-SystemDetails.ps1.md)**: Collects some useful system hardware and operating system details via CIM. -- **[Import-EdgeKeywords.ps1](Import-EdgeKeywords.ps1.md)**: Adds search keywords to an Edge SQLite profile configuration. -- **[Read-ChocolateySummary.ps1](Read-ChocolateySummary.ps1.md)**: Retrieves the a summary from the Chocolatey log. -- 🆕 **[Show-Status.ps1](Show-Status.ps1.md)**: Displays requested system status values using powerline font characters. -- 🆙 **[Update-Everything.ps1](Update-Everything.ps1.md)**: Updates everything it can on the system. -- **[Use-Java.ps1](Use-Java.ps1.md)**: Switch the Java version for the current process by modifying environment variables. - -### TLS/SSL - -- **[Get-ServerCertificate.ps1](Get-ServerCertificate.ps1.md)**: Returns the certificate provided by the requested server. - -### Unicode - -- **[ConvertTo-FileName.ps1](ConvertTo-FileName.ps1.md)**: Returns a valid and safe filename from a given string. -- **[ConvertTo-SafeEntities.ps1](ConvertTo-SafeEntities.ps1.md)**: Encode text as XML/HTML, escaping all characters outside 7-bit ASCII. -- **[Get-CharacterDetails.ps1](Get-CharacterDetails.ps1.md)**: Returns filterable categorical information about characters in the Unicode Basic Multilingual Plane. -- **[Get-Unicode.ps1](Get-Unicode.ps1.md)**: Returns the (UTF-16) .NET string for a given Unicode codepoint, which may be a surrogate pair. -- **[Get-UnicodeByName.ps1](Get-UnicodeByName.ps1.md)**: Returns characters based on Unicode code point name, GitHub short code, or HTML entity. -- **[Get-UnicodeData.ps1](Get-UnicodeData.ps1.md)**: Returns the current (cached) Unicode character data. -- **[Get-UnicodeName.ps1](Get-UnicodeName.ps1.md)**: Returns the name of a Unicode code point. -- 🆙 **[Import-CharConstants.ps1](Import-CharConstants.ps1.md)**: Imports characters by name as constants into the current scope. - -### VSCode - -- **[Add-VsCodeDatabaseConnection.ps1](Add-VsCodeDatabaseConnection.ps1.md)**: Adds a VS Code MSSQL database connection to the repo. -- **[Get-VSCCurrentFile.ps1](Get-VSCCurrentFile.ps1.md)**: Returns the path of the current file open in VSCode, when run in the PowerShell Extension Terminal in VSCode. -- **[Get-VSCodeSetting.ps1](Get-VSCodeSetting.ps1.md)**: Sets a VSCode setting. -- **[Get-VSCodeSettingsFile.ps1](Get-VSCodeSettingsFile.ps1.md)**: Gets the path of the VSCode settings.config file. -- **[Import-VsCodeDatabaseConnections.ps1](Import-VsCodeDatabaseConnections.ps1.md)**: Adds config XDT connection strings to VSCode settings. -- **[Push-WorkspaceLocation.ps1](Push-WorkspaceLocation.ps1.md)**: Pushes the current VS Code editor workspace location to the location stack. -- **[Set-VSCodeSetting.ps1](Set-VSCodeSetting.ps1.md)**: Sets a VSCode setting. - -### XML - -- **[Compare-Xml.ps1](Compare-Xml.ps1.md)**: Compares two XML documents and returns the differences. -- **[Convert-Xml.ps1](Convert-Xml.ps1.md)**: Transform XML using an XSLT template. -- **[ConvertFrom-EscapedXml.ps1](ConvertFrom-EscapedXml.ps1.md)**: Parse escaped XML into XML and serialize it. -- **[ConvertFrom-XmlElement.ps1](ConvertFrom-XmlElement.ps1.md)**: Converts named nodes of an element to properties of a PSObject, recursively. -- **[ConvertTo-XmlElements.ps1](ConvertTo-XmlElements.ps1.md)**: Serializes complex content into XML elements. -- **[Format-Xml.ps1](Format-Xml.ps1.md)**: Pretty-print XML. -- **[Get-XmlNamespaces.ps1](Get-XmlNamespaces.ps1.md)**: Gets the namespaces from a document as a dictionary. -- **[Merge-XmlSelections.ps1](Merge-XmlSelections.ps1.md)**: Builds an object using the named XPath selections as properties. -- **[New-NamespaceManager.ps1](New-NamespaceManager.ps1.md)**: Creates an object to lookup XML namespace prefixes. -- **[Resolve-XmlSchemaLocation.ps1](Resolve-XmlSchemaLocation.ps1.md)**: Gets the namespaces and their URIs and URLs from a document. -- **[Resolve-XPath.ps1](Resolve-XPath.ps1.md)**: Returns the XPath of the location of an XML node. -- **[Show-DataRef.ps1](Show-DataRef.ps1.md)**: Display an HTML view of an XML schema or WSDL using Saxon. -- **[Test-Xml.ps1](Test-Xml.ps1.md)**: Try parsing text as XML, and validating it if a schema is provided. - -### Other - -- **[Backup-Workstation.ps1](Backup-Workstation.ps1.md)**: Adds various configuration files and exported settings to a ZIP file. -- **[Connect-SshKey.ps1](Connect-SshKey.ps1.md)**: Uses OpenSSH to generate a key and connect it to an ssh server. -- **[ConvertTo-RomanNumeral.ps1](ConvertTo-RomanNumeral.ps1.md)**: Convert a number to a Roman numeral. -- **[Copy-Html.ps1](Copy-Html.ps1.md)**: Copies objects as an HTML table. -- 🆙 **[Export-Readme.ps1](Export-Readme.ps1.md)**: Generate README.md file for the scripts repo. -- **[Format-HtmlDataTable.ps1](Format-HtmlDataTable.ps1.md)**: Right-aligns numeric data in an HTML table for emailing, and optionally zebra-stripes &c. -- **[Get-ADServiceAccountInfo.ps1](Get-ADServiceAccountInfo.ps1.md)**: Lists the Global Managed Service Accounts for the domain, including the computers they are bound to. -- **[Get-AspNetEvents.ps1](Get-AspNetEvents.ps1.md)**: Parses ASP.NET errors from the event log on the given server. -- **[Get-Dns.ps1](Get-Dns.ps1.md)**: Looks up DNS info, given a hostname or address. -- **[Get-GitHubRepoChildItem.ps1](Get-GitHubRepoChildItem.ps1.md)**: Gets the items and child items in one or more specified locations. -- **[Get-IisLog.ps1](Get-IisLog.ps1.md)**: Easily query IIS logs. -- **[Get-PathUsage.ps1](Get-PathUsage.ps1.md)**: Returns the list of directories in the path, and the commands found in each. -- **[Get-PocketArticles.ps1](Get-PocketArticles.ps1.md)**: Retrieves a list of saved articles from a Pocket account. -- **[Get-RandomBytes.ps1](Get-RandomBytes.ps1.md)**: Returns random bytes. -- **[Get-Todos.ps1](Get-Todos.ps1.md)**: Returns the TODOs for the current git repo, which can help document technical debt. -- **[Measure-Indents.ps1](Measure-Indents.ps1.md)**: Measures the indentation characters used in a text file. -- **[Measure-StandardDeviation.ps1](Measure-StandardDeviation.ps1.md)**: Calculate the standard deviation of numeric values. -- **[Measure-TextFile.ps1](Measure-TextFile.ps1.md)**: Counts each type of indent and line ending. -- **[New-RandomVehicle.ps1](New-RandomVehicle.ps1.md)**: Generates random vehicle details with a valid VIN. -- **[Optimize-Path.ps1](Optimize-Path.ps1.md)**: Sorts, prunes, and normalizes both user and system Path entries. -- **[Remove-PocketArticle.ps1](Remove-PocketArticle.ps1.md)**: Removes an article from a Pocket account. -- **[Repair-AppxPackages.ps1](Repair-AppxPackages.ps1.md)**: Re-registers all installed Appx packages. -- **[Restore-Workstation.ps1](Restore-Workstation.ps1.md)**: Restores various configuration files and exported settings from a ZIP file. -- **[Save-PodcastEpisodes.ps1](Save-PodcastEpisodes.ps1.md)**: Downloads enclosures from a podcast feed. -- **[Send-MailMessageFile.ps1](Send-MailMessageFile.ps1.md)**: Sends emails from a drop folder using .NET config defaults. -- **[Test-HttpSecurity.ps1](Test-HttpSecurity.ps1.md)**: Scan sites using Mozilla's Observatory. -- 🆙 **[Write-CallInfo.ps1](Write-CallInfo.ps1.md)**: Prints caller name and parameters to the host for debugging purposes. -- **[Write-VisibleString.ps1](Write-VisibleString.ps1.md)**: Displays a string, showing nonprintable characters. + +### Command + +- **[Hide-Command.ps1](Hide-Command.ps1.md)**: Make a command unavailable. +- **[Invoke-CommandWithParams.ps1](Invoke-CommandWithParams.ps1.md)**: Execute a command by using matching dictionary entries as parameters. +- **[Use-Command.ps1](Use-Command.ps1.md)**: Checks for the existence of the given command, and adds if missing and a source is defined. + +### Configuration + +- **[Get-ConfigConnectionStringBuilders.ps1](Get-ConfigConnectionStringBuilders.ps1.md)**: Return named connection string builders for connection strings in a config file. +- **[Get-NuGetConfigs.ps1](Get-NuGetConfigs.ps1.md)**: Returns the available NuGet configuration files, in order of preference. +- **[Use-NetMailConfig.ps1](Use-NetMailConfig.ps1.md)**: Use .NET configuration to set defaults for Send-MailMessage. + +### Console + +- **[Set-ConsoleColorTheme.ps1](Set-ConsoleColorTheme.ps1.md)**: Overrides ConsoleClass window color palette entries with a preset color theme. + +### Credential + +- **[Export-SecretVault.ps1](Export-SecretVault.ps1.md)**: Exports secret vault content. +- **[Get-CachedCredential.ps1](Get-CachedCredential.ps1.md)**: Return a credential from secure storage, or prompt the user for it if not found. +- **[Get-SecretDetails.ps1](Get-SecretDetails.ps1.md)**: Returns secret info from the secret vaults, including metadata as properties. +- **[Import-SecretVault.ps1](Import-SecretVault.ps1.md)**: Imports secrets into secret vaults. +- **[Remove-CachedCredential.ps1](Remove-CachedCredential.ps1.md)**: Removes a credential from secure storage. +- **[Save-Secret.ps1](Save-Secret.ps1.md)**: Sets a secret in a secret vault with metadata. + +### Data formats + +- **[New-Jwt.ps1](New-Jwt.ps1.md)**: Generates a JSON Web Token (JWT) +- **[Test-Jwt.ps1](Test-Jwt.ps1.md)**: Determines whether a string is a valid JWT. +- **[Test-Windows1252.ps1](Test-Windows1252.ps1.md)**: Determines whether a file contains Windows-1252 bytes that are invalid UTF-8 bytes. + +### Database + +- **[Export-DatabaseScripts.ps1](Export-DatabaseScripts.ps1.md)**: Exports MS SQL database objects from the given server and database as files, into a consistent folder structure. +- **[Export-TableMerge.ps1](Export-TableMerge.ps1.md)**: Exports table data as a T-SQL MERGE statement. +- **[Find-DatabaseValue.ps1](Find-DatabaseValue.ps1.md)**: Searches an entire database for a field value. +- **[Find-DbColumn.ps1](Find-DbColumn.ps1.md)**: Searches for database columns. +- **[Find-DbIndexes.ps1](Find-DbIndexes.ps1.md)**: Returns indexes using a column with the given name. +- **[Initialize-DatabaseNotebook.ps1](Initialize-DatabaseNotebook.ps1.md)**: Populates a new notebook with details about a database. +- **[Measure-DbColumn.ps1](Measure-DbColumn.ps1.md)**: Provides statistics about SQL Server column data. +- **[Measure-DbColumnValues.ps1](Measure-DbColumnValues.ps1.md)**: Provides sorted counts of SQL Server column values. +- **[Measure-DbTable.ps1](Measure-DbTable.ps1.md)**: Provides frequency details about SQL Server table data. +- **[New-DbProviderObject.ps1](New-DbProviderObject.ps1.md)**: Create a common database object. +- **[Repair-DatabaseConstraintNames.ps1](Repair-DatabaseConstraintNames.ps1.md)**: Finds database constraints with system-generated names and gives them deterministic names. +- **[Repair-DatabaseUntrustedConstraints.ps1](Repair-DatabaseUntrustedConstraints.ps1.md)**: Finds database constraints that have been incompletely re-enabled. +- **[Send-SqlReport.ps1](Send-SqlReport.ps1.md)**: Execute a SQL statement and email the results. +- **[Test-ConnectionString.ps1](Test-ConnectionString.ps1.md)**: Test a given connection string and provide details about the connection. +- **[Use-SqlcmdParams.ps1](Use-SqlcmdParams.ps1.md)**: Use the calling script parameters to set Invoke-Sqlcmd defaults. + +### Date and time + +- **[ConvertTo-LogParserTimestamp.ps1](ConvertTo-LogParserTimestamp.ps1.md)**: Formats a datetime as a LogParser literal. + +### DotNet + +- **[Find-DotNetTools.ps1](Find-DotNetTools.ps1.md)**: Returns a list of matching dotnet tools. +- **[Get-AssemblyFramework.ps1](Get-AssemblyFramework.ps1.md)**: Gets the framework version an assembly was compiled for. +- **[Get-DotNetFrameworkVersions.ps1](Get-DotNetFrameworkVersions.ps1.md)**: Determine which .NET Frameworks are installed on the requested system. +- **[Get-DotNetGlobalTools.ps1](Get-DotNetGlobalTools.ps1.md)**: Returns a list of global dotnet tools. +- **[Get-DotNetVersions.ps1](Get-DotNetVersions.ps1.md)**: Determine which .NET Core & Framework versions are installed. +- **[Update-DotNetPackages.ps1](Update-DotNetPackages.ps1.md)**: Updates NuGet packages for a .NET solution or project. + +### EnvironmentVariables + +- **[Compress-EnvironmentVariables.ps1](Compress-EnvironmentVariables.ps1.md)**: Replaces each of the longest matching parts of a string with an embedded environment variable with that value. + +### Files + +- **[Backup-File.ps1](Backup-File.ps1.md)**: Create a backup as a sibling to a file, with date and time values in the name. +- **[Join-FileName.ps1](Join-FileName.ps1.md)**: Combines a filename with a string. +- **[Measure-Caches.ps1](Measure-Caches.ps1.md)**: Returns a list of matching cache directories, and their sizes, sorted. +- **[New-Shortcut.ps1](New-Shortcut.ps1.md)**: Create a Windows shortcut. +- **[Remove-LockyFile.ps1](Remove-LockyFile.ps1.md)**: Removes a file that may be prone to locking. +- **[Test-LockedFile.ps1](Test-LockedFile.ps1.md)**: Returns true if the specified file is locked. + +### Git and GitHub + +- **[Add-GitHubMetadata.ps1](Add-GitHubMetadata.ps1.md)**: Adds GitHub Linguist overrides to a repo's .gitattributes. +- **[Copy-GitHubLabels.ps1](Copy-GitHubLabels.ps1.md)**: Copies configured issue labels from one repo to another. +- **[Get-GitFileMetadata.ps1](Get-GitFileMetadata.ps1.md)**: Returns the creation and last modification metadata for a file in a git repo. +- **[Get-GitFirstCommit.ps1](Get-GitFirstCommit.ps1.md)**: Gets the SHA-1 hash of the first commit of the current repo. +- **[Get-RepoName.ps1](Get-RepoName.ps1.md)**: Gets the name of the repo. +- **[Rename-GitHubLocalBranch.ps1](Rename-GitHubLocalBranch.ps1.md)**: Rename a git repository branch. +- **[Trace-GitRepoTest.ps1](Trace-GitRepoTest.ps1.md)**: Uses git bisect to search for the point in the repo history that the test script starts returning true. + +### HTTP + +- **[ConvertTo-BasicAuthentication.ps1](ConvertTo-BasicAuthentication.ps1.md)**: Produces a basic authentication header string from a credential. +- **[ConvertTo-MultipartFormData.ps1](ConvertTo-MultipartFormData.ps1.md)**: Creates multipart/form-data to send as a request body. +- **[Get-ContentSecurityPolicy.ps1](Get-ContentSecurityPolicy.ps1.md)**: Returns the content security policy at from the given URL. +- **[Get-SslDetails.ps1](Get-SslDetails.ps1.md)**: Enumerates the SSL protocols that the client is able to successfully use to connect to a server. +- **[Show-HttpStatus.ps1](Show-HttpStatus.ps1.md)**: Displays the HTTP status code info. + +### Json + +- **[Export-Json.ps1](Export-Json.ps1.md)**: Exports a portion of a JSON document, recursively importing references. +- **[Get-OpenApiInfo.ps1](Get-OpenApiInfo.ps1.md)**: Returns metadata from an OpenAPI definition. +- **[Merge-Json.ps1](Merge-Json.ps1.md)**: Create a new JSON string by recursively combining the properties of JSON strings. +- **[Resolve-JsonPointer.ps1](Resolve-JsonPointer.ps1.md)**: Returns matching JSON Pointer paths, given a JSON Pointer path with wildcards. +- **[Select-Json.ps1](Select-Json.ps1.md)**: Returns a value from a JSON string or file. +- **[Set-Json.ps1](Set-Json.ps1.md)**: Sets a property in a JSON string or file. + +### Mermaid Diagrams + +- **[Export-MermaidER.ps1](Export-MermaidER.ps1.md)**: Generates a Mermaid entity relation diagram for database tables. + +### Notebooks + +- **[Add-NotebookCell.ps1](Add-NotebookCell.ps1.md)**: When run within a Polyglot Notebook, appends a cell to it. + +### Packages and libraries + +- **[Find-ProjectPackages.ps1](Find-ProjectPackages.ps1.md)**: Find modules used in projects. +- **[Get-LibraryVulnerabilityInfo.ps1](Get-LibraryVulnerabilityInfo.ps1.md)**: Get the list of module/package/library vulnerabilities from the RetireJS or SafeNuGet projects. + +### PowerShell + +- **[Add-ScopeLevel.ps1](Add-ScopeLevel.ps1.md)**: Convert a scope level to account for another call stack level. + +### Scheduled Tasks + +- **[Backup-SchTasks.ps1](Backup-SchTasks.ps1.md)**: Exports the local list of Scheduled Tasks into a single XML file. +- **[ConvertTo-ICalendar.ps1](ConvertTo-ICalendar.ps1.md)**: Converts supported objects (Scheduled Tasks) to the RFC 5545 iCalendar format. +- **[Copy-SchTasks.ps1](Copy-SchTasks.ps1.md)**: Copy scheduled jobs from another computer to this one, using a GUI list to choose jobs. +- **[Get-SimpleSchTasks.ps1](Get-SimpleSchTasks.ps1.md)**: Returns simple scheduled task info. +- **[Restore-SchTasks.ps1](Restore-SchTasks.ps1.md)**: Imports from a single XML file into the local Scheduled Tasks. +- **[Set-SchTaskMsa.ps1](Set-SchTaskMsa.ps1.md)**: Sets a Scheduled Task's runtime user as the given gMSA/MSA. + +### Scripts + +- **[New-PesterTests.ps1](New-PesterTests.ps1.md)**: Creates a new Pester testing script from a script's examples and parameter sets. +- **[New-Script.ps1](New-Script.ps1.md)**: Creates a simple boilerplate script. +- **[Optimize-Help.ps1](Optimize-Help.ps1.md)**: Cleans up comment-based help blocks by fully unindenting and capitalizing dot keywords. +- **[Rename-Script.ps1](Rename-Script.ps1.md)**: Renames all instances of a script, and updates any usage of it. +- **[Repair-ScriptStyle.ps1](Repair-ScriptStyle.ps1.md)**: Accepts justifications for script analysis rule violations, fixing the rest using Invoke-ScriptAnalysis. + +### Search and replace + +- **[Find-Lines.ps1](Find-Lines.ps1.md)**: Searches a specific subset of files for lines matching a pattern. + +### Seq + +- **[Send-SeqEvent.ps1](Send-SeqEvent.ps1.md)**: Send an event to a Seq server. +- **[Send-SeqScriptEvent.ps1](Send-SeqScriptEvent.ps1.md)**: Sends an event (often an error) from a script to a Seq server, including script info. +- **[Use-SeqServer.ps1](Use-SeqServer.ps1.md)**: Set the default Server and ApiKey for Send-SeqEvent.ps1 + +### System and updates + +- **[Convert-ChocolateyToWinget.ps1](Convert-ChocolateyToWinget.ps1.md)**: Change from managing various packages with Chocolatey to WinGet. +- **[Export-EdgeKeywords.ps1](Export-EdgeKeywords.ps1.md)**: Returns the configured search keywords from an Edge SQLite file. +- **[Export-InstalledPackages.ps1](Export-InstalledPackages.ps1.md)**: Exports the list of packages installed by various tools. +- **[Find-InstalledPrograms.ps1](Find-InstalledPrograms.ps1.md)**: Searches installed programs. +- **[Get-SystemDetails.ps1](Get-SystemDetails.ps1.md)**: Collects some useful system hardware and operating system details via CIM. +- **[Import-EdgeKeywords.ps1](Import-EdgeKeywords.ps1.md)**: Adds search keywords to an Edge SQLite profile configuration. +- **[Read-ChocolateySummary.ps1](Read-ChocolateySummary.ps1.md)**: Retrieves the a summary from the Chocolatey log. +- **[Update-Everything.ps1](Update-Everything.ps1.md)**: Updates everything it can on the system. +- **[Use-Java.ps1](Use-Java.ps1.md)**: Switch the Java version for the current process by modifying environment variables. + +### TLS/SSL + +- **[Get-ServerCertificate.ps1](Get-ServerCertificate.ps1.md)**: Returns the certificate provided by the requested server. + +### Unicode + +- **[Get-CharacterDetails.ps1](Get-CharacterDetails.ps1.md)**: Returns filterable categorical information about characters in the Unicode Basic Multilingual Plane. +- **[Get-Unicode.ps1](Get-Unicode.ps1.md)**: Returns the (UTF-16) .NET string for a given Unicode codepoint, which may be a surrogate pair. +- **[Get-UnicodeByName.ps1](Get-UnicodeByName.ps1.md)**: Returns characters based on Unicode code point name, GitHub short code, or HTML entity. +- **[Get-UnicodeData.ps1](Get-UnicodeData.ps1.md)**: Returns the current (cached) Unicode character data. +- **[Get-UnicodeName.ps1](Get-UnicodeName.ps1.md)**: Returns the name of a Unicode code point. +- **[Import-CharConstants.ps1](Import-CharConstants.ps1.md)**: Imports characters by name as constants into the current scope. + +### VSCode + +- **[Add-VsCodeDatabaseConnection.ps1](Add-VsCodeDatabaseConnection.ps1.md)**: Adds a VS Code MSSQL database connection to the repo. +- **[Get-VSCCurrentFile.ps1](Get-VSCCurrentFile.ps1.md)**: Returns the path of the current file open in VSCode, when run in the PowerShell Extension Terminal in VSCode. +- **[Get-VSCodeSetting.ps1](Get-VSCodeSetting.ps1.md)**: Sets a VSCode setting. +- **[Get-VSCodeSettingsFile.ps1](Get-VSCodeSettingsFile.ps1.md)**: Gets the path of the VSCode settings.config file. +- **[Import-VsCodeDatabaseConnections.ps1](Import-VsCodeDatabaseConnections.ps1.md)**: Adds config XDT connection strings to VSCode settings. +- **[Push-WorkspaceLocation.ps1](Push-WorkspaceLocation.ps1.md)**: Pushes the current VS Code editor workspace location to the location stack. +- **[Set-VSCodeSetting.ps1](Set-VSCodeSetting.ps1.md)**: Sets a VSCode setting. + +### Windows Terminal + +- **[Set-TerminalProfile.ps1](Set-TerminalProfile.ps1.md)**: Adds or updates a Windows Terminal command profile. +- **[Test-WindowsTerminal.ps1](Test-WindowsTerminal.ps1.md)**: Returns true if PowerShell is running within Windows Terminal. + +### XML + +- **[Compare-Xml.ps1](Compare-Xml.ps1.md)**: Compares two XML documents and returns the differences. +- **[Convert-Xml.ps1](Convert-Xml.ps1.md)**: Transform XML using an XSLT template. +- **[ConvertFrom-EscapedXml.ps1](ConvertFrom-EscapedXml.ps1.md)**: Parse escaped XML into XML and serialize it. +- **[ConvertFrom-XmlElement.ps1](ConvertFrom-XmlElement.ps1.md)**: Converts named nodes of an element to properties of a PSObject, recursively. +- **[ConvertTo-XmlElements.ps1](ConvertTo-XmlElements.ps1.md)**: Serializes complex content into XML elements. +- **[Format-Xml.ps1](Format-Xml.ps1.md)**: Pretty-print XML. +- **[Get-XmlNamespaces.ps1](Get-XmlNamespaces.ps1.md)**: Gets the namespaces from a document as a dictionary. +- **[Merge-XmlSelections.ps1](Merge-XmlSelections.ps1.md)**: Builds an object using the named XPath selections as properties. +- **[New-NamespaceManager.ps1](New-NamespaceManager.ps1.md)**: Creates an object to lookup XML namespace prefixes. +- **[Resolve-XmlSchemaLocation.ps1](Resolve-XmlSchemaLocation.ps1.md)**: Gets the namespaces and their URIs and URLs from a document. +- **[Resolve-XPath.ps1](Resolve-XPath.ps1.md)**: Returns the XPath of the location of an XML node. +- **[Show-DataRef.ps1](Show-DataRef.ps1.md)**: Display an HTML view of an XML schema or WSDL using Saxon. +- **[Test-Xml.ps1](Test-Xml.ps1.md)**: Try parsing text as XML, and validating it if a schema is provided. + +### Other + +- **[Backup-Workstation.ps1](Backup-Workstation.ps1.md)**: Adds various configuration files and exported settings to a ZIP file. +- **[Connect-SshKey.ps1](Connect-SshKey.ps1.md)**: Uses OpenSSH to generate a key and connect it to an ssh server. +- 🆙 **[Export-Readme.ps1](Export-Readme.ps1.md)**: Generate README.md file for the scripts repo. +- **[Get-ADServiceAccountInfo.ps1](Get-ADServiceAccountInfo.ps1.md)**: Lists the Global Managed Service Accounts for the domain, including the computers they are bound to. +- **[Get-AspNetEvents.ps1](Get-AspNetEvents.ps1.md)**: Parses ASP.NET errors from the event log on the given server. +- **[Get-Dns.ps1](Get-Dns.ps1.md)**: Looks up DNS info, given a hostname or address. +- **[Get-GitHubRepoChildItem.ps1](Get-GitHubRepoChildItem.ps1.md)**: Gets the items and child items in one or more specified locations. +- **[Get-IisLog.ps1](Get-IisLog.ps1.md)**: Easily query IIS logs. +- **[Get-PathUsage.ps1](Get-PathUsage.ps1.md)**: Returns the list of directories in the path, and the commands found in each. +- **[Get-PocketArticles.ps1](Get-PocketArticles.ps1.md)**: Retrieves a list of saved articles from a Pocket account. +- **[Get-Todos.ps1](Get-Todos.ps1.md)**: Returns the TODOs for the current git repo, which can help document technical debt. +- **[Measure-Indents.ps1](Measure-Indents.ps1.md)**: Measures the indentation characters used in a text file. +- **[Measure-StandardDeviation.ps1](Measure-StandardDeviation.ps1.md)**: Calculate the standard deviation of numeric values. +- **[Measure-TextFile.ps1](Measure-TextFile.ps1.md)**: Counts each type of indent and line ending. +- **[New-RandomVehicle.ps1](New-RandomVehicle.ps1.md)**: Generates random vehicle details with a valid VIN. +- **[Optimize-Path.ps1](Optimize-Path.ps1.md)**: Sorts, prunes, and normalizes both user and system Path entries. +- **[Remove-PocketArticle.ps1](Remove-PocketArticle.ps1.md)**: Removes an article from a Pocket account. +- **[Repair-AppxPackages.ps1](Repair-AppxPackages.ps1.md)**: Re-registers all installed Appx packages. +- **[Restore-Workstation.ps1](Restore-Workstation.ps1.md)**: Restores various configuration files and exported settings from a ZIP file. +- **[Send-MailMessageFile.ps1](Send-MailMessageFile.ps1.md)**: Sends emails from a drop folder using .NET config defaults. +- **[Test-HttpSecurity.ps1](Test-HttpSecurity.ps1.md)**: Scan sites using Mozilla's Observatory. diff --git a/scripts-to-modules.json b/scripts-to-modules.json new file mode 100644 index 00000000..531e174b --- /dev/null +++ b/scripts-to-modules.json @@ -0,0 +1,159 @@ +[ + { + "module": "Networky", + "cmdlets": [ + "Connect-SshKey", + "ConvertTo-BasicAuthentication", + "ConvertTo-MultipartFormData", + "Get-ContentSecurityPolicy", + "Get-Dns", + "Get-ServerCertificate", + "Get-SslDetails", + "Save-PodcastEpisodes", + "Save-WebRequest", + "Show-HttpStatus", + "Test-HttpSecurity", + "Trace-WebRequest" + ] + }, + { + "module": "XML", + "cmdlets": [ + "Compare-Xml", + "Convert-Xml", + "ConvertFrom-EscapedXml", + "ConvertFrom-XmlElement", + "ConvertTo-XmlElements", + "Format-Xml", + "Get-XmlNamespaces", + "Merge-XmlSelections", + "New-NamespaceManager", + "Resolve-XmlSchemaLocation", + "Resolve-XPath", + "Test-Xml" + ] + }, + { + "module": "JSON", + "cmdlets": [ + "Export-Json", + "Merge-Json", + "Resolve-JsonPointer", + "Select-Json", + "Set-Json" + ] + }, + { + "module": "Development", + "cmdlets": [ + "Add-GitHubMetadata", + "Add-NotebookCell", + "Add-VsCodeDatabaseConnection", + "Copy-GitHubLabels", + "Export-OpenApiSchema", + "Find-DotNetTools", + "Get-AssemblyFramework", + "Get-GitFileMetadata", + "Get-GitFirstCommit", + "Get-GitHubRepoChildItem", + "Get-LibraryVulnerabilityInfo", + "Get-NuGetConfigs", + "Get-OpenApiInfo", + "Get-RepoName", + "Get-Todos", + "Get-VSCCurrentFile", + "Get-VSCodeSetting", + "Get-VSCodeSettingsFile", + "Import-VsCodeDatabaseConnections", + "Initialize-DatabaseNotebook", + "New-Jwt", + "Push-WorkspaceLocation", + "Rename-GitHubLocalBranch", + "Repair-ScriptStyle", + "Set-VSCodeSetting", + "Show-DataRef", + "Show-OpenApiInfo", + "Test-Jwt", + "Trace-GitRepoTest" + ] + }, + { + "module": "Windows/Servers", + "cmdlets": [ + "Backup-File", + "Backup-SchTasks", + "Backup-Workstation", + "Convert-ChocolateyToWinget", + "ConvertFrom-CimInstance", + "ConvertTo-LogParserTimestamp", + "Copy-SchTasks", + "Find-ProjectPackages", + "Get-ADServiceAccountInfo", + "Get-ADUserStatus", + "Get-AspNetEvents", + "Get-DotNetFrameworkVersions", + "Get-DotNetVersions", + "Get-IisLog", + "Get-SimpleSchTasks", + "Get-SystemDetails", + "Measure-Caches", + "Remove-LockyFile", + "Repair-AppxPackages", + "Restore-SchTasks", + "Restore-Workstation", + "Set-SchTaskMsa", + "Set-TerminalProfile", + "Test-LockedFile", + "Test-WindowsTerminal" + ] + }, + { + "module": "Database", + "cmdlets": [ + "Export-DatabaseScripts", + "Export-MermaidER", + "Export-TableMerge", + "Find-DatabaseValue", + "Find-DbColumn", + "Find-DbIndexes", + "Measure-DbColumn", + "Measure-DbColumnValues", + "Measure-DbTable", + "New-DbProviderObject", + "Repair-DatabaseConstraintNames", + "Repair-DatabaseUntrustedConstraints", + "Send-SqlReport", + "Test-ConnectionString", + "Use-DbInstance", + "Use-SqlcmdParams" + ] + }, + { + "module": "Unicode", + "cmdlets": [ + "Get-CharacterDetails", + "Get-Unicode", + "Get-UnicodeByName", + "Get-UnicodeData", + "Get-UnicodeName", + "Import-CharConstants" + ] + }, + { + "module": "Secrets", + "cmdlets": [ + "Export-SecretVault", + "Get-SecretDetails", + "Import-SecretVault", + "Save-Secret" + ] + }, + { + "module": "Seq", + "cmdlets": [ + "Send-SeqEvent", + "Send-SeqScriptEvent", + "Use-SeqServer" + ] + } +] diff --git a/test/Add-CapturesToMatches.Tests.ps1 b/test/Add-CapturesToMatches.Tests.ps1 deleted file mode 100644 index 15bd2099..00000000 --- a/test/Add-CapturesToMatches.Tests.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -<# -.SYNOPSIS -Tests adding named capture group values as note properties to Select-String MatchInfo objects. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Add-CapturesToMatches' -Tag Add-CapturesToMatches,Select-Xml -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Add to regex selection' -Tag AddCapturesToMatches,Add,Captures,Xml { - It "Value '' should add '' and ''" -TestCases @( - @{ Text = 'Arthur Dent adent@example.org'; Name = 'Arthur Dent'; Email = 'adent@example.org' } - @{ Text = 'Tricia McMillan trillian@example.com'; Name = 'Tricia McMillan'; Email = 'trillian@example.com' } - ) { - Param([string]$Text,[string]$Name,[string]$Email) - $result = $Text |Select-String '^(?.*?\b)\s*(?\S+@\S+)$' |Add-CapturesToMatches.ps1 - $result.Name |Should -BeExactly $Name -Because 'the name capture should be added' - $result.Email |Should -BeExactly $Email -Because 'the email capture should be added' - } - } -} diff --git a/test/Add-TimeSpan.Tests.ps1 b/test/Add-TimeSpan.Tests.ps1 deleted file mode 100644 index dd946f9f..00000000 --- a/test/Add-TimeSpan.Tests.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# -.SYNOPSIS -Tests adding a timespan to DateTime values. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Add-TimeSpan' -Tag Add-TimeSpan -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Adds a timespan to DateTime values.' -Tag AddTimeSpan,Add,TimeSpan { - It "Should add '' to a '' pipeline value and return ''" -TestCases @( - @{ TimeSpan = '00:00:30'; DateTime = '2000-01-01'; Result = '2000-01-01T00:00:30' } - @{ TimeSpan = '00:00:59'; DateTime = '2020-12-31T23:59:00'; Result = '2020-12-31T23:59:59' } - @{ TimeSpan = '00:00:30'; DateTime = '2010-07-01T00:00:00'; Result = '2010-07-01T00:00:30' } - @{ TimeSpan = '7'; DateTime = '2000-01-01T00:00:00'; Result = '2000-01-08T00:00:00' } - @{ TimeSpan = '100'; DateTime = '2020-12-31T23:59:00'; Result = '2021-04-10T23:59:00' } - @{ TimeSpan = '60'; DateTime = '2010-07-01T00:00:00'; Result = '2010-08-30T00:00:00' } - @{ TimeSpan = 7; DateTime = '2000-01-01T00:00:00'; Result = '2000-01-01T00:00:00.0000007' } - @{ TimeSpan = 100; DateTime = '2020-12-31T23:59:00'; Result = '2020-12-31T23:59:00.00001' } - @{ TimeSpan = 60; DateTime = '2010-07-01T00:00:00'; Result = '2010-07-01T00:00:00.000006' } - ) { - Param($TimeSpan,[datetime]$DateTime,[datetime]$Result) - $DateTime |Add-TimeSpan.ps1 $TimeSpan |Should -Be $Result - } - } -} diff --git a/test/Compare-Keys.Tests.ps1 b/test/Compare-Keys.Tests.ps1 deleted file mode 100644 index 50d40555..00000000 --- a/test/Compare-Keys.Tests.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -<# -.SYNOPSIS -Tests returning the differences between two dictionaries. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Compare-Keys' -Tag Compare-Keys -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - $initialOutputRendering,$PSStyle.OutputRendering = $PSStyle.OutputRendering,'PlainText' - } - AfterAll { - $PSStyle.OutputRendering = $initialOutputRendering - } - Context 'Returns the differences between two dictionaries' -Tag CompareKeys,Compare,Keys { - $space = ' ' - It "Comparing '' to '' (including equal keys) should yield ''" -TestCases @( - @{ - ReferenceDictionary = @{ A = 1; B = 2; C = 3 } - DifferenceDictionary = @{ D = 6; C = 4; B = 2 } - Result = @" -Key Action ReferenceValue DifferenceValue ---- ------ -------------- --------------- -A Deleted 1$space -B Unchanged 2 2 -C Modified 3 4 -D Added 6 -"@ - } - ) { - Param([Collections.IDictionary]$ReferenceDictionary,[Collections.IDictionary]$DifferenceDictionary,[string]$Result) - Compare-Keys.ps1 -ReferenceDictionary $ReferenceDictionary -DifferenceDictionary $DifferenceDictionary -IncludeEqual | - Sort-Object Key | - Out-String | - ForEach-Object {$_.Trim()} | - Should -BeExactly $Result - } - } -} diff --git a/test/Convert-ClipboardTsvToHtml.Tests.ps1 b/test/Convert-ClipboardTsvToHtml.Tests.ps1 deleted file mode 100644 index ad265122..00000000 --- a/test/Convert-ClipboardTsvToHtml.Tests.ps1 +++ /dev/null @@ -1,70 +0,0 @@ -<# -.SYNOPSIS -Tests parsing TSV clipboard data into HTML table data which is copied back to the clipboard. -#> - -$sixspaces = ' '*6 -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Convert-ClipboardTsvToHtml' -Tag Convert-ClipboardTsvToHtml -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Parses TSV clipboard data into HTML table data which is copied back to the clipboard' ` - -Tag ConvertClipboardTsvToHtml,Convert,ClipboardTsv,Clipboard,Tsv,Html { - It "Should convert '' to ''" -TestCases @( -@{ TsvData = @" -Id`tName -1`tFirst -2`tSecond -3`tThird -"@ -split '\r?\n'; HtmlData = @" -Version:0.9$sixspaces -StartHTML:000000185$sixspaces -EndHTML:000000510$sixspaces -StartFragment:000000285$sixspaces -EndFragment:000000478$sixspaces -StartSelection:000000285$sixspaces -EndSelection:000000478 - - - - - - - -
IdName
1First
2Second
3Third
-"@ } -@{ TsvData = @( - [pscustomobject]@{ Name = 'New Year''s Day (observed)'; Date = '2023-01-02' } - [pscustomobject]@{ Name = 'Martin Luther King, Jr Day'; Date = '2023-01-16' } - [pscustomobject]@{ Name = 'Washington''s Birthday'; Date = '2023-02-20' } -) |ConvertTo-Csv -Delimiter "`t" -UseQuotes AsNeeded; HtmlData = @" -Version:0.9$sixspaces -StartHTML:000000185$sixspaces -EndHTML:000000603$sixspaces -StartFragment:000000285$sixspaces -EndFragment:000000571$sixspaces -StartSelection:000000285$sixspaces -EndSelection:000000571 - - - - - - - -
NameDate
New Year's Day (observed)2023-01-02
Martin Luther King, Jr Day2023-01-16
Washington's Birthday2023-02-20
-"@ } - ) { - Param([string[]] $TsvData, [string] $HtmlData) - Set-Clipboard -Value $TsvData - Convert-ClipboardTsvToHtml.ps1 - $result = Invoke-WindowsPowerShell.ps1 {"$((Get-Clipboard -Format Text -TextFormatType Html) -join "`r`n")"} - $result |Should -Be $HtmlData - } - } -} diff --git a/test/ConvertFrom-Base64.Tests.ps1 b/test/ConvertFrom-Base64.Tests.ps1 deleted file mode 100644 index 51e902bf..00000000 --- a/test/ConvertFrom-Base64.Tests.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# -.SYNOPSIS -Tests converting base64-encoded text to bytes or text. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertFrom-Base64' -Tag ConvertFrom-Base64 -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Converts base64-encoded text to bytes or text' -Tag ConvertFromBase64,Convert,ConvertFrom,Base64 { - It "Should parse a standard base-64 string as parameter" { - ConvertFrom-Base64.ps1 dXNlcm5hbWU6QmFkUEBzc3dvcmQ= -Encoding utf8 | - Should -BeExactly 'username:BadP@ssword' - } - It "Should parse a URI-style base-64 string from pipeline" { - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9' | - ConvertFrom-Base64.ps1 -Encoding ascii -UriStyle | - Should -BeExactly '{"alg":"HS256","typ":"JWT"}' - } - It "Should parse a base-64 string from pipeline as a byte array" { - '77u/dHJ1ZQ0K' | - ConvertFrom-Base64.ps1 | - Should -BeExactly ([byte[]]@(0xEF,0xBB,0xBF,0x74,0x72,0x75,0x65,0x0D,0x0A)) - } - } -} diff --git a/test/ConvertFrom-CimInstance.Tests.ps1 b/test/ConvertFrom-CimInstance.Tests.ps1 index 902e4c7b..28e2649b 100644 --- a/test/ConvertFrom-CimInstance.Tests.ps1 +++ b/test/ConvertFrom-CimInstance.Tests.ps1 @@ -3,17 +3,17 @@ Tests converting a CimInstance object to a PSObject. #> -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertFrom-CimInstance' -Tag ConvertFrom-CimInstance -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } +if((Test-Path .changes -Type Leaf) -and + !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name | + Where-Object {$_.StartsWith("$(($MyInvocation.MyCommand.Name -split '\.',2)[0]).")})) {return} +BeforeAll { + Set-StrictMode -Version Latest + $module = Get-Item "$PSScriptRoot/../src/.publish/*.psd1" + Import-Module $module -Force +} +Describe 'ConvertFrom-CimInstance' -Tag ConvertFrom-CimInstance { Context 'Convert a CimInstance object to a PSObject' ` - -Tag ConvertFromCimInstance,Convert,ConvertFrom,CimInstance { + -Tag ConvertFromCimInstance,Convert,ConvertFrom,CimInstance -Skip:$(!$IsWindows) { BeforeAll { Register-ScheduledTask -TaskName x -Description 'This is a test.' ` -Action (New-ScheduledTaskAction -Execute pwsh -Argument 1) ` @@ -24,7 +24,7 @@ Describe 'ConvertFrom-CimInstance' -Tag ConvertFrom-CimInstance -Skip:$skip { catch { Write-Warning "$_" } } It "Should convert a Scheduled Task CIM instance into a PSCustomObject" { - $task = Get-ScheduledTask -TaskName x |ConvertFrom-CimInstance.ps1 + $task = Get-ScheduledTask -TaskName x |ConvertFrom-CimInstance $task |Should -BeOfType pscustomobject $task.'#CimClassName' |Should -BeExactly MSFT_ScheduledTask $task.TaskName |Should -BeExactly x @@ -46,3 +46,6 @@ Describe 'ConvertFrom-CimInstance' -Tag ConvertFrom-CimInstance -Skip:$skip { } } } +AfterAll { + Remove-Module $module.BaseName -Force +} diff --git a/test/ConvertFrom-DataRow.Tests.ps1 b/test/ConvertFrom-DataRow.Tests.ps1 index 00e1f03b..a9bf5549 100644 --- a/test/ConvertFrom-DataRow.Tests.ps1 +++ b/test/ConvertFrom-DataRow.Tests.ps1 @@ -3,11 +3,15 @@ Tests Converts a DataRow object to a PSObject, Hashtable, or single value. #> -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertFrom-DataRow' -Tag ConvertFrom-DataRow -Skip:$skip { +if((Test-Path .changes -Type Leaf) -and + !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name | + Where-Object {$_.StartsWith("$(($MyInvocation.MyCommand.Name -split '\.',2)[0]).")})) {return} +BeforeAll { + Set-StrictMode -Version Latest + $module = Get-Item "$PSScriptRoot/../src/.publish/*.psd1" + Import-Module $module -Force +} +Describe 'ConvertFrom-DataRow' -Tag ConvertFrom-DataRow { BeforeAll { $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator $datadir = Join-Path $PSScriptRoot 'data' @@ -20,21 +24,24 @@ Describe 'ConvertFrom-DataRow' -Tag ConvertFrom-DataRow -Skip:$skip { [void]$data.ReadXml((Join-Path $datadir 'product-dataset.xml')) } It "Should convert rows to objects" { - $rows = $data.Tables['Product'] |ConvertFrom-DataRow.ps1 + $rows = $data.Tables['Product'] |ConvertFrom-DataRow $rows |Should -BeOfType pscustomobject $rows.ProductID |Should -BeExactly 1,2,3,4 $rows.Name |Should -BeExactly 'Widget','Gimmick','Gadget','Contrivance' } It "Should convert rows to dictionaries" { - $rows = $data.Tables['Product'] |ConvertFrom-DataRow.ps1 -AsDictionary + $rows = $data.Tables['Product'] |ConvertFrom-DataRow -AsDictionary $rows |Should -BeOfType Collections.Specialized.OrderedDictionary $rows.ProductID |Should -BeExactly 1,2,3,4 $rows.Name |Should -BeExactly 'Widget','Gimmick','Gadget','Contrivance' } It "Should convert rows to values" { - $rows = $data.Tables['Product'] |ConvertFrom-DataRow.ps1 -AsValues + $rows = $data.Tables['Product'] |ConvertFrom-DataRow -AsValues $rows |Should -BeOfType pscustomobject $rows |Should -BeExactly 1,'Widget',2,'Gimmick',3,'Gadget',4,'Contrivance' } } } +AfterAll { + Remove-Module $module.BaseName -Force +} diff --git a/test/ConvertFrom-Duration.Tests.ps1 b/test/ConvertFrom-Duration.Tests.ps1 deleted file mode 100644 index 1dd7cd40..00000000 --- a/test/ConvertFrom-Duration.Tests.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -<# -.SYNOPSIS -Tests parsing a Timespan from a ISO8601 duration string. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertFrom-Duration' -Tag ConvertFrom-Duration -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Parses a Timespan from a ISO8601 duration string' ` - -Tag ConvertFromDuration,Convert,ConvertFrom,Duration,TimeSpan { - BeforeAll {Mock Write-Warning {Write-Information $Message}} - It "Should parse '' as ''" -TestCases @( - @{ Duration = 'PT1S'; TimeSpan = '0:00:01' } - @{ Duration = 'PT1M'; TimeSpan = '0:01:00' } - @{ Duration = 'PT1H'; TimeSpan = '1:00:00' } - @{ Duration = 'P1D'; TimeSpan = '1.0:00:00' } - @{ Duration = 'P1W'; TimeSpan = '7.0:00:00' } - @{ Duration = 'P1M'; TimeSpan = '30.0:00:00'; Warnings = 'Adding month(s) as a mean number of days (30.436875).' } - @{ Duration = 'P1Y'; TimeSpan = '365.0:00:00'; Warnings = 'Adding year(s) as a mean number of days (365.2425).' } - @{ Duration = 'PT72H10M'; TimeSpan = '3.00:10:00' } - @{ Duration = 'P90DT8H'; TimeSpan = '90.08:00:00' } - @{ Duration = 'P3DT48H90M300S'; TimeSpan = '5.01:35:00' } - @{ Duration = 'P1Y3M2DT8H20M15S'; TimeSpan = '458.08:20:15' - Warnings = 'Adding year(s) as a mean number of days (365.2425).', - 'Adding month(s) as a mean number of days (30.436875).' } - @{ Duration = 'P3Y6M4DT12H30M5S'; TimeSpan = '1283.12:30:05' - Warnings = 'Adding year(s) as a mean number of days (365.2425).', - 'Adding month(s) as a mean number of days (30.436875).' } - ) { - Param([string]$Duration,[timespan]$TimeSpan,[string[]]$Warnings = @()) - ConvertFrom-Duration.ps1 $Duration |Should -BeExactly $TimeSpan - if($Warnings) - { - Assert-MockCalled -CommandName Write-Warning -Times ($Warnings.Count) -ParameterFilter {$Message -in $Warnings} - } - } - } -} diff --git a/test/ConvertFrom-EpochTime.Tests.ps1 b/test/ConvertFrom-EpochTime.Tests.ps1 deleted file mode 100644 index a3906f78..00000000 --- a/test/ConvertFrom-EpochTime.Tests.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -<# -.SYNOPSIS -Tests converting an integer Unix (POSIX) time (seconds since Jan 1, 1970) into a DateTime value. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertFrom-EpochTime' -Tag ConvertFrom-EpochTime -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Converts an integer Unix (POSIX) time (seconds since Jan 1, 1970) into a DateTime value' ` - -Tag ConvertFromEpochTime,ConvertFrom,Convert,EpochTime { - It "Epoch time '' is converted to ''" -TestCases @( - @{ EpochTime = 946684800; Result = '2000-01-01' } - @{ EpochTime = 1012615322; Result = '2002-02-02T02:02:02' } - @{ EpochTime = 1645568542; Result = '2022-02-22T22:22:22' } - @{ EpochTime = 0; Result = '1970-01-01' } - @{ EpochTime = 663486600; Result = '1991-01-10T05:50' } - ) { - Param([int] $EpochTime, [datetime] $Result) - $EpochTime |ConvertFrom-EpochTime.ps1 |Should -BeExactly $Result - } - } - -} diff --git a/test/ConvertFrom-Hex.Tests.ps1 b/test/ConvertFrom-Hex.Tests.ps1 deleted file mode 100644 index 8a7f3daf..00000000 --- a/test/ConvertFrom-Hex.Tests.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -<# -.SYNOPSIS -Tests converting a string of hexadecimal digits into a byte array. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertFrom-Hex' -Tag ConvertFrom-Hex -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Convert a string of hexadecimal digits into a byte array' -Tag ConvertFromHex,Convert,ConvertFrom,Hex { - It "The value '' should return ''" -TestCases @( - @{ Value = 'EF BB BF'; Result = 0xEF,0xBB,0xBF } - @{ Value = 'c0ffee'; Result = 0xC0,0xFF,0xEE } - @{ Value = '0x25504446'; Result = 0x25,0x50,0x44,0x46 } - ) { - Param([string]$Value,[byte[]]$Result) - ConvertFrom-Hex.ps1 $Value |Should -BeExactly $Result -Because 'the parameter should work' - $Value |ConvertFrom-Hex.ps1 |Should -BeExactly $Result -Because 'pipeline input should work' - } - } -} diff --git a/test/ConvertFrom-IsoWeekDate.Tests.ps1 b/test/ConvertFrom-IsoWeekDate.Tests.ps1 deleted file mode 100644 index dcf352b4..00000000 --- a/test/ConvertFrom-IsoWeekDate.Tests.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# -.SYNOPSIS -Tests returning a DateTime object from an ISO week date string. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name | - Where-Object {$_.StartsWith($basename) -or $_.StartsWith('Format-Date')}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -$scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator -if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} -Describe 'ConvertFrom-IsoWeekDate' -Tag ConvertFrom-IsoWeekDate -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Returns a DateTime object from an ISO week date string.' ` - -Tag ConvertFromIsoWeekDate,Convert,ConvertFrom,IsoWeekDate { - It "ISO week date string '' should return DateTime value ''" -TestCases @( - 0..300 |ForEach-Object {$date = (Get-Date 2000-01-01).AddDays($_*10); @{ - InputObject = Format-Date.ps1 -Format Iso8601WeekDate -Date $date - Result = $date - }} - ) { - Param([string]$InputObject,[datetime]$Result) - ConvertFrom-IsoWeekDate.ps1 $InputObject |Should -Be $Result - } - } -} diff --git a/test/ConvertTo-Base64.Tests.ps1 b/test/ConvertTo-Base64.Tests.ps1 deleted file mode 100644 index d6a71b88..00000000 --- a/test/ConvertTo-Base64.Tests.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -<# -.SYNOPSIS -Tests converting bytes or text to base64-encoded text. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertTo-Base64' -Tag ConvertTo-Base64 -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Converts bytes or text to base64-encoded text.' -Tag ConvertToBase64,Convert,ConvertTo,Base64 { - It "Should encode a string parameter as a standard base-64 string" { - ConvertTo-Base64.ps1 'username:BadP@ssword' -Encoding utf8 | - Should -BeExactly 'dXNlcm5hbWU6QmFkUEBzc3dvcmQ=' - } - It "Should encode a string from pipeline to a URI-style base-64 string" { - '{"alg":"HS256","typ":"JWT"}' | - ConvertTo-Base64.ps1 -UriStyle | - Should -BeExactly 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9' - } - It "Should encode a byte array from pipeline to a base-64 string from pipeline" { - ,([byte[]]@(0xEF,0xBB,0xBF,0x74,0x72,0x75,0x65,0x0D,0x0A)) | - ConvertTo-Base64.ps1 | - Should -BeExactly '77u/dHJ1ZQ0K' - } - } -} diff --git a/test/ConvertTo-EpochTime.Tests.ps1 b/test/ConvertTo-EpochTime.Tests.ps1 deleted file mode 100644 index 1c004c1f..00000000 --- a/test/ConvertTo-EpochTime.Tests.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -<# -.SYNOPSIS -Tests converting a DateTime value into an integer Unix (POSIX) time, seconds since Jan 1, 1970. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertTo-EpochTime' -Tag ConvertTo-EpochTime -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Converts a DateTime value into an integer Unix (POSIX) time, seconds since Jan 1, 1970' ` - -Tag ConvertToEpochTime,Convert,ConvertTo,EpochTime { - It "DateTime value '' should return ''" ` - -Tag ConvertToEpochTime,Convert,ConvertTo,EpochTime,Epoch -TestCases @( - @{ DateTime = '2000-01-01Z'; Result = 946684800 } - @{ DateTime = '2002-02-02T02:02:02Z'; Result = 1012615322 } - @{ DateTime = '2022-02-22T22:22:22Z'; Result = 1645568542 } - @{ DateTime = '1970-01-01Z'; Result = 0 } - @{ DateTime = '1991-01-10T05:50Z'; Result = 663486600 } - ) { - Param([datetime]$DateTime,[int]$Result) - ConvertTo-EpochTime.ps1 $DateTime |Should -BeExactly $Result -Because 'parameter should work' - $DateTime |ConvertTo-EpochTime.ps1 |Should -BeExactly $Result -Because 'pipeline should work' - } - } -} diff --git a/test/ConvertTo-OrderedDictionary.Tests.ps1 b/test/ConvertTo-OrderedDictionary.Tests.ps1 deleted file mode 100644 index d6d61e9a..00000000 --- a/test/ConvertTo-OrderedDictionary.Tests.ps1 +++ /dev/null @@ -1,35 +0,0 @@ -<# -.SYNOPSIS -Tests converting an object to an ordered dictionary of properties and values. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertTo-OrderedDictionary' -Tag ConvertTo-OrderedDictionary -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Converts an object to an ordered dictionary of properties and values.' ` - -Tag ConvertToOrderedDictionary,Convert,ConvertTo,OrderedDictionary,Dictionary { - It "Should convert an IO.FileInfo object into a dictionary" { - $file = Get-Item ConvertTo-OrderedDictionary.ps1 |ConvertTo-OrderedDictionary.ps1 - $file |Should -BeOfType Collections.IDictionary - $file.Contains('Name') |Should -BeTrue -Because 'the dictionary should include a Name key' - $file['Name'] |Should -BeOfType string - $file['Name'] |Should -Be 'ConvertTo-OrderedDictionary.ps1' - $file.Contains('Length') |Should -BeTrue -Because 'the dictionary should include a Length key' - $file['Length'] |Should -BeOfType long - $file.Contains('Mode') |Should -BeTrue -Because 'the dictionary should include a Mode key' - $file['Mode'] |Should -BeOfType string - $file.Contains('VersionInfo') |Should -BeTrue -Because 'the dictionary should include a VersionInfo key' - $file['VersionInfo'] |Should -BeOfType Diagnostics.FileVersionInfo - $file['VersionInfo'].FileName |Should -BeOfType string - $file.Contains('CreationTime') |Should -BeTrue -Because 'the dictionary should include a CreationTime key' - $file['CreationTime'] |Should -BeOfType datetime - } - } - -} diff --git a/test/ConvertTo-PowerShell.Tests.ps1 b/test/ConvertTo-PowerShell.Tests.ps1 deleted file mode 100644 index e1703224..00000000 --- a/test/ConvertTo-PowerShell.Tests.ps1 +++ /dev/null @@ -1,114 +0,0 @@ -<# -.SYNOPSIS -Tests serializing complex content into PowerShell literals. -#> - -#Requires -Version 7 -[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText','', -Justification='These are tests.')] Param() -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertTo-PowerShell' -Tag ConvertTo-PowerShell -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Serializes complex content into PowerShell literals.' -Tag ctps,ConvertToPowerShell,Convert,ConvertTo,PowerShell { - It "Should convert '' into idiomatic numeric literal ''" -TestCases @( - @{ Value = 0x0; Result = '0' } - @{ Value = 0x1; Result = '1' } - @{ Value = 0x7; Result = '7' } - @{ Value = 0xFKB; Result = '15KB' } - @{ Value = 9E0; Result = '9' } - @{ Value = 1E0; Result = '1' } - @{ Value = 4E0LGB; Result = '4LGB' } - @{ Value = 1E0Y; Result = '1y' } - @{ Value = 2E2UY; Result = '200uy' } - @{ Value = 3E1SKB; Result = '30sKB' } - @{ Value = 6E1USKB; Result = '60usKB' } - @{ Value = 3E0UGB; Result = '3uGB' } - @{ Value = 15E3ULPB; Result = '15000ulPB' } - ) { - Param($Value, [string] $Result) - $Value |ConvertTo-PowerShell.ps1 |Should -BeExactly $Result - } - It "Should convert JSON '' into PowerShell literals" -TestCases @( - @{ Value = 'null'; Result = '$null' } - @{ Value = '7'; Result = '7L' } - @{ Value = '"Don''t Panic!"'; Result = "'Don''t Panic!'" } - @{ Value = '"2000-01-01T00:00:00"'; Result = "[datetime]'2000-01-01T00:00:00'" } - @{ Value = '[6,9,42]'; Result = "@(`r`n`t6L`r`n`t9L`r`n`t42L`r`n)" } - @{ Value = '{}'; Result = "[pscustomobject]@{`r`n`r`n}" } - @{ Value = '{"a":1,"b":2,"c":{"d":"2017-03-22T20:59:31","e":null}}'; Result = @' -[pscustomobject]@{ - a = 1L - b = 2L - c = [pscustomobject]@{ - d = [datetime]'2017-03-22T20:59:31' - e = $null - } -} -'@ } - ) { - Param([string] $Value, [string] $Result) - $expression = ConvertFrom-Json $Value -NoEnumerate |ConvertTo-PowerShell.ps1 - $expression |Should -BeExactly $Result - Invoke-Expression $expression |ConvertTo-Json -Compress |Should -BeExactly $Value - } - } - Context 'Serializes secure strings secured with a generated key' -Tag ctpsGenerateKey { - It "Should generate PowerShell for secure '', using a generated zero key" -TestCases @( - @{ Value = 'Test' } - @{ Value = 'Lorem ipsum dolor' } - ) { - Param([string] $Value) - $expression = ConvertTo-SecureString $Value -AsPlainText -Force | - ConvertTo-PowerShell.ps1 -GenerateKey | - Out-String - $expression |Should -BeLike '*ConvertTo-SecureString*' - Invoke-Expression $expression |ConvertFrom-SecureString -AsPlainText |Should -BeExactly $Value - } - } - Context 'Serialize secure strings secured with a provided password' -Tag ctpsSecureKey { - It "Should generate PowerShell for secure '', using password ''" -TestCases @( - @{ Value = 'Test'; Secret = 'P@ssw0rd' } - @{ Value = 'Lorem ipsum dolor'; Secret = '$w0rdf1sh' } - ) { - Param([string] $Value, [string] $Secret) - $secureKey = ConvertTo-SecureString $Secret -AsPlainText -Force - $expression = ConvertTo-SecureString $Value -AsPlainText -Force | - ConvertTo-PowerShell.ps1 -SecureKey $secureKey | - Out-String - $expression |Should -BeLike '*Rfc2898DeriveBytes*' - $expression |Should -BeLike '*GetBytes*' - $expression |Should -BeLike '*ConvertTo-SecureString*' - } - } - Context 'Serialize secure strings secured with a credential' -Tag ctpsCredential { - It "Should generate PowerShell for secure '', using credential '' : ''" -TestCases @( - @{ Value = 'Test'; Name = 'user'; Secret = 'P@ssw0rd!' } - @{ Value = 'Lorem ipsum dolor'; Name = 'apikey'; Secret = '$w0rdF1sh' } - ) { - Param([string] $Value, [string] $Name, [string] $Secret) - $credential = New-Object pscredential $Name,(ConvertTo-SecureString $Secret -AsPlainText -Force) - $expression = ConvertTo-SecureString $Value -AsPlainText -Force | - ConvertTo-PowerShell.ps1 -Credential $credential | - Out-String - $expression |Should -BeLike '*ConvertTo-SecureString*' - } - } - Context 'Serialize secure strings secured with a provided zero key' -Tag ctpsKeyBytes { - It "Should generate PowerShell for secure '', using key bytes ''" -TestCases @( - @{ Value = 'Test'; Secret = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } - @{ Value = 'Lorem ipsum dolor'; Secret = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } - ) { - Param([string] $Value, [byte[]] $Secret) - $expression = ConvertTo-SecureString $Value -AsPlainText -Force | - ConvertTo-PowerShell.ps1 -Key $Secret | - Out-String - $expression |Should -BeLike '*ConvertTo-SecureString*' - } - } -} diff --git a/test/ConvertTo-RomanNumeral.Tests.ps1 b/test/ConvertTo-RomanNumeral.Tests.ps1 deleted file mode 100644 index 32b46a4c..00000000 --- a/test/ConvertTo-RomanNumeral.Tests.ps1 +++ /dev/null @@ -1,112 +0,0 @@ -<# -.SYNOPSIS -Tests converting a number to a Roman numeral. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ConvertTo-RomanNumeral' -Tag ConvertTo-RomanNumeral -Skip:$skip { - BeforeAll { - if(!(Get-Module -List PSScriptAnalyzer)) {Install-Module PSScriptAnalyzer -Force} - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Convert a number to a Roman numeral' -Tag Convert,ConvertTo,ConvertToRomanNumeral,RomanNumeral { - It "Should convert '' to '' (ASCII)" -TestCases @( - @{ Value = 1; Result = 'I' } - @{ Value = 2; Result = 'II' } - @{ Value = 3; Result = 'III' } - @{ Value = 4; Result = 'IV' } - @{ Value = 5; Result = 'V' } - @{ Value = 6; Result = 'VI' } - @{ Value = 7; Result = 'VII' } - @{ Value = 8; Result = 'VIII' } - @{ Value = 9; Result = 'IX' } - @{ Value = 10; Result = 'X' } - @{ Value = 11; Result = 'XI' } - @{ Value = 12; Result = 'XII' } - @{ Value = 13; Result = 'XIII' } - @{ Value = 14; Result = 'XIV' } - @{ Value = 15; Result = 'XV' } - @{ Value = 16; Result = 'XVI' } - @{ Value = 17; Result = 'XVII' } - @{ Value = 18; Result = 'XVIII' } - @{ Value = 19; Result = 'XIX' } - @{ Value = 20; Result = 'XX' } - @{ Value = 21; Result = 'XXI' } - @{ Value = 22; Result = 'XXII' } - @{ Value = 23; Result = 'XXIII' } - @{ Value = 24; Result = 'XXIV' } - @{ Value = 25; Result = 'XXV' } - @{ Value = 35; Result = 'XXXV' } - @{ Value = 45; Result = 'XLV' } - @{ Value = 46; Result = 'XLVI' } - @{ Value = 47; Result = 'XLVII' } - @{ Value = 48; Result = 'XLVIII' } - @{ Value = 49; Result = 'XLIX' } - @{ Value = 50; Result = 'L' } - @{ Value = 51; Result = 'LI' } - @{ Value = 52; Result = 'LII' } - @{ Value = 99; Result = 'XCIX' } - @{ Value = 100; Result = 'C' } - @{ Value = 999; Result = 'CMXCIX' } - @{ Value = 1000; Result = 'M' } - @{ Value = 1111; Result = 'MCXI' } - @{ Value = 2020; Result = 'MMXX' } - @{ Value = 2022; Result = 'MMXXII' } - ) { - Param([int] $Value, [string] $Result) - ConvertTo-RomanNumeral.ps1 $Value |Should -BeExactly $Result -Because 'parameter should work' - $Value |ConvertTo-RomanNumeral.ps1 |Should -BeExactly $Result -Because 'pipeline should work' - } - It "Should convert '' to '' (Unicode)" -TestCases @( - @{ Value = 1; Result = 'Ⅰ' } - @{ Value = 2; Result = 'Ⅱ' } - @{ Value = 3; Result = 'Ⅲ' } - @{ Value = 4; Result = 'Ⅳ' } - @{ Value = 5; Result = 'Ⅴ' } - @{ Value = 6; Result = 'Ⅵ' } - @{ Value = 7; Result = 'Ⅶ' } - @{ Value = 8; Result = 'Ⅷ' } - @{ Value = 9; Result = 'Ⅸ' } - @{ Value = 10; Result = 'Ⅹ' } - @{ Value = 11; Result = 'ⅩⅠ' } - @{ Value = 12; Result = 'ⅩⅡ' } - @{ Value = 13; Result = 'ⅩⅢ' } - @{ Value = 14; Result = 'ⅩⅣ' } - @{ Value = 15; Result = 'ⅩⅤ' } - @{ Value = 16; Result = 'ⅩⅥ' } - @{ Value = 17; Result = 'ⅩⅦ' } - @{ Value = 18; Result = 'ⅩⅧ' } - @{ Value = 19; Result = 'ⅩⅨ' } - @{ Value = 20; Result = 'ⅩⅩ' } - @{ Value = 21; Result = 'ⅩⅩⅠ' } - @{ Value = 22; Result = 'ⅩⅩⅡ' } - @{ Value = 23; Result = 'ⅩⅩⅢ' } - @{ Value = 24; Result = 'ⅩⅩⅣ' } - @{ Value = 25; Result = 'ⅩⅩⅤ' } - @{ Value = 35; Result = 'ⅩⅩⅩⅤ' } - @{ Value = 45; Result = 'ⅩⅬⅤ' } - @{ Value = 46; Result = 'ⅩⅬⅥ' } - @{ Value = 47; Result = 'ⅩⅬⅦ' } - @{ Value = 48; Result = 'ⅩⅬⅧ' } - @{ Value = 49; Result = 'ⅩⅬⅨ' } - @{ Value = 50; Result = 'Ⅼ' } - @{ Value = 51; Result = 'ⅬⅠ' } - @{ Value = 52; Result = 'ⅬⅡ' } - @{ Value = 99; Result = 'ⅩⅭⅨ' } - @{ Value = 100; Result = 'Ⅽ' } - @{ Value = 999; Result = 'ⅭⅯⅩⅭⅠⅩ' } - @{ Value = 1000; Result = 'Ⅿ' } - @{ Value = 1111; Result = 'ⅯⅭⅩⅠ' } - @{ Value = 2020; Result = 'ⅯⅯⅩⅩ' } - @{ Value = 2022; Result = 'ⅯⅯⅩⅩⅡ' } - ) { - Param([int] $Value, [string] $Result) - ConvertTo-RomanNumeral.ps1 $Value -Unicode |Should -BeExactly $Result -Because 'parameter should work' - $Value |ConvertTo-RomanNumeral.ps1 -Unicode |Should -BeExactly $Result -Because 'pipeline should work' - } - } -} diff --git a/test/Disable-AnsiColor.Tests.ps1 b/test/Disable-AnsiColor.Tests.ps1 deleted file mode 100644 index 84bef0d6..00000000 --- a/test/Disable-AnsiColor.Tests.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -<# -.SYNOPSIS -Tests disabling ANSI terminal colors. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Disable-AnsiColor' -Tag Disable-AnsiColor -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Disables ANSI terminal colors' -Tag DisableAnsiColor,Disable,AnsiColor { - It "Sets OutputRendering" { - Param([string] $OutputRendering) - $PSStyle.OutputRendering = 'Ansi' - Disable-AnsiColor.ps1 - $PSStyle.OutputRendering |Should -Be 'PlainText' - Disable-AnsiColor.ps1 -HostOnly - $PSStyle.OutputRendering |Should -Be 'Host' - } - } -} diff --git a/test/Enable-AnsiColor.Tests.ps1 b/test/Enable-AnsiColor.Tests.ps1 deleted file mode 100644 index f000b8fe..00000000 --- a/test/Enable-AnsiColor.Tests.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -<# -.SYNOPSIS -Tests Enables ANSI terminal colors. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Enable-AnsiColor' -Tag Enable-AnsiColor -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Enables ANSI terminal colors.' -Tag EnableAnsiColor,Enable,AnsiColor { - It "Sets OutputRendering" { - Param([string] $OutputRendering) - $PSStyle.OutputRendering = 'PlainText' - Enable-AnsiColor.ps1 -HostOnly - $PSStyle.OutputRendering |Should -Be 'Host' - Enable-AnsiColor.ps1 - $PSStyle.OutputRendering |Should -Be 'Ansi' - } - } -} diff --git a/test/Expand-EnvironmentVariables.Tests.ps1 b/test/Expand-EnvironmentVariables.Tests.ps1 deleted file mode 100644 index b55d9060..00000000 --- a/test/Expand-EnvironmentVariables.Tests.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -<# -.SYNOPSIS -Tests replacing the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Expand-EnvironmentVariables' -Tag Expand-EnvironmentVariables -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string' ` - -Tag ExpandEnvironmentVariables,Expand,EnvironmentVariables,EnvVar { - It "Expands '' to ''" -TestCases @( - @{ String = '%SystemRoot%\System32\cmd.exe'; Result = 'C:\WINDOWS\System32\cmd.exe' } - @{ String = '%CommonProgramFiles%\System\ado'; Result = 'C:\Program Files\Common Files\System\ado' } - ) { - Param([string] $String, [string] $Result) - Expand-EnvironmentVariables.ps1 $String |Should -Be $Result -Because 'parameter should work' - $String |Expand-EnvironmentVariables.ps1 |Should -Be $Result -Because 'pipeline should work' - } - } -} diff --git a/test/Export-OpenApiSchema.Tests.ps1 b/test/Export-OpenApiSchema.Tests.ps1 index c314db09..5039ee25 100644 --- a/test/Export-OpenApiSchema.Tests.ps1 +++ b/test/Export-OpenApiSchema.Tests.ps1 @@ -3,19 +3,19 @@ Tests extracting a JSON schema from an OpenAPI definition. #> -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Export-OpenApiSchema' -Tag Export-OpenApiSchema -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - $datadir = Join-Path $PSScriptRoot 'data' - } +if((Test-Path .changes -Type Leaf) -and + !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name | + Where-Object {$_.StartsWith("$(($MyInvocation.MyCommand.Name -split '\.',2)[0]).")})) {return} +BeforeAll { + Set-StrictMode -Version Latest + $module = Get-Item "$PSScriptRoot/../src/.publish/*.psd1" + Import-Module $module -Force + $datadir = Join-Path $PSScriptRoot 'data' +} +Describe 'Export-OpenApiSchema' -Tag Export-OpenApiSchema { Context 'Extracts a JSON schema from an OpenAPI definition' -Tag ExportOpenApiSchema,Export,OpenApi { It "Exports the response schema from sample schema" { - Export-OpenApiSchema.ps1 (Join-Path $datadir sample-openapi.json) |Should -BeExactly @' + Export-OpenApiSchema (Join-Path $datadir sample-openapi.json) |Should -BeExactly @' { "required": [ "id", @@ -37,7 +37,7 @@ Describe 'Export-OpenApiSchema' -Tag Export-OpenApiSchema -Skip:$skip { '@ } It "Exports the request schema from sample schema" { - Export-OpenApiSchema.ps1 (Join-Path $datadir sample-openapi.json) -RequestSchema |Should -BeExactly @' + Export-OpenApiSchema (Join-Path $datadir sample-openapi.json) -RequestSchema |Should -BeExactly @' { "type": "integer", "minimum": 1, @@ -48,3 +48,6 @@ Describe 'Export-OpenApiSchema' -Tag Export-OpenApiSchema -Skip:$skip { } } } +AfterAll { + Remove-Module $module.BaseName -Force +} diff --git a/test/Find-NewestFile.Tests.ps1 b/test/Find-NewestFile.Tests.ps1 deleted file mode 100644 index 64456b8c..00000000 --- a/test/Find-NewestFile.Tests.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -<# -.SYNOPSIS -Tests finding the most recent file. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Find-NewestFile' -Tag Find-NewestFile -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Finds the most recent file' -Tag FindNewestFile,Find,NewestFile { - It "Gets most recent file" { - 0..4 |ForEach-Object { - 'test' |Out-File "TestDrive:/test$_.txt" - (Get-Item "TestDrive:/test$_.txt").LastWriteTime = - (Get-Item "TestDrive:/test$_.txt").LastWriteTime.AddMinutes(-$_) - } - Get-Item TestDrive:/test*.txt |Find-NewestFile.ps1 |Should -BeLike '*test0.txt' - } - } - -} diff --git a/test/ForEach-Progress.Tests.ps1 b/test/ForEach-Progress.Tests.ps1 deleted file mode 100644 index 9864aa55..00000000 --- a/test/ForEach-Progress.Tests.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -<# -.SYNOPSIS -Tests performing an operation against each item in a collection of input objects, with a progress bar. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'ForEach-Progress' -Tag ForEach-Progress -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Performs an operation against each item in a collection of input objects, with a progress bar' ` - -Tag ForEachProgress,ForEach,Progress { - It "Displays progress" { - Mock Write-Progress {} - 1..10 |ForEach-Progress.ps1 -Activity 'Processing' {"$_"} {"$_"} - Assert-MockCalled -CommandName Write-Progress -Times 10 - } - } -} diff --git a/test/README.md b/test/README.md index 945dfbfa..39bc241d 100644 --- a/test/README.md +++ b/test/README.md @@ -1,445 +1,317 @@ Script Tests ============ -
296 ‰ Scripts repo (233) 📅 605 days -
  • 909 ‰ A (11) 📅 501 days -
    • 909 ‰ Add (11) 📅 501 days - -- ✔️ Add-CapturesToMatches.ps1 -- ✔️ Add-Counter.ps1 -- ✔️ Add-DynamicParam.ps1 -- ✔️ Add-GitHubMetadata.ps1 -- ✔️ Add-NotebookCell.ps1 -- ✔️ Add-NoteProperty.ps1 -- ✖️ Add-NugetPackage.ps1 -- ✔️ Add-ParameterDefault.ps1 -- ✔️ Add-ScopeLevel.ps1 -- ✔️ Add-TimeSpan.ps1 +
      257 ‰ Scripts repo (144) 📅 at once +
      • 750 ‰ A (4) 📅 at once +
        • 750 ‰ Add (4) 📅 at once + +- ✔️ Add-GitHubMetadata.ps1 +- ✔️ Add-NotebookCell.ps1 +- ✖️ Add-ScopeLevel.ps1 - ✔️ Add-VsCodeDatabaseConnection.ps1 -
      • -
      • 1000 ‰ B (3) 📅 150 days -
        • 1000 ‰ Backup (3) 📅 150 days +
      • +
      • 1000 ‰ B (3) 📅 at once +
        • 1000 ‰ Backup (3) 📅 at once -- ✔️ Backup-File.ps1 -- ✔️ Backup-SchTasks.ps1 +- ✔️ Backup-File.ps1 +- ✔️ Backup-SchTasks.ps1 - ✔️ Backup-Workstation.ps1 -
      • -
      • 969 ‰ C (32) 📅 580 days -
        • 1000 ‰ Compare (3) 📅 446 days +
      • +
      • 1000 ‰ C (14) 📅 at once +
        • 1000 ‰ Compare (1) 📅 147 days -- ✔️ Compare-Keys.ps1 -- ✔️ Compare-Properties.ps1 - ✔️ Compare-Xml.ps1 -
        • -
        • 1000 ‰ Compress (1) 📅 143 days +
        • +
        • 1000 ‰ Compress (1) 📅 1241 days - ✔️ Compress-EnvironmentVariables.ps1 -
        • -
        • 1000 ‰ Connect (1) 📅 140 days +
        • +
        • 1000 ‰ Connect (1) 📅 150 days - ✔️ Connect-SshKey.ps1 -
        • -
        • 1000 ‰ Convert (3) 📅 580 days +
        • +
        • 1000 ‰ Convert (2) 📅 at once -- ✔️ Convert-ChocolateyToWinget.ps1 -- ✔️ Convert-ClipboardTsvToHtml.ps1 +- ✔️ Convert-ChocolateyToWinget.ps1 - ✔️ Convert-Xml.ps1 -
        • -
        • 1000 ‰ ConvertFrom (9) 📅 408 days - -- ✔️ ConvertFrom-Base64.ps1 -- ✔️ ConvertFrom-CimInstance.ps1 -- ✔️ ConvertFrom-DataRow.ps1 -- ✔️ ConvertFrom-Duration.ps1 -- ✔️ ConvertFrom-EpochTime.ps1 -- ✔️ ConvertFrom-EscapedXml.ps1 -- ✔️ ConvertFrom-Hex.ps1 -- ✔️ ConvertFrom-IsoWeekDate.ps1 +
        • +
        • 1000 ‰ ConvertFrom (2) 📅 at once + +- ✔️ ConvertFrom-EscapedXml.ps1 - ✔️ ConvertFrom-XmlElement.ps1 -
        • -
        • 917 ‰ ConvertTo (12) 📅 573 days - -- ✔️ ConvertTo-Base64.ps1 -- ✔️ ConvertTo-BasicAuthentication.ps1 -- ✔️ ConvertTo-EpochTime.ps1 -- ✖️ ConvertTo-FileName.ps1 -- ✔️ ConvertTo-ICalendar.ps1 -- ✔️ ConvertTo-LogParserTimestamp.ps1 -- ✔️ ConvertTo-MultipartFormData.ps1 -- ✔️ ConvertTo-OrderedDictionary.ps1 -- ✔️ ConvertTo-PowerShell.ps1 -- ✔️ ConvertTo-RomanNumeral.ps1 -- ✔️ ConvertTo-SafeEntities.ps1 +
        • +
        • 1000 ‰ ConvertTo (5) 📅 at once + +- ✔️ ConvertTo-BasicAuthentication.ps1 +- ✔️ ConvertTo-ICalendar.ps1 +- ✔️ ConvertTo-LogParserTimestamp.ps1 +- ✔️ ConvertTo-MultipartFormData.ps1 - ✔️ ConvertTo-XmlElements.ps1 -
        • -
        • 1000 ‰ Copy (3) 📅 62 days +
        • +
        • 1000 ‰ Copy (2) 📅 at once -- ✔️ Copy-GitHubLabels.ps1 -- ✔️ Copy-Html.ps1 +- ✔️ Copy-GitHubLabels.ps1 - ✔️ Copy-SchTasks.ps1 -
      • -
      • 1000 ‰ D (1) 📅 57 days -
        • 1000 ‰ Disable (1) 📅 57 days - -- ✔️ Disable-AnsiColor.ps1 - -
      • -
      • 917 ‰ E (12) 📅 372 days -
        • 1000 ‰ Enable (1) 📅 57 days - -- ✔️ Enable-AnsiColor.ps1 - -
        • -
        • 1000 ‰ Expand (1) 📅 56 days - -- ✔️ Expand-EnvironmentVariables.ps1 - -
        • -
        • 900 ‰ Export (10) 📅 26 days - -- ✔️ Export-DatabaseScripts.ps1 -- ✔️ Export-EdgeKeywords.ps1 -- ✔️ Export-InstalledPackages.ps1 -- ✔️ Export-Json.ps1 -- ✔️ Export-MermaidER.ps1 -- ✖️ Export-MermaidXY.ps1 -- ✔️ Export-OpenApiSchema.ps1 -- ✔️ Export-Readme.ps1 -- ✔️ Export-SecretVault.ps1 +
      • +
      • 1000 ‰ E (8) 📅 at once +
        • 1000 ‰ Export (8) 📅 at once + +- ✔️ Export-DatabaseScripts.ps1 +- ✔️ Export-EdgeKeywords.ps1 +- ✔️ Export-InstalledPackages.ps1 +- ✔️ Export-Json.ps1 +- ✔️ Export-MermaidER.ps1 +- ✔️ Export-Readme.ps1 +- ✔️ Export-SecretVault.ps1 - ✔️ Export-TableMerge.ps1 -
      • -
      • 667 ‰ F (15) 📅 9 days -
        • 1000 ‰ Find (8) 📅 5 days - -- ✔️ Find-DatabaseValue.ps1 -- ✔️ Find-DbColumn.ps1 -- ✔️ Find-DbIndexes.ps1 -- ✔️ Find-DotNetTools.ps1 -- ✔️ Find-InstalledPrograms.ps1 -- ✔️ Find-Lines.ps1 -- ✔️ Find-NewestFile.ps1 -- ✔️ Find-ProjectPackages.ps1 +
      • +
      • 875 ‰ F (8) 📅 at once +
        • 1000 ‰ Find (7) 📅 at once -
        • -
        • 1000 ‰ ForEach (1) 📅 at once - -- ✔️ ForEach-Progress.ps1 +- ✔️ Find-DatabaseValue.ps1 +- ✔️ Find-DbColumn.ps1 +- ✔️ Find-DbIndexes.ps1 +- ✔️ Find-DotNetTools.ps1 +- ✔️ Find-InstalledPrograms.ps1 +- ✔️ Find-Lines.ps1 +- ✔️ Find-ProjectPackages.ps1 -
        • -
        • 167 ‰ Format (6) 📅 at once +
        • +
        • not started Format (1) -- ✔️ Format-ByteUnits.ps1 -- ✖️ Format-Date.ps1 -- ✖️ Format-EscapedUrl.ps1 -- ✖️ Format-HtmlDataTable.ps1 -- ✖️ Format-Permutations.ps1 - ✖️ Format-Xml.ps1 -
      • -
      • 23 ‰ G (44) 📅 490 days -
        • 23 ‰ Get (44) 📅 490 days - -- ✖️ Get-ADServiceAccountInfo.ps1 -- ✖️ Get-ADUserStatus.ps1 -- ✖️ Get-AspNetEvents.ps1 -- ✖️ Get-AssemblyFramework.ps1 -- ✖️ Get-CachedCredential.ps1 -- ✖️ Get-CharacterDetails.ps1 -- ✖️ Get-CommandParameters.ps1 -- ✖️ Get-CommandPath.ps1 -- ✖️ Get-ConfigConnectionStringBuilders.ps1 -- ✖️ Get-ConsoleHistory.ps1 -- ✖️ Get-ContentSecurityPolicy.ps1 -- ✖️ Get-Dns.ps1 -- ✖️ Get-DotNetFrameworkVersions.ps1 -- ✖️ Get-DotNetGlobalTools.ps1 -- ✖️ Get-DotNetVersions.ps1 -- ✖️ Get-EnumValues.ps1 -- ✖️ Get-FrenchRepublicanDate.ps1 -- ✖️ Get-GitFileMetadata.ps1 -- ✖️ Get-GitFirstCommit.ps1 -- ✖️ Get-GitHubRepoChildItem.ps1 -- ✔️ Get-IisLog.ps1 -- ✖️ Get-LibraryVulnerabilityInfo.ps1 -- ✖️ Get-ModuleScope.ps1 -- ✖️ Get-NuGetConfigs.ps1 -- ✖️ Get-OpenApiInfo.ps1 -- ✖️ Get-PathUsage.ps1 -- ✖️ Get-PocketArticles.ps1 -- ✖️ Get-RandomBytes.ps1 -- ✖️ Get-RepoName.ps1 -- ✖️ Get-SecretDetails.ps1 -- ✖️ Get-ServerCertificate.ps1 -- ✖️ Get-SimpleSchTasks.ps1 -- ✖️ Get-SslDetails.ps1 -- ✖️ Get-SystemDetails.ps1 -- ✖️ Get-Todos.ps1 -- ✖️ Get-TypeAccelerators.ps1 -- ✖️ Get-Unicode.ps1 -- ✖️ Get-UnicodeByName.ps1 -- ✖️ Get-UnicodeData.ps1 -- ✖️ Get-UnicodeName.ps1 -- ✖️ Get-VSCCurrentFile.ps1 -- ✖️ Get-VSCodeSetting.ps1 -- ✖️ Get-VSCodeSettingsFile.ps1 +
      • +
      • 28 ‰ G (36) 📅 490 days +
        • 28 ‰ Get (36) 📅 490 days + +- ✖️ Get-ADServiceAccountInfo.ps1 +- ✖️ Get-ADUserStatus.ps1 +- ✖️ Get-AspNetEvents.ps1 +- ✖️ Get-AssemblyFramework.ps1 +- ✖️ Get-CachedCredential.ps1 +- ✖️ Get-CharacterDetails.ps1 +- ✖️ Get-ConfigConnectionStringBuilders.ps1 +- ✖️ Get-ContentSecurityPolicy.ps1 +- ✖️ Get-Dns.ps1 +- ✖️ Get-DotNetFrameworkVersions.ps1 +- ✖️ Get-DotNetGlobalTools.ps1 +- ✖️ Get-DotNetVersions.ps1 +- ✖️ Get-GitFileMetadata.ps1 +- ✖️ Get-GitFirstCommit.ps1 +- ✖️ Get-GitHubRepoChildItem.ps1 +- ✔️ Get-IisLog.ps1 +- ✖️ Get-LibraryVulnerabilityInfo.ps1 +- ✖️ Get-NuGetConfigs.ps1 +- ✖️ Get-OpenApiInfo.ps1 +- ✖️ Get-PathUsage.ps1 +- ✖️ Get-PocketArticles.ps1 +- ✖️ Get-RepoName.ps1 +- ✖️ Get-SecretDetails.ps1 +- ✖️ Get-ServerCertificate.ps1 +- ✖️ Get-SimpleSchTasks.ps1 +- ✖️ Get-SslDetails.ps1 +- ✖️ Get-SystemDetails.ps1 +- ✖️ Get-Todos.ps1 +- ✖️ Get-Unicode.ps1 +- ✖️ Get-UnicodeByName.ps1 +- ✖️ Get-UnicodeData.ps1 +- ✖️ Get-UnicodeName.ps1 +- ✖️ Get-VSCCurrentFile.ps1 +- ✖️ Get-VSCodeSetting.ps1 +- ✖️ Get-VSCodeSettingsFile.ps1 - ✖️ Get-XmlNamespaces.ps1 -
      • +
  • not started H (1)
    • not started Hide (1) - ✖️ Hide-Command.ps1 -
  • -
  • not started I (10) -
    • not started Import (6) +
  • +
  • not started I (6) +
    • not started Import (4) -- ✖️ Import-CharConstants.ps1 -- ✖️ Import-ClipboardTsv.ps1 -- ✖️ Import-EdgeKeywords.ps1 -- ✖️ Import-SecretVault.ps1 -- ✖️ Import-Variables.ps1 +- ✖️ Import-CharConstants.ps1 +- ✖️ Import-EdgeKeywords.ps1 +- ✖️ Import-SecretVault.ps1 - ✖️ Import-VsCodeDatabaseConnections.ps1 -
    • +
  • not started Initialize (1) - ✖️ Initialize-DatabaseNotebook.ps1 -
  • -
  • not started Invoke (3) +
  • +
  • not started Invoke (1) -- ✖️ Invoke-CachedCommand.ps1 - ✖️ Invoke-CommandWithParams.ps1 -- ✖️ Invoke-WindowsPowerShell.ps1 -
-
  • not started J (2) -
    • not started Join (2) +
  • +
  • not started J (1) +
    • not started Join (1) - ✖️ Join-FileName.ps1 -- ✖️ Join-Keys.ps1 - -
  • -
  • not started L (1) -
    • not started Limit (1) -- ✖️ Limit-Digits.ps1 +
  • +
  • not started M (9) +
    • not started Measure (7) -
  • -
  • not started M (12) -
    • not started Measure (9) - -- ✖️ Measure-Caches.ps1 -- ✖️ Measure-DbColumn.ps1 -- ✖️ Measure-DbColumnValues.ps1 -- ✖️ Measure-DbTable.ps1 -- ✖️ Measure-Indents.ps1 -- ✖️ Measure-Properties.ps1 -- ✖️ Measure-StandardDeviation.ps1 +- ✖️ Measure-Caches.ps1 +- ✖️ Measure-DbColumn.ps1 +- ✖️ Measure-DbColumnValues.ps1 +- ✖️ Measure-DbTable.ps1 +- ✖️ Measure-Indents.ps1 +- ✖️ Measure-StandardDeviation.ps1 - ✖️ Measure-TextFile.ps1 -- ✖️ Measure-Values.ps1 -
    • -
    • not started Merge (3) +
    • +
    • not started Merge (2) -- ✖️ Merge-Json.ps1 -- ✖️ Merge-PSObject.ps1 +- ✖️ Merge-Json.ps1 - ✖️ Merge-XmlSelections.ps1 -
  • +
  • not started N (7)
    • not started New (7) -- ✖️ New-DbProviderObject.ps1 -- ✖️ New-Jwt.ps1 -- ✖️ New-NamespaceManager.ps1 -- ✖️ New-PesterTests.ps1 -- ✖️ New-RandomVehicle.ps1 -- ✖️ New-Script.ps1 +- ✖️ New-DbProviderObject.ps1 +- ✖️ New-Jwt.ps1 +- ✖️ New-NamespaceManager.ps1 +- ✖️ New-PesterTests.ps1 +- ✖️ New-RandomVehicle.ps1 +- ✖️ New-Script.ps1 - ✖️ New-Shortcut.ps1 -
  • +
  • not started O (2)
    • not started Optimize (2) -- ✖️ Optimize-Help.ps1 +- ✖️ Optimize-Help.ps1 - ✖️ Optimize-Path.ps1 -
  • +
  • not started P (1)
    • not started Push (1) - ✖️ Push-WorkspaceLocation.ps1 -
  • -
  • not started R (20) -
    • not started Read (2) +
  • +
  • not started R (15) +
    • not started Read (1) - ✖️ Read-ChocolateySummary.ps1 -- ✖️ Read-Choice.ps1 -
    • -
    • not started Remove (6) +
    • +
    • not started Remove (3) -- ✖️ Remove-CachedCredential.ps1 -- ✖️ Remove-ConsoleHistory.ps1 -- ✖️ Remove-LockyFile.ps1 -- ✖️ Remove-NullValues.ps1 -- ✖️ Remove-ParameterDefault.ps1 +- ✖️ Remove-CachedCredential.ps1 +- ✖️ Remove-LockyFile.ps1 - ✖️ Remove-PocketArticle.ps1 -
    • +
  • not started Rename (2) -- ✖️ Rename-GitHubLocalBranch.ps1 +- ✖️ Rename-GitHubLocalBranch.ps1 - ✖️ Rename-Script.ps1 -
  • -
  • not started Repair (5) +
  • +
  • not started Repair (4) -- ✖️ Repair-AppxPackages.ps1 -- ✖️ Repair-DatabaseConstraintNames.ps1 -- ✖️ Repair-DatabaseUntrustedConstraints.ps1 -- ✖️ Repair-MarkdownHeaders.ps1 +- ✖️ Repair-AppxPackages.ps1 +- ✖️ Repair-DatabaseConstraintNames.ps1 +- ✖️ Repair-DatabaseUntrustedConstraints.ps1 - ✖️ Repair-ScriptStyle.ps1 -
  • +
  • not started Resolve (3) -- ✖️ Resolve-JsonPointer.ps1 -- ✖️ Resolve-XmlSchemaLocation.ps1 +- ✖️ Resolve-JsonPointer.ps1 +- ✖️ Resolve-XmlSchemaLocation.ps1 - ✖️ Resolve-XPath.ps1 -
  • +
  • not started Restore (2) -- ✖️ Restore-SchTasks.ps1 +- ✖️ Restore-SchTasks.ps1 - ✖️ Restore-Workstation.ps1 -
  • -
  • 80 ‰ S (25) 📅 48 days -
    • not started Save (3) +
  • +
  • 77 ‰ S (13) 📅 48 days +
    • not started Save (1) -- ✖️ Save-PodcastEpisodes.ps1 - ✖️ Save-Secret.ps1 -- ✖️ Save-WebRequest.ps1 -
    • -
    • 667 ‰ Select (3) 📅 48 days +
    • +
    • 1000 ‰ Select (1) 📅 48 days -- ✔️ Select-CapturesFromMatches.ps1 - ✔️ Select-Json.ps1 -- ✖️ Select-ScriptCommands.ps1 -
    • +
  • not started Send (4) -- ✖️ Send-MailMessageFile.ps1 -- ✖️ Send-SeqEvent.ps1 -- ✖️ Send-SeqScriptEvent.ps1 +- ✖️ Send-MailMessageFile.ps1 +- ✖️ Send-SeqEvent.ps1 +- ✖️ Send-SeqScriptEvent.ps1 - ✖️ Send-SqlReport.ps1 -
  • -
  • not started Set (6) +
  • +
  • not started Set (5) -- ✖️ Set-ConsoleColorTheme.ps1 -- ✖️ Set-Json.ps1 -- ✖️ Set-ParameterDefault.ps1 -- ✖️ Set-RegexReplace.ps1 -- ✖️ Set-SchTaskMsa.ps1 +- ✖️ Set-ConsoleColorTheme.ps1 +- ✖️ Set-Json.ps1 +- ✖️ Set-SchTaskMsa.ps1 +- ✖️ Set-TerminalProfile.ps1 - ✖️ Set-VSCodeSetting.ps1 -
  • -
  • not started Show (6) +
  • +
  • not started Show (2) -- ✖️ Show-DataRef.ps1 +- ✖️ Show-DataRef.ps1 - ✖️ Show-HttpStatus.ps1 -- ✖️ Show-OpenApiInfo.ps1 -- ✖️ Show-PSDriveUsage.ps1 -- ✖️ Show-Status.ps1 -- ✖️ Show-Time.ps1 - -
  • -
  • not started Split (2) - -- ✖️ Split-Keys.ps1 -- ✖️ Split-Uri.ps1 - -
  • -
  • not started Stop (1) - -- ✖️ Stop-ThrowError.ps1 - -
  • -
  • not started T (19) -
    • not started Test (17) - -- ✖️ Test-Administrator.ps1 -- ✖️ Test-ConnectionString.ps1 -- ✖️ Test-DateTime.ps1 -- ✖️ Test-FileTypeMagicNumber.ps1 -- ✖️ Test-HttpSecurity.ps1 -- ✖️ Test-Interactive.ps1 -- ✖️ Test-Jwt.ps1 -- ✖️ Test-LockedFile.ps1 -- ✖️ Test-MagicNumber.ps1 -- ✖️ Test-NewerFile.ps1 -- ✖️ Test-NoteProperty.ps1 -- ✖️ Test-Range.ps1 -- ✖️ Test-Uri.ps1 -- ✖️ Test-USFederalHoliday.ps1 -- ✖️ Test-Variable.ps1 -- ✖️ Test-Windows1252.ps1 -- ✖️ Test-Xml.ps1 -
    • -
    • not started Trace (2) +
  • +
  • not started T (8) +
    • not started Test (7) -- ✖️ Trace-GitRepoTest.ps1 -- ✖️ Trace-WebRequest.ps1 +- ✖️ Test-ConnectionString.ps1 +- ✖️ Test-HttpSecurity.ps1 +- ✖️ Test-Jwt.ps1 +- ✖️ Test-LockedFile.ps1 +- ✖️ Test-Windows1252.ps1 +- ✖️ Test-WindowsTerminal.ps1 +- ✖️ Test-Xml.ps1 -
  • -
  • not started U (12) -
    • not started Uninstall (1) +
    • +
    • not started Trace (1) -- ✖️ Uninstall-OldModules.ps1 +- ✖️ Trace-GitRepoTest.ps1 -
    • -
    • not started Update (4) +
  • +
  • not started U (8) +
    • not started Update (2) -- ✖️ Update-DotNetPackages.ps1 +- ✖️ Update-DotNetPackages.ps1 - ✖️ Update-Everything.ps1 -- ✖️ Update-Files.ps1 -- ✖️ Update-Modules.ps1 - -
    • -
    • not started Use (7) - -- ✖️ Use-Command.ps1 -- ✖️ Use-Java.ps1 -- ✖️ Use-NetMailConfig.ps1 -- ✖️ Use-ProgressView.ps1 -- ✖️ Use-ReasonableDefaults.ps1 -- ✖️ Use-SeqServer.ps1 -- ✖️ Use-SqlcmdParams.ps1 -
  • -
  • not started W (3) -
    • not started Write (3) +
    • +
    • not started Use (6) -- ✖️ Write-CallInfo.ps1 -- ✖️ Write-Info.ps1 -- ✖️ Write-VisibleString.ps1 +- ✖️ Use-Command.ps1 +- ✖️ Use-DbInstance.ps1 +- ✖️ Use-Java.ps1 +- ✖️ Use-NetMailConfig.ps1 +- ✖️ Use-SeqServer.ps1 +- ✖️ Use-SqlcmdParams.ps1 -
  • + diff --git a/test/Select-CapturesFromMatches.Tests.ps1 b/test/Select-CapturesFromMatches.Tests.ps1 deleted file mode 100644 index ae79c560..00000000 --- a/test/Select-CapturesFromMatches.Tests.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -<# -.SYNOPSIS -Tests selecting named capture group values as note properties from Select-String MatchInfo objects. -#> - -$basename = "$(($MyInvocation.MyCommand.Name -split '\.',2)[0])." -$skip = !(Test-Path .changes -Type Leaf) ? $false : - !@(Get-Content .changes |Get-Item |Select-Object -ExpandProperty Name |Where-Object {$_.StartsWith($basename)}) -if($skip) {Write-Information "No changes to $basename" -infa Continue} -Describe 'Select-CapturesFromMatches' -Tag Select-CapturesFromMatches -Skip:$skip { - BeforeAll { - $scriptsdir,$sep = (Split-Path $PSScriptRoot),[io.path]::PathSeparator - if($scriptsdir -notin ($env:Path -split $sep)) {$env:Path += "$sep$scriptsdir"} - } - Context 'Selects named capture group values as note properties from Select-String MatchInfo objects' ` - -Tag SelectCapturesFromMatches,Select,Captures,Regex { - It "Should select name '' and email '' from '' using ''" -TestCases @( - @{ InputString = 'Arthur Dent adent@example.org'; Regex = '^(?.*?\b)\s*(?\S+@\S+)$'; Name = 'Arthur Dent'; Email = 'adent@example.org' } - @{ InputString = 'Tricia McMillan '; Regex = '^(?.*?\b)\s*<(?\S+@\S+)>$'; Name = 'Tricia McMillan'; Email = 'trillian@example.com' } - ) { - Param([string] $InputString, [regex] $Regex, [string] $Name, [string] $Email) - $captures = $InputString |Select-String $Regex |Select-CapturesFromMatches.ps1 - $captures.Name |Should -BeExactly $Name - $captures.Email |Should -BeExactly $Email - } - } -} From ec3d656650357f70531a8bc79c14d478b7be97a6 Mon Sep 17 00:00:00 2001 From: Brian Lalonde Date: Wed, 6 May 2026 09:33:22 -0700 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=90=9B=20Prevent=20extra=20newline=20?= =?UTF-8?q?at=20end=20of=20converted=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Convert-ExternalScriptToModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Convert-ExternalScriptToModule.ps1 b/Convert-ExternalScriptToModule.ps1 index e0fd66ab..1850dc68 100644 --- a/Convert-ExternalScriptToModule.ps1 +++ b/Convert-ExternalScriptToModule.ps1 @@ -43,7 +43,7 @@ Begin $start,$end = $_.StartOffset,$_.EndOffset $script = $script.Remove($start, $end - $start).Insert($start, (Split-Path $_.Text -LeafBase)) } - $script.Insert($usingOffset, "using module $ModuleName`r`n") | + $script.Insert($usingOffset, "using module $ModuleName`r`n").Trim() | Out-File $ps1 -Encoding $encoding } From d77f8adb31207f6cdf4b43d19d769f710afa2648 Mon Sep 17 00:00:00 2001 From: Brian Lalonde Date: Wed, 6 May 2026 15:37:46 -0700 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=90=9B=20Be=20sure=20to=20update=20sc?= =?UTF-8?q?ript=20bottom-to-top=20so=20offsets=20don't=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Convert-ExternalScriptToModule.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Convert-ExternalScriptToModule.ps1 b/Convert-ExternalScriptToModule.ps1 index 1850dc68..9704fe76 100644 --- a/Convert-ExternalScriptToModule.ps1 +++ b/Convert-ExternalScriptToModule.ps1 @@ -31,15 +31,13 @@ Begin ) if($Values.Count -ne 1) {throw "Unexpected grouping of $($Values.Count) files."} $ps1,$cmd = $Values.FullName,$Values.BaseName - $ext = New-Object Stack[IScriptExtent] $Group.Count - $Group |ForEach-Object {$ext.Push($_)} [int] $usingOffset = Get-ScriptTokens $ps1 | Where-Object Kind -notin 'Comment','NewLine' | Select-Object -First 1 | ForEach-Object {$_.Extent.StartOffset} $encoding = Get-FileEncoding $ps1 $script = Get-Content $ps1 -Raw - $ext |ForEach-Object { + $Group |Sort-Object StartOffset -Descending |ForEach-Object { $start,$end = $_.StartOffset,$_.EndOffset $script = $script.Remove($start, $end - $start).Insert($start, (Split-Path $_.Text -LeafBase)) } From 06f5625ba72453d0ba5dc1ae827c09311cbb7eff Mon Sep 17 00:00:00 2001 From: Brian Lalonde Date: Wed, 13 May 2026 20:57:11 -0700 Subject: [PATCH 5/7] =?UTF-8?q?=E2=9C=A8=20Add=20warnings=20for=20remainin?= =?UTF-8?q?g=20refs;=20update=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Convert-ExternalScriptToModule.ps1 | 10 + Export-Readme.ps1 | 1 + README.md | 475 +++++++++++---------- docs/Convert-ExternalScriptToModule.ps1.md | 89 ++++ docs/ConvertFrom-CimInstance.ps1.md | 75 ++++ docs/ConvertFrom-DataRow.ps1.md | 119 ++++++ docs/Export-OpenApiSchema.ps1.md | 155 +++++++ docs/Save-PodcastEpisodes.ps1.md | 166 +++++++ docs/Save-WebRequest.ps1.md | 150 +++++++ docs/Show-OpenApiInfo.ps1.md | 80 ++++ docs/Trace-WebRequest.ps1.md | 156 +++++++ docs/index.md | 10 +- test/README.md | 36 +- 13 files changed, 1274 insertions(+), 248 deletions(-) create mode 100644 docs/Convert-ExternalScriptToModule.ps1.md create mode 100644 docs/ConvertFrom-CimInstance.ps1.md create mode 100644 docs/ConvertFrom-DataRow.ps1.md create mode 100644 docs/Export-OpenApiSchema.ps1.md create mode 100644 docs/Save-PodcastEpisodes.ps1.md create mode 100644 docs/Save-WebRequest.ps1.md create mode 100644 docs/Show-OpenApiInfo.ps1.md create mode 100644 docs/Trace-WebRequest.ps1.md diff --git a/Convert-ExternalScriptToModule.ps1 b/Convert-ExternalScriptToModule.ps1 index 9704fe76..c97fd778 100644 --- a/Convert-ExternalScriptToModule.ps1 +++ b/Convert-ExternalScriptToModule.ps1 @@ -57,8 +57,18 @@ Begin ForEach-Object {$_.Tokens.Extent} | Group-Object {Get-Item $_.File} } + + function Write-OutstandingWarning + { + [CmdletBinding()] Param( + [Parameter(Position=0,Mandatory=$true)][string] $Path + ) + [string[]] $cmdlets = Get-Command -Module $ModuleName |Select-Object -ExpandProperty Name + Select-String -Pattern "\b(?:$($cmdlets -join '|'))\.ps1\b" -Path $Path |Write-Warning + } } Process { Find-ExternalScriptUsage $Path |Update-ScriptFile + Write-OutstandingWarning $Path } diff --git a/Export-Readme.ps1 b/Export-Readme.ps1 index 104e9ef6..20f14230 100644 --- a/Export-Readme.ps1 +++ b/Export-Readme.ps1 @@ -306,6 +306,7 @@ Useful General-Purpose Scripts > [!NOTE] > Many scripts have been moved into modules to improve their usability! > See **[ModernConveniences][]** and the [scripts-to-modules.json roadmap][]. +> Use **[Convert-ExternalScriptToModule.ps1](Convert-ExternalScriptToModule.ps1)** to convert your scripts! [ModernConveniences]: https://github.com/brianary/ModernConveniences/ "A collection of general-purpose functions for objects, properties, and more." [scripts-to-modules.json roadmap]: scripts-to-modules.json "The plan to divide the scripts into modules by purpose." diff --git a/README.md b/README.md index 1725a31c..aca70f91 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -Useful General-Purpose Scripts +Useful General-Purpose Scripts ============================== [![Pester tests results](https://gist.githubusercontent.com/brianary/4642e5c804aa1b40738def5a7c03607a/raw/badge.svg)][pester.yml] -[![Pester tests coverage](https://img.shields.io/badge/Pester_coverage-3471_%E2%80%B1-orange +[![Pester tests coverage](https://img.shields.io/badge/Pester_coverage-3426_%E2%80%B1-orange red)](https://github.com/brianary/scripts/tree/main/test) [![GitHub license badge](https://badgen.net/github/license/brianary/Scripts?icon=github)](https://mit-license.org/ "MIT License") [![GitHub stars badge](https://badgen.net/github/stars/brianary/Scripts?icon=github)](https://github.com/brianary/scripts/stargazers "Stars") @@ -19,6 +19,7 @@ red)](https://github.com/brianary/scripts/tree/main/test) > [!NOTE] > Many scripts have been moved into modules to improve their usability! > See **[ModernConveniences][]** and the [scripts-to-modules.json roadmap][]. +> Use **[Convert-ExternalScriptToModule.ps1](Convert-ExternalScriptToModule.ps1)** to convert your scripts! [ModernConveniences]: https://github.com/brianary/ModernConveniences/ "A collection of general-purpose functions for objects, properties, and more." [scripts-to-modules.json roadmap]: scripts-to-modules.json "The plan to divide the scripts into modules by purpose." @@ -29,243 +30,251 @@ See [PS5](PS5) for legacy scripts, [syscfg](syscfg) for single-use system config PowerShell Scripts ------------------ - -### Command - -- **[Hide-Command.ps1](Hide-Command.ps1)**: Make a command unavailable. -- **[Invoke-CommandWithParams.ps1](Invoke-CommandWithParams.ps1)**: Execute a command by using matching dictionary entries as parameters. -- **[Use-Command.ps1](Use-Command.ps1)**: Checks for the existence of the given command, and adds if missing and a source is defined. - -### Configuration - -- **[Get-ConfigConnectionStringBuilders.ps1](Get-ConfigConnectionStringBuilders.ps1)**: Return named connection string builders for connection strings in a config file. -- **[Get-NuGetConfigs.ps1](Get-NuGetConfigs.ps1)**: Returns the available NuGet configuration files, in order of preference. -- **[Use-NetMailConfig.ps1](Use-NetMailConfig.ps1)**: Use .NET configuration to set defaults for Send-MailMessage. - -### Console - -- **[Set-ConsoleColorTheme.ps1](Set-ConsoleColorTheme.ps1)**: Overrides ConsoleClass window color palette entries with a preset color theme. - -### Credential - -- **[Export-SecretVault.ps1](Export-SecretVault.ps1)**: Exports secret vault content. -- **[Get-CachedCredential.ps1](Get-CachedCredential.ps1)**: Return a credential from secure storage, or prompt the user for it if not found. -- **[Get-SecretDetails.ps1](Get-SecretDetails.ps1)**: Returns secret info from the secret vaults, including metadata as properties. -- **[Import-SecretVault.ps1](Import-SecretVault.ps1)**: Imports secrets into secret vaults. -- **[Remove-CachedCredential.ps1](Remove-CachedCredential.ps1)**: Removes a credential from secure storage. -- **[Save-Secret.ps1](Save-Secret.ps1)**: Sets a secret in a secret vault with metadata. - -### Data formats - -- **[New-Jwt.ps1](New-Jwt.ps1)**: Generates a JSON Web Token (JWT) -- **[Test-Jwt.ps1](Test-Jwt.ps1)**: Determines whether a string is a valid JWT. -- **[Test-Windows1252.ps1](Test-Windows1252.ps1)**: Determines whether a file contains Windows-1252 bytes that are invalid UTF-8 bytes. - -### Database - -- **[Export-DatabaseScripts.ps1](Export-DatabaseScripts.ps1)**: Exports MS SQL database objects from the given server and database as files, into a consistent folder structure. -- **[Export-TableMerge.ps1](Export-TableMerge.ps1)**: Exports table data as a T-SQL MERGE statement. -- **[Find-DatabaseValue.ps1](Find-DatabaseValue.ps1)**: Searches an entire database for a field value. -- **[Find-DbColumn.ps1](Find-DbColumn.ps1)**: Searches for database columns. -- **[Find-DbIndexes.ps1](Find-DbIndexes.ps1)**: Returns indexes using a column with the given name. -- **[Initialize-DatabaseNotebook.ps1](Initialize-DatabaseNotebook.ps1)**: Populates a new notebook with details about a database. -- **[Measure-DbColumn.ps1](Measure-DbColumn.ps1)**: Provides statistics about SQL Server column data. -- **[Measure-DbColumnValues.ps1](Measure-DbColumnValues.ps1)**: Provides sorted counts of SQL Server column values. -- **[Measure-DbTable.ps1](Measure-DbTable.ps1)**: Provides frequency details about SQL Server table data. -- **[New-DbProviderObject.ps1](New-DbProviderObject.ps1)**: Create a common database object. -- **[Repair-DatabaseConstraintNames.ps1](Repair-DatabaseConstraintNames.ps1)**: Finds database constraints with system-generated names and gives them deterministic names. -- **[Repair-DatabaseUntrustedConstraints.ps1](Repair-DatabaseUntrustedConstraints.ps1)**: Finds database constraints that have been incompletely re-enabled. -- **[Send-SqlReport.ps1](Send-SqlReport.ps1)**: Execute a SQL statement and email the results. -- **[Test-ConnectionString.ps1](Test-ConnectionString.ps1)**: Test a given connection string and provide details about the connection. -- **[Use-SqlcmdParams.ps1](Use-SqlcmdParams.ps1)**: Use the calling script parameters to set Invoke-Sqlcmd defaults. - -### Date and time - -- **[ConvertTo-LogParserTimestamp.ps1](ConvertTo-LogParserTimestamp.ps1)**: Formats a datetime as a LogParser literal. - -### DotNet - -- **[Find-DotNetTools.ps1](Find-DotNetTools.ps1)**: Returns a list of matching dotnet tools. -- **[Get-AssemblyFramework.ps1](Get-AssemblyFramework.ps1)**: Gets the framework version an assembly was compiled for. -- **[Get-DotNetFrameworkVersions.ps1](Get-DotNetFrameworkVersions.ps1)**: Determine which .NET Frameworks are installed on the requested system. -- **[Get-DotNetGlobalTools.ps1](Get-DotNetGlobalTools.ps1)**: Returns a list of global dotnet tools. -- **[Get-DotNetVersions.ps1](Get-DotNetVersions.ps1)**: Determine which .NET Core & Framework versions are installed. -- **[Update-DotNetPackages.ps1](Update-DotNetPackages.ps1)**: Updates NuGet packages for a .NET solution or project. - -### EnvironmentVariables - -- **[Compress-EnvironmentVariables.ps1](Compress-EnvironmentVariables.ps1)**: Replaces each of the longest matching parts of a string with an embedded environment variable with that value. - -### Files - -- **[Backup-File.ps1](Backup-File.ps1)**: Create a backup as a sibling to a file, with date and time values in the name. -- **[Join-FileName.ps1](Join-FileName.ps1)**: Combines a filename with a string. -- **[Measure-Caches.ps1](Measure-Caches.ps1)**: Returns a list of matching cache directories, and their sizes, sorted. -- **[New-Shortcut.ps1](New-Shortcut.ps1)**: Create a Windows shortcut. -- **[Remove-LockyFile.ps1](Remove-LockyFile.ps1)**: Removes a file that may be prone to locking. -- **[Test-LockedFile.ps1](Test-LockedFile.ps1)**: Returns true if the specified file is locked. - -### Git and GitHub - -- **[Add-GitHubMetadata.ps1](Add-GitHubMetadata.ps1)**: Adds GitHub Linguist overrides to a repo's .gitattributes. -- **[Copy-GitHubLabels.ps1](Copy-GitHubLabels.ps1)**: Copies configured issue labels from one repo to another. -- **[Get-GitFileMetadata.ps1](Get-GitFileMetadata.ps1)**: Returns the creation and last modification metadata for a file in a git repo. -- **[Get-GitFirstCommit.ps1](Get-GitFirstCommit.ps1)**: Gets the SHA-1 hash of the first commit of the current repo. -- **[Get-RepoName.ps1](Get-RepoName.ps1)**: Gets the name of the repo. -- **[Rename-GitHubLocalBranch.ps1](Rename-GitHubLocalBranch.ps1)**: Rename a git repository branch. -- **[Trace-GitRepoTest.ps1](Trace-GitRepoTest.ps1)**: Uses git bisect to search for the point in the repo history that the test script starts returning true. - -### HTTP - -- **[ConvertTo-BasicAuthentication.ps1](ConvertTo-BasicAuthentication.ps1)**: Produces a basic authentication header string from a credential. -- **[ConvertTo-MultipartFormData.ps1](ConvertTo-MultipartFormData.ps1)**: Creates multipart/form-data to send as a request body. -- **[Get-ContentSecurityPolicy.ps1](Get-ContentSecurityPolicy.ps1)**: Returns the content security policy at from the given URL. -- **[Get-SslDetails.ps1](Get-SslDetails.ps1)**: Enumerates the SSL protocols that the client is able to successfully use to connect to a server. -- **[Show-HttpStatus.ps1](Show-HttpStatus.ps1)**: Displays the HTTP status code info. - -### Json - -- **[Export-Json.ps1](Export-Json.ps1)**: Exports a portion of a JSON document, recursively importing references. -- **[Get-OpenApiInfo.ps1](Get-OpenApiInfo.ps1)**: Returns metadata from an OpenAPI definition. -- **[Merge-Json.ps1](Merge-Json.ps1)**: Create a new JSON string by recursively combining the properties of JSON strings. -- **[Resolve-JsonPointer.ps1](Resolve-JsonPointer.ps1)**: Returns matching JSON Pointer paths, given a JSON Pointer path with wildcards. -- **[Select-Json.ps1](Select-Json.ps1)**: Returns a value from a JSON string or file. -- **[Set-Json.ps1](Set-Json.ps1)**: Sets a property in a JSON string or file. - -### Mermaid Diagrams - -- **[Export-MermaidER.ps1](Export-MermaidER.ps1)**: Generates a Mermaid entity relation diagram for database tables. - -### Notebooks - -- **[Add-NotebookCell.ps1](Add-NotebookCell.ps1)**: When run within a Polyglot Notebook, appends a cell to it. - -### Packages and libraries - -- **[Find-ProjectPackages.ps1](Find-ProjectPackages.ps1)**: Find modules used in projects. -- **[Get-LibraryVulnerabilityInfo.ps1](Get-LibraryVulnerabilityInfo.ps1)**: Get the list of module/package/library vulnerabilities from the RetireJS or SafeNuGet projects. - -### PowerShell - -- **[Add-ScopeLevel.ps1](Add-ScopeLevel.ps1)**: Convert a scope level to account for another call stack level. - -### Scheduled Tasks - -- **[Backup-SchTasks.ps1](Backup-SchTasks.ps1)**: Exports the local list of Scheduled Tasks into a single XML file. -- **[ConvertTo-ICalendar.ps1](ConvertTo-ICalendar.ps1)**: Converts supported objects (Scheduled Tasks) to the RFC 5545 iCalendar format. -- **[Copy-SchTasks.ps1](Copy-SchTasks.ps1)**: Copy scheduled jobs from another computer to this one, using a GUI list to choose jobs. -- **[Get-SimpleSchTasks.ps1](Get-SimpleSchTasks.ps1)**: Returns simple scheduled task info. -- **[Restore-SchTasks.ps1](Restore-SchTasks.ps1)**: Imports from a single XML file into the local Scheduled Tasks. -- **[Set-SchTaskMsa.ps1](Set-SchTaskMsa.ps1)**: Sets a Scheduled Task's runtime user as the given gMSA/MSA. - -### Scripts - -- **[New-PesterTests.ps1](New-PesterTests.ps1)**: Creates a new Pester testing script from a script's examples and parameter sets. -- **[New-Script.ps1](New-Script.ps1)**: Creates a simple boilerplate script. -- **[Optimize-Help.ps1](Optimize-Help.ps1)**: Cleans up comment-based help blocks by fully unindenting and capitalizing dot keywords. -- **[Rename-Script.ps1](Rename-Script.ps1)**: Renames all instances of a script, and updates any usage of it. -- **[Repair-ScriptStyle.ps1](Repair-ScriptStyle.ps1)**: Accepts justifications for script analysis rule violations, fixing the rest using Invoke-ScriptAnalysis. - -### Search and replace - -- **[Find-Lines.ps1](Find-Lines.ps1)**: Searches a specific subset of files for lines matching a pattern. - -### Seq - -- **[Send-SeqEvent.ps1](Send-SeqEvent.ps1)**: Send an event to a Seq server. -- **[Send-SeqScriptEvent.ps1](Send-SeqScriptEvent.ps1)**: Sends an event (often an error) from a script to a Seq server, including script info. -- **[Use-SeqServer.ps1](Use-SeqServer.ps1)**: Set the default Server and ApiKey for Send-SeqEvent.ps1 - -### System and updates - -- **[Convert-ChocolateyToWinget.ps1](Convert-ChocolateyToWinget.ps1)**: Change from managing various packages with Chocolatey to WinGet. -- **[Export-EdgeKeywords.ps1](Export-EdgeKeywords.ps1)**: Returns the configured search keywords from an Edge SQLite file. -- **[Export-InstalledPackages.ps1](Export-InstalledPackages.ps1)**: Exports the list of packages installed by various tools. -- **[Find-InstalledPrograms.ps1](Find-InstalledPrograms.ps1)**: Searches installed programs. -- **[Get-SystemDetails.ps1](Get-SystemDetails.ps1)**: Collects some useful system hardware and operating system details via CIM. -- **[Import-EdgeKeywords.ps1](Import-EdgeKeywords.ps1)**: Adds search keywords to an Edge SQLite profile configuration. -- **[Read-ChocolateySummary.ps1](Read-ChocolateySummary.ps1)**: Retrieves the a summary from the Chocolatey log. -- **[Update-Everything.ps1](Update-Everything.ps1)**: Updates everything it can on the system. -- **[Use-Java.ps1](Use-Java.ps1)**: Switch the Java version for the current process by modifying environment variables. - -### TLS/SSL - -- **[Get-ServerCertificate.ps1](Get-ServerCertificate.ps1)**: Returns the certificate provided by the requested server. - -### Unicode - -- **[Get-CharacterDetails.ps1](Get-CharacterDetails.ps1)**: Returns filterable categorical information about characters in the Unicode Basic Multilingual Plane. -- **[Get-Unicode.ps1](Get-Unicode.ps1)**: Returns the (UTF-16) .NET string for a given Unicode codepoint, which may be a surrogate pair. -- **[Get-UnicodeByName.ps1](Get-UnicodeByName.ps1)**: Returns characters based on Unicode code point name, GitHub short code, or HTML entity. -- **[Get-UnicodeData.ps1](Get-UnicodeData.ps1)**: Returns the current (cached) Unicode character data. -- **[Get-UnicodeName.ps1](Get-UnicodeName.ps1)**: Returns the name of a Unicode code point. -- **[Import-CharConstants.ps1](Import-CharConstants.ps1)**: Imports characters by name as constants into the current scope. - -### VSCode - -- **[Add-VsCodeDatabaseConnection.ps1](Add-VsCodeDatabaseConnection.ps1)**: Adds a VS Code MSSQL database connection to the repo. -- **[Get-VSCCurrentFile.ps1](Get-VSCCurrentFile.ps1)**: Returns the path of the current file open in VSCode, when run in the PowerShell Extension Terminal in VSCode. -- **[Get-VSCodeSetting.ps1](Get-VSCodeSetting.ps1)**: Sets a VSCode setting. -- **[Get-VSCodeSettingsFile.ps1](Get-VSCodeSettingsFile.ps1)**: Gets the path of the VSCode settings.config file. -- **[Import-VsCodeDatabaseConnections.ps1](Import-VsCodeDatabaseConnections.ps1)**: Adds config XDT connection strings to VSCode settings. -- **[Push-WorkspaceLocation.ps1](Push-WorkspaceLocation.ps1)**: Pushes the current VS Code editor workspace location to the location stack. -- **[Set-VSCodeSetting.ps1](Set-VSCodeSetting.ps1)**: Sets a VSCode setting. - -### Windows Terminal - -- **[Set-TerminalProfile.ps1](Set-TerminalProfile.ps1)**: Adds or updates a Windows Terminal command profile. -- **[Test-WindowsTerminal.ps1](Test-WindowsTerminal.ps1)**: Returns true if PowerShell is running within Windows Terminal. - -### XML - -- **[Compare-Xml.ps1](Compare-Xml.ps1)**: Compares two XML documents and returns the differences. -- **[Convert-Xml.ps1](Convert-Xml.ps1)**: Transform XML using an XSLT template. -- **[ConvertFrom-EscapedXml.ps1](ConvertFrom-EscapedXml.ps1)**: Parse escaped XML into XML and serialize it. -- **[ConvertFrom-XmlElement.ps1](ConvertFrom-XmlElement.ps1)**: Converts named nodes of an element to properties of a PSObject, recursively. -- **[ConvertTo-XmlElements.ps1](ConvertTo-XmlElements.ps1)**: Serializes complex content into XML elements. -- **[Format-Xml.ps1](Format-Xml.ps1)**: Pretty-print XML. -- **[Get-XmlNamespaces.ps1](Get-XmlNamespaces.ps1)**: Gets the namespaces from a document as a dictionary. -- **[Merge-XmlSelections.ps1](Merge-XmlSelections.ps1)**: Builds an object using the named XPath selections as properties. -- **[New-NamespaceManager.ps1](New-NamespaceManager.ps1)**: Creates an object to lookup XML namespace prefixes. -- **[Resolve-XmlSchemaLocation.ps1](Resolve-XmlSchemaLocation.ps1)**: Gets the namespaces and their URIs and URLs from a document. -- **[Resolve-XPath.ps1](Resolve-XPath.ps1)**: Returns the XPath of the location of an XML node. -- **[Show-DataRef.ps1](Show-DataRef.ps1)**: Display an HTML view of an XML schema or WSDL using Saxon. -- **[Test-Xml.ps1](Test-Xml.ps1)**: Try parsing text as XML, and validating it if a schema is provided. - -### Other - -- **[Backup-Workstation.ps1](Backup-Workstation.ps1)**: Adds various configuration files and exported settings to a ZIP file. -- **[Connect-SshKey.ps1](Connect-SshKey.ps1)**: Uses OpenSSH to generate a key and connect it to an ssh server. -- :up: **[Export-Readme.ps1](Export-Readme.ps1)**: Generate README.md file for the scripts repo. -- **[Get-ADServiceAccountInfo.ps1](Get-ADServiceAccountInfo.ps1)**: Lists the Global Managed Service Accounts for the domain, including the computers they are bound to. -- **[Get-AspNetEvents.ps1](Get-AspNetEvents.ps1)**: Parses ASP.NET errors from the event log on the given server. -- **[Get-Dns.ps1](Get-Dns.ps1)**: Looks up DNS info, given a hostname or address. -- **[Get-GitHubRepoChildItem.ps1](Get-GitHubRepoChildItem.ps1)**: Gets the items and child items in one or more specified locations. -- **[Get-IisLog.ps1](Get-IisLog.ps1)**: Easily query IIS logs. -- **[Get-PathUsage.ps1](Get-PathUsage.ps1)**: Returns the list of directories in the path, and the commands found in each. -- **[Get-PocketArticles.ps1](Get-PocketArticles.ps1)**: Retrieves a list of saved articles from a Pocket account. -- **[Get-Todos.ps1](Get-Todos.ps1)**: Returns the TODOs for the current git repo, which can help document technical debt. -- **[Measure-Indents.ps1](Measure-Indents.ps1)**: Measures the indentation characters used in a text file. -- **[Measure-StandardDeviation.ps1](Measure-StandardDeviation.ps1)**: Calculate the standard deviation of numeric values. -- **[Measure-TextFile.ps1](Measure-TextFile.ps1)**: Counts each type of indent and line ending. -- **[New-RandomVehicle.ps1](New-RandomVehicle.ps1)**: Generates random vehicle details with a valid VIN. -- **[Optimize-Path.ps1](Optimize-Path.ps1)**: Sorts, prunes, and normalizes both user and system Path entries. -- **[Remove-PocketArticle.ps1](Remove-PocketArticle.ps1)**: Removes an article from a Pocket account. -- **[Repair-AppxPackages.ps1](Repair-AppxPackages.ps1)**: Re-registers all installed Appx packages. -- **[Restore-Workstation.ps1](Restore-Workstation.ps1)**: Restores various configuration files and exported settings from a ZIP file. -- **[Send-MailMessageFile.ps1](Send-MailMessageFile.ps1)**: Sends emails from a drop folder using .NET config defaults. + +### Command + +- **[Hide-Command.ps1](Hide-Command.ps1)**: Make a command unavailable. +- **[Invoke-CommandWithParams.ps1](Invoke-CommandWithParams.ps1)**: Execute a command by using matching dictionary entries as parameters. +- **[Use-Command.ps1](Use-Command.ps1)**: Checks for the existence of the given command, and adds if missing and a source is defined. + +### Configuration + +- **[Get-ConfigConnectionStringBuilders.ps1](Get-ConfigConnectionStringBuilders.ps1)**: Return named connection string builders for connection strings in a config file. +- **[Get-NuGetConfigs.ps1](Get-NuGetConfigs.ps1)**: Returns the available NuGet configuration files, in order of preference. +- **[Use-NetMailConfig.ps1](Use-NetMailConfig.ps1)**: Use .NET configuration to set defaults for Send-MailMessage. + +### Console + +- **[Set-ConsoleColorTheme.ps1](Set-ConsoleColorTheme.ps1)**: Overrides ConsoleClass window color palette entries with a preset color theme. + +### Credential + +- **[Export-SecretVault.ps1](Export-SecretVault.ps1)**: Exports secret vault content. +- **[Get-CachedCredential.ps1](Get-CachedCredential.ps1)**: Return a credential from secure storage, or prompt the user for it if not found. +- **[Get-SecretDetails.ps1](Get-SecretDetails.ps1)**: Returns secret info from the secret vaults, including metadata as properties. +- **[Import-SecretVault.ps1](Import-SecretVault.ps1)**: Imports secrets into secret vaults. +- **[Remove-CachedCredential.ps1](Remove-CachedCredential.ps1)**: Removes a credential from secure storage. +- **[Save-Secret.ps1](Save-Secret.ps1)**: Sets a secret in a secret vault with metadata. + +### Data formats + +- **[New-Jwt.ps1](New-Jwt.ps1)**: Generates a JSON Web Token (JWT) +- **[Test-Jwt.ps1](Test-Jwt.ps1)**: Determines whether a string is a valid JWT. +- **[Test-Windows1252.ps1](Test-Windows1252.ps1)**: Determines whether a file contains Windows-1252 bytes that are invalid UTF-8 bytes. + +### Database + +- :up: **[ConvertFrom-DataRow.ps1](ConvertFrom-DataRow.ps1)**: Converts a DataRow object to a PSObject, Hashtable, or single value. +- **[Export-DatabaseScripts.ps1](Export-DatabaseScripts.ps1)**: Exports MS SQL database objects from the given server and database as files, into a consistent folder structure. +- **[Export-TableMerge.ps1](Export-TableMerge.ps1)**: Exports table data as a T-SQL MERGE statement. +- **[Find-DatabaseValue.ps1](Find-DatabaseValue.ps1)**: Searches an entire database for a field value. +- **[Find-DbColumn.ps1](Find-DbColumn.ps1)**: Searches for database columns. +- **[Find-DbIndexes.ps1](Find-DbIndexes.ps1)**: Returns indexes using a column with the given name. +- **[Initialize-DatabaseNotebook.ps1](Initialize-DatabaseNotebook.ps1)**: Populates a new notebook with details about a database. +- **[Measure-DbColumn.ps1](Measure-DbColumn.ps1)**: Provides statistics about SQL Server column data. +- **[Measure-DbColumnValues.ps1](Measure-DbColumnValues.ps1)**: Provides sorted counts of SQL Server column values. +- **[Measure-DbTable.ps1](Measure-DbTable.ps1)**: Provides frequency details about SQL Server table data. +- **[New-DbProviderObject.ps1](New-DbProviderObject.ps1)**: Create a common database object. +- **[Repair-DatabaseConstraintNames.ps1](Repair-DatabaseConstraintNames.ps1)**: Finds database constraints with system-generated names and gives them deterministic names. +- **[Repair-DatabaseUntrustedConstraints.ps1](Repair-DatabaseUntrustedConstraints.ps1)**: Finds database constraints that have been incompletely re-enabled. +- **[Send-SqlReport.ps1](Send-SqlReport.ps1)**: Execute a SQL statement and email the results. +- **[Test-ConnectionString.ps1](Test-ConnectionString.ps1)**: Test a given connection string and provide details about the connection. +- **[Use-SqlcmdParams.ps1](Use-SqlcmdParams.ps1)**: Use the calling script parameters to set Invoke-Sqlcmd defaults. + +### Date and time + +- **[ConvertTo-LogParserTimestamp.ps1](ConvertTo-LogParserTimestamp.ps1)**: Formats a datetime as a LogParser literal. + +### DotNet + +- **[Find-DotNetTools.ps1](Find-DotNetTools.ps1)**: Returns a list of matching dotnet tools. +- **[Get-AssemblyFramework.ps1](Get-AssemblyFramework.ps1)**: Gets the framework version an assembly was compiled for. +- **[Get-DotNetFrameworkVersions.ps1](Get-DotNetFrameworkVersions.ps1)**: Determine which .NET Frameworks are installed on the requested system. +- **[Get-DotNetGlobalTools.ps1](Get-DotNetGlobalTools.ps1)**: Returns a list of global dotnet tools. +- **[Get-DotNetVersions.ps1](Get-DotNetVersions.ps1)**: Determine which .NET Core & Framework versions are installed. +- **[Update-DotNetPackages.ps1](Update-DotNetPackages.ps1)**: Updates NuGet packages for a .NET solution or project. + +### EnvironmentVariables + +- **[Compress-EnvironmentVariables.ps1](Compress-EnvironmentVariables.ps1)**: Replaces each of the longest matching parts of a string with an embedded environment variable with that value. + +### Files + +- **[Backup-File.ps1](Backup-File.ps1)**: Create a backup as a sibling to a file, with date and time values in the name. +- **[Join-FileName.ps1](Join-FileName.ps1)**: Combines a filename with a string. +- **[Measure-Caches.ps1](Measure-Caches.ps1)**: Returns a list of matching cache directories, and their sizes, sorted. +- **[New-Shortcut.ps1](New-Shortcut.ps1)**: Create a Windows shortcut. +- **[Remove-LockyFile.ps1](Remove-LockyFile.ps1)**: Removes a file that may be prone to locking. +- **[Test-LockedFile.ps1](Test-LockedFile.ps1)**: Returns true if the specified file is locked. + +### Git and GitHub + +- **[Add-GitHubMetadata.ps1](Add-GitHubMetadata.ps1)**: Adds GitHub Linguist overrides to a repo's .gitattributes. +- **[Copy-GitHubLabels.ps1](Copy-GitHubLabels.ps1)**: Copies configured issue labels from one repo to another. +- **[Get-GitFileMetadata.ps1](Get-GitFileMetadata.ps1)**: Returns the creation and last modification metadata for a file in a git repo. +- **[Get-GitFirstCommit.ps1](Get-GitFirstCommit.ps1)**: Gets the SHA-1 hash of the first commit of the current repo. +- **[Get-RepoName.ps1](Get-RepoName.ps1)**: Gets the name of the repo. +- **[Rename-GitHubLocalBranch.ps1](Rename-GitHubLocalBranch.ps1)**: Rename a git repository branch. +- **[Trace-GitRepoTest.ps1](Trace-GitRepoTest.ps1)**: Uses git bisect to search for the point in the repo history that the test script starts returning true. + +### HTTP + +- **[ConvertTo-BasicAuthentication.ps1](ConvertTo-BasicAuthentication.ps1)**: Produces a basic authentication header string from a credential. +- **[ConvertTo-MultipartFormData.ps1](ConvertTo-MultipartFormData.ps1)**: Creates multipart/form-data to send as a request body. +- **[Get-ContentSecurityPolicy.ps1](Get-ContentSecurityPolicy.ps1)**: Returns the content security policy at from the given URL. +- **[Get-SslDetails.ps1](Get-SslDetails.ps1)**: Enumerates the SSL protocols that the client is able to successfully use to connect to a server. +- :up: **[Save-WebRequest.ps1](Save-WebRequest.ps1)**: Downloads a given URL to a file, automatically determining the filename. +- **[Show-HttpStatus.ps1](Show-HttpStatus.ps1)**: Displays the HTTP status code info. +- :up: **[Trace-WebRequest.ps1](Trace-WebRequest.ps1)**: Provides details about a retrieving a URI. + +### Json + +- **[Export-Json.ps1](Export-Json.ps1)**: Exports a portion of a JSON document, recursively importing references. +- :up: **[Export-OpenApiSchema.ps1](Export-OpenApiSchema.ps1)**: Extracts a JSON schema from an OpenAPI definition. +- **[Get-OpenApiInfo.ps1](Get-OpenApiInfo.ps1)**: Returns metadata from an OpenAPI definition. +- **[Merge-Json.ps1](Merge-Json.ps1)**: Create a new JSON string by recursively combining the properties of JSON strings. +- **[Resolve-JsonPointer.ps1](Resolve-JsonPointer.ps1)**: Returns matching JSON Pointer paths, given a JSON Pointer path with wildcards. +- **[Select-Json.ps1](Select-Json.ps1)**: Returns a value from a JSON string or file. +- **[Set-Json.ps1](Set-Json.ps1)**: Sets a property in a JSON string or file. +- :up: **[Show-OpenApiInfo.ps1](Show-OpenApiInfo.ps1)**: Displays metadata from an OpenAPI definition. + +### Mermaid Diagrams + +- **[Export-MermaidER.ps1](Export-MermaidER.ps1)**: Generates a Mermaid entity relation diagram for database tables. + +### Notebooks + +- **[Add-NotebookCell.ps1](Add-NotebookCell.ps1)**: When run within a Polyglot Notebook, appends a cell to it. + +### Packages and libraries + +- **[Find-ProjectPackages.ps1](Find-ProjectPackages.ps1)**: Find modules used in projects. +- **[Get-LibraryVulnerabilityInfo.ps1](Get-LibraryVulnerabilityInfo.ps1)**: Get the list of module/package/library vulnerabilities from the RetireJS or SafeNuGet projects. + +### PowerShell + +- **[Add-ScopeLevel.ps1](Add-ScopeLevel.ps1)**: Convert a scope level to account for another call stack level. +- :new: **[Convert-ExternalScriptToModule.ps1](Convert-ExternalScriptToModule.ps1)**: Convert a script from external script usage to module cmdlet usage. + +### Scheduled Tasks + +- **[Backup-SchTasks.ps1](Backup-SchTasks.ps1)**: Exports the local list of Scheduled Tasks into a single XML file. +- :up: **[ConvertFrom-CimInstance.ps1](ConvertFrom-CimInstance.ps1)**: Convert a CimInstance object to a PSObject. +- **[ConvertTo-ICalendar.ps1](ConvertTo-ICalendar.ps1)**: Converts supported objects (Scheduled Tasks) to the RFC 5545 iCalendar format. +- **[Copy-SchTasks.ps1](Copy-SchTasks.ps1)**: Copy scheduled jobs from another computer to this one, using a GUI list to choose jobs. +- **[Get-SimpleSchTasks.ps1](Get-SimpleSchTasks.ps1)**: Returns simple scheduled task info. +- **[Restore-SchTasks.ps1](Restore-SchTasks.ps1)**: Imports from a single XML file into the local Scheduled Tasks. +- **[Set-SchTaskMsa.ps1](Set-SchTaskMsa.ps1)**: Sets a Scheduled Task's runtime user as the given gMSA/MSA. + +### Scripts + +- **[New-PesterTests.ps1](New-PesterTests.ps1)**: Creates a new Pester testing script from a script's examples and parameter sets. +- **[New-Script.ps1](New-Script.ps1)**: Creates a simple boilerplate script. +- **[Optimize-Help.ps1](Optimize-Help.ps1)**: Cleans up comment-based help blocks by fully unindenting and capitalizing dot keywords. +- **[Rename-Script.ps1](Rename-Script.ps1)**: Renames all instances of a script, and updates any usage of it. +- **[Repair-ScriptStyle.ps1](Repair-ScriptStyle.ps1)**: Accepts justifications for script analysis rule violations, fixing the rest using Invoke-ScriptAnalysis. + +### Search and replace + +- **[Find-Lines.ps1](Find-Lines.ps1)**: Searches a specific subset of files for lines matching a pattern. + +### Seq + +- **[Send-SeqEvent.ps1](Send-SeqEvent.ps1)**: Send an event to a Seq server. +- **[Send-SeqScriptEvent.ps1](Send-SeqScriptEvent.ps1)**: Sends an event (often an error) from a script to a Seq server, including script info. +- **[Use-SeqServer.ps1](Use-SeqServer.ps1)**: Set the default Server and ApiKey for Send-SeqEvent.ps1 + +### System and updates + +- **[Convert-ChocolateyToWinget.ps1](Convert-ChocolateyToWinget.ps1)**: Change from managing various packages with Chocolatey to WinGet. +- **[Export-EdgeKeywords.ps1](Export-EdgeKeywords.ps1)**: Returns the configured search keywords from an Edge SQLite file. +- **[Export-InstalledPackages.ps1](Export-InstalledPackages.ps1)**: Exports the list of packages installed by various tools. +- **[Find-InstalledPrograms.ps1](Find-InstalledPrograms.ps1)**: Searches installed programs. +- **[Get-SystemDetails.ps1](Get-SystemDetails.ps1)**: Collects some useful system hardware and operating system details via CIM. +- **[Import-EdgeKeywords.ps1](Import-EdgeKeywords.ps1)**: Adds search keywords to an Edge SQLite profile configuration. +- **[Read-ChocolateySummary.ps1](Read-ChocolateySummary.ps1)**: Retrieves the a summary from the Chocolatey log. +- **[Update-Everything.ps1](Update-Everything.ps1)**: Updates everything it can on the system. +- **[Use-Java.ps1](Use-Java.ps1)**: Switch the Java version for the current process by modifying environment variables. + +### TLS/SSL + +- **[Get-ServerCertificate.ps1](Get-ServerCertificate.ps1)**: Returns the certificate provided by the requested server. + +### Unicode + +- **[Get-CharacterDetails.ps1](Get-CharacterDetails.ps1)**: Returns filterable categorical information about characters in the Unicode Basic Multilingual Plane. +- **[Get-Unicode.ps1](Get-Unicode.ps1)**: Returns the (UTF-16) .NET string for a given Unicode codepoint, which may be a surrogate pair. +- **[Get-UnicodeByName.ps1](Get-UnicodeByName.ps1)**: Returns characters based on Unicode code point name, GitHub short code, or HTML entity. +- **[Get-UnicodeData.ps1](Get-UnicodeData.ps1)**: Returns the current (cached) Unicode character data. +- **[Get-UnicodeName.ps1](Get-UnicodeName.ps1)**: Returns the name of a Unicode code point. +- **[Import-CharConstants.ps1](Import-CharConstants.ps1)**: Imports characters by name as constants into the current scope. + +### VSCode + +- **[Add-VsCodeDatabaseConnection.ps1](Add-VsCodeDatabaseConnection.ps1)**: Adds a VS Code MSSQL database connection to the repo. +- **[Get-VSCCurrentFile.ps1](Get-VSCCurrentFile.ps1)**: Returns the path of the current file open in VSCode, when run in the PowerShell Extension Terminal in VSCode. +- **[Get-VSCodeSetting.ps1](Get-VSCodeSetting.ps1)**: Sets a VSCode setting. +- **[Get-VSCodeSettingsFile.ps1](Get-VSCodeSettingsFile.ps1)**: Gets the path of the VSCode settings.config file. +- **[Import-VsCodeDatabaseConnections.ps1](Import-VsCodeDatabaseConnections.ps1)**: Adds config XDT connection strings to VSCode settings. +- **[Push-WorkspaceLocation.ps1](Push-WorkspaceLocation.ps1)**: Pushes the current VS Code editor workspace location to the location stack. +- **[Set-VSCodeSetting.ps1](Set-VSCodeSetting.ps1)**: Sets a VSCode setting. + +### Windows Terminal + +- **[Set-TerminalProfile.ps1](Set-TerminalProfile.ps1)**: Adds or updates a Windows Terminal command profile. +- **[Test-WindowsTerminal.ps1](Test-WindowsTerminal.ps1)**: Returns true if PowerShell is running within Windows Terminal. + +### XML + +- **[Compare-Xml.ps1](Compare-Xml.ps1)**: Compares two XML documents and returns the differences. +- **[Convert-Xml.ps1](Convert-Xml.ps1)**: Transform XML using an XSLT template. +- **[ConvertFrom-EscapedXml.ps1](ConvertFrom-EscapedXml.ps1)**: Parse escaped XML into XML and serialize it. +- **[ConvertFrom-XmlElement.ps1](ConvertFrom-XmlElement.ps1)**: Converts named nodes of an element to properties of a PSObject, recursively. +- **[ConvertTo-XmlElements.ps1](ConvertTo-XmlElements.ps1)**: Serializes complex content into XML elements. +- **[Format-Xml.ps1](Format-Xml.ps1)**: Pretty-print XML. +- **[Get-XmlNamespaces.ps1](Get-XmlNamespaces.ps1)**: Gets the namespaces from a document as a dictionary. +- **[Merge-XmlSelections.ps1](Merge-XmlSelections.ps1)**: Builds an object using the named XPath selections as properties. +- **[New-NamespaceManager.ps1](New-NamespaceManager.ps1)**: Creates an object to lookup XML namespace prefixes. +- **[Resolve-XmlSchemaLocation.ps1](Resolve-XmlSchemaLocation.ps1)**: Gets the namespaces and their URIs and URLs from a document. +- **[Resolve-XPath.ps1](Resolve-XPath.ps1)**: Returns the XPath of the location of an XML node. +- **[Show-DataRef.ps1](Show-DataRef.ps1)**: Display an HTML view of an XML schema or WSDL using Saxon. +- **[Test-Xml.ps1](Test-Xml.ps1)**: Try parsing text as XML, and validating it if a schema is provided. + +### Other + +- **[Backup-Workstation.ps1](Backup-Workstation.ps1)**: Adds various configuration files and exported settings to a ZIP file. +- **[Connect-SshKey.ps1](Connect-SshKey.ps1)**: Uses OpenSSH to generate a key and connect it to an ssh server. +- :up: **[Export-Readme.ps1](Export-Readme.ps1)**: Generate README.md file for the scripts repo. +- **[Get-ADServiceAccountInfo.ps1](Get-ADServiceAccountInfo.ps1)**: Lists the Global Managed Service Accounts for the domain, including the computers they are bound to. +- **[Get-AspNetEvents.ps1](Get-AspNetEvents.ps1)**: Parses ASP.NET errors from the event log on the given server. +- **[Get-Dns.ps1](Get-Dns.ps1)**: Looks up DNS info, given a hostname or address. +- **[Get-GitHubRepoChildItem.ps1](Get-GitHubRepoChildItem.ps1)**: Gets the items and child items in one or more specified locations. +- **[Get-IisLog.ps1](Get-IisLog.ps1)**: Easily query IIS logs. +- **[Get-PathUsage.ps1](Get-PathUsage.ps1)**: Returns the list of directories in the path, and the commands found in each. +- **[Get-PocketArticles.ps1](Get-PocketArticles.ps1)**: Retrieves a list of saved articles from a Pocket account. +- **[Get-Todos.ps1](Get-Todos.ps1)**: Returns the TODOs for the current git repo, which can help document technical debt. +- **[Measure-Indents.ps1](Measure-Indents.ps1)**: Measures the indentation characters used in a text file. +- **[Measure-StandardDeviation.ps1](Measure-StandardDeviation.ps1)**: Calculate the standard deviation of numeric values. +- **[Measure-TextFile.ps1](Measure-TextFile.ps1)**: Counts each type of indent and line ending. +- **[New-RandomVehicle.ps1](New-RandomVehicle.ps1)**: Generates random vehicle details with a valid VIN. +- **[Optimize-Path.ps1](Optimize-Path.ps1)**: Sorts, prunes, and normalizes both user and system Path entries. +- **[Remove-PocketArticle.ps1](Remove-PocketArticle.ps1)**: Removes an article from a Pocket account. +- **[Repair-AppxPackages.ps1](Repair-AppxPackages.ps1)**: Re-registers all installed Appx packages. +- **[Restore-Workstation.ps1](Restore-Workstation.ps1)**: Restores various configuration files and exported settings from a ZIP file. +- :up: **[Save-PodcastEpisodes.ps1](Save-PodcastEpisodes.ps1)**: Downloads enclosures from a podcast feed. +- **[Send-MailMessageFile.ps1](Send-MailMessageFile.ps1)**: Sends emails from a drop folder using .NET config defaults. - **[Test-HttpSecurity.ps1](Test-HttpSecurity.ps1)**: Scan sites using Mozilla's Observatory. F# Scripts ---------- -- **[NCrontab Schedule Test](https://webcoder.info/scripts/Test-NCrontab.html)**: Returns a sampling of the next several date & times scheduled by an NCrontab string. -- **[Parse Unicode data](https://webcoder.info/scripts/UnicodeData.html)**: Experiment with CSV type provider to read Unicode data. +- **[NCrontab Schedule Test](https://webcoder.info/scripts/Test-NCrontab.html)**: Returns a sampling of the next several date & times scheduled by an NCrontab string. +- **[Parse Unicode data](https://webcoder.info/scripts/UnicodeData.html)**: Experiment with CSV type provider to read Unicode data. - **[US Federal Holiday Detection](https://webcoder.info/scripts/USFederalHolidays.html)**: Here's how to determine whether a date is a US federal holiday using F#. Office VBA Scripts ------------------ -- **[OutlookExpireTag.vba](OutlookExpireTag.vba)**: Too many emails remain beyond their period of relevance: daily personnel schedule changes, found item notices, office food notices, server reboot notices, weather/traffic warnings, &c. This Outlook script will allow specifying an expiration date as a hashtag in the subject of outgoing emails, since Outlook does such a good job of hiding the UI for that field. -BL -- **[OutlookPasteFormattedIndented.vba](OutlookPasteFormattedIndented.vba)**: Outlook will strip single-space indents when displaying emails. If you've got, for example, syntax highlighted source code that employs any indentation of only one space, you'll want to add two spaces to the each line (adding one will not appear for text that isn't indented). This Outlook script will paste formatted text, and indent it. Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work) -- **[OutlookPasteTsvTable.vba](OutlookPasteTsvTable.vba)**: This Outlook VBA Sub can be connected to a toolbar button for pasting TSV data as an attractive, formatted table. -BL Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work) +- **[OutlookExpireTag.vba](OutlookExpireTag.vba)**: Too many emails remain beyond their period of relevance: daily personnel schedule changes, found item notices, office food notices, server reboot notices, weather/traffic warnings, &c. This Outlook script will allow specifying an expiration date as a hashtag in the subject of outgoing emails, since Outlook does such a good job of hiding the UI for that field. -BL +- **[OutlookPasteFormattedIndented.vba](OutlookPasteFormattedIndented.vba)**: Outlook will strip single-space indents when displaying emails. If you've got, for example, syntax highlighted source code that employs any indentation of only one space, you'll want to add two spaces to the each line (adding one will not appear for text that isn't indented). This Outlook script will paste formatted text, and indent it. Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work) +- **[OutlookPasteTsvTable.vba](OutlookPasteTsvTable.vba)**: This Outlook VBA Sub can be connected to a toolbar button for pasting TSV data as an attractive, formatted table. -BL Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work) - + diff --git a/docs/Convert-ExternalScriptToModule.ps1.md b/docs/Convert-ExternalScriptToModule.ps1.md new file mode 100644 index 00000000..a97c161f --- /dev/null +++ b/docs/Convert-ExternalScriptToModule.ps1.md @@ -0,0 +1,89 @@ +--- +external help file: -help.xml +Module Name: +online version: +schema: 2.0.0 +--- + +# Convert-ExternalScriptToModule.ps1 + +## SYNOPSIS +Convert a script from external script usage to module cmdlet usage. + +## SYNTAX + +``` +Convert-ExternalScriptToModule.ps1 [[-ModuleName] ] [[-Path] ] + [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -ModuleName +The module to use instead of external scripts. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: ModernConveniences +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Path +The script to update to module usage. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: FullName + +Required: False +Position: 2 +Default value: *.ps1 +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String containing the path of the script to update. +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/docs/ConvertFrom-CimInstance.ps1.md b/docs/ConvertFrom-CimInstance.ps1.md new file mode 100644 index 00000000..ff0567ae --- /dev/null +++ b/docs/ConvertFrom-CimInstance.ps1.md @@ -0,0 +1,75 @@ +--- +external help file: -help.xml +Module Name: +online version: +schema: 2.0.0 +--- + +# ConvertFrom-CimInstance.ps1 + +## SYNOPSIS +Convert a CimInstance object to a PSObject. + +## SYNTAX + +``` +ConvertFrom-CimInstance.ps1 [[-InputObject] ] [-ProgressAction ] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### EXAMPLE 1 +``` +$tasks = Get-ScheduledTask |ConvertFrom-CimInstance +``` + +Gets the scheduled tasks as PSObjects that support tab completion and can be serialized and exported. + +## PARAMETERS + +### -InputObject +The CimInstance object to convert to a PSObject. + +```yaml +Type: CimInstance +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Management.Infrastructure.CimInstance to convert to a PSObject. +## OUTPUTS + +### PSObject converted from the CimInstance entered. +## NOTES + +## RELATED LINKS diff --git a/docs/ConvertFrom-DataRow.ps1.md b/docs/ConvertFrom-DataRow.ps1.md new file mode 100644 index 00000000..6af40cc2 --- /dev/null +++ b/docs/ConvertFrom-DataRow.ps1.md @@ -0,0 +1,119 @@ +--- +external help file: -help.xml +Module Name: +online version: +schema: 2.0.0 +--- + +# ConvertFrom-DataRow.ps1 + +## SYNOPSIS +Converts a DataRow object to a PSObject, Hashtable, or single value. + +## SYNTAX + +### AsObject (Default) +``` +ConvertFrom-DataRow.ps1 [-DataRow] [-ProgressAction ] [] +``` + +### AsValues +``` +ConvertFrom-DataRow.ps1 [-DataRow] [-AsValues] [-ProgressAction ] + [] +``` + +### AsDictionary +``` +ConvertFrom-DataRow.ps1 [-DataRow] [-AsDictionary] [-ProgressAction ] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### EXAMPLE 1 +``` +Invoke-Sqlcmd "select top 3 ProductID, Name from Production.Product" -ServerInstance ServerName -Database AdventureWorks |ConvertFrom-DataRow.ps1 |ConvertTo-Html +``` + +## PARAMETERS + +### -DataRow +A record containing fields/columns to convert to an object with properties. + +```yaml +Type: DataRow +Parameter Sets: (All) +Aliases: + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -AsValues +Indicates a the record's values should be returned as an array. + +```yaml +Type: SwitchParameter +Parameter Sets: AsValues +Aliases: AsArray + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AsDictionary +Indicates an ordered dictionary of fieldnames/columnnames to values should be returned +rather than an object with properties. + +```yaml +Type: SwitchParameter +Parameter Sets: AsDictionary +Aliases: AsOrderedDictionary, AsHashtable + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.Data.DataRow with fields to convert into an object with properties or +### into a hash with key/value pairs. +## OUTPUTS + +### System.Management.Automation.PSObject +### or System.Object[] if -AsValues is specified +### or System.Collections.Specialized.OrderedDictionary if -AsDictionary is specified +## NOTES + +## RELATED LINKS diff --git a/docs/Export-OpenApiSchema.ps1.md b/docs/Export-OpenApiSchema.ps1.md new file mode 100644 index 00000000..0cd74f56 --- /dev/null +++ b/docs/Export-OpenApiSchema.ps1.md @@ -0,0 +1,155 @@ +--- +external help file: -help.xml +Module Name: +online version: https://www.openapis.org/ +schema: 2.0.0 +--- + +# Export-OpenApiSchema.ps1 + +## SYNOPSIS +Extracts a JSON schema from an OpenAPI definition. + +## SYNTAX + +### ResponseStatus (Default) +``` +Export-OpenApiSchema.ps1 [[-Path] ] [[-Method] ] [[-EndpointPath] ] + [[-ResponseStatus] ] [-ProgressAction ] [] +``` + +### RequestSchema +``` +Export-OpenApiSchema.ps1 [[-Path] ] [[-Method] ] [[-EndpointPath] ] [-RequestSchema] + [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### EXAMPLE 1 +``` +Export-OpenApiSchema api.json +``` + +Returns the schema of the 200 response of any defined endpoint is returned. + +### EXAMPLE 2 +``` +Export-OpenApiSchema api.json POST /hello -RequestSchema +``` + +Returns the schema of the request body of the POST /hello endpoint. + +## PARAMETERS + +### -Path +The path to the OpenAPI JSON file. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 1 +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Method +The HTTP verb of the endpoint to extract the schema from. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: 2 +Default value: * +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -EndpointPath +The HTTP path of the endpoint to extract the schema from. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: ApiPath + +Required: False +Position: 3 +Default value: * +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RequestSchema +Indicates that the request schema of the endpoint should be returned. + +```yaml +Type: SwitchParameter +Parameter Sets: RequestSchema +Aliases: In + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResponseStatus +Indicates the HTTP status code of the response schema of the endpoint that should be returned. + +```yaml +Type: Int32 +Parameter Sets: ResponseStatus +Aliases: + +Required: False +Position: 4 +Default value: 200 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +### System.String of the extracted JSON schema. +## NOTES + +## RELATED LINKS + +[https://www.openapis.org/](https://www.openapis.org/) + +[Export-Json]() + +[Set-Json]() + diff --git a/docs/Save-PodcastEpisodes.ps1.md b/docs/Save-PodcastEpisodes.ps1.md new file mode 100644 index 00000000..d813784a --- /dev/null +++ b/docs/Save-PodcastEpisodes.ps1.md @@ -0,0 +1,166 @@ +--- +external help file: -help.xml +Module Name: +online version: +schema: 2.0.0 +--- + +# Save-PodcastEpisodes.ps1 + +## SYNOPSIS +Downloads enclosures from a podcast feed. + +## SYNTAX + +``` +Save-PodcastEpisodes.ps1 [-Uri] [-After ] [-Before ] [-First ] [-Last ] + [-UseTitle] [-CreateFolder] [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### EXAMPLE 1 +``` +Save-PodcastEpisodes.ps1 https://www.youlooknicetoday.com/rss -UseTitle +``` + +Downloads podcast episodes to the current directory. + +## PARAMETERS + +### -Uri +The URL of the podcast feed. + +```yaml +Type: Uri +Parameter Sets: (All) +Aliases: Url + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -After +Episodes before this date will be ignored. + +```yaml +Type: DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Before +Episodes after this date will be ignored. + +```yaml +Type: DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -First +Includes only the given number of initial episodes, by publish date. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Last +Includes only the given number of most recent episodes, by publish date. + +```yaml +Type: Int32 +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: 0 +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UseTitle +Use episode titles for filenames. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -CreateFolder +Downloads the episodes into a folder with the podcast name. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[Save-WebRequest.ps1]() + diff --git a/docs/Save-WebRequest.ps1.md b/docs/Save-WebRequest.ps1.md new file mode 100644 index 00000000..09697fe5 --- /dev/null +++ b/docs/Save-WebRequest.ps1.md @@ -0,0 +1,150 @@ +--- +external help file: -help.xml +Module Name: +online version: https://tools.ietf.org/html/rfc2183 +schema: 2.0.0 +--- + +# Save-WebRequest.ps1 + +## SYNOPSIS +Downloads a given URL to a file, automatically determining the filename. + +## SYNTAX + +``` +Save-WebRequest.ps1 [-Uri] [-OutDirectory ] [-CreationTime ] + [-LastWriteTime ] [-Open] [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### EXAMPLE 1 +``` +Save-WebRequest.ps1 https://www.irs.gov/pub/irs-pdf/f1040.pdf -Open +``` + +Saves f1040.pdf (or else a filename specified in the Content-Disposition header) and opens it. + +## PARAMETERS + +### -Uri +The URL to download. + +```yaml +Type: Uri +Parameter Sets: (All) +Aliases: Url, Href, Src + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -OutDirectory +The directory to save the file into. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -CreationTime +Sets the creation time on the file to the given value. + +```yaml +Type: DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -LastWriteTime +Sets the creation time on the file to the given value. + +```yaml +Type: DateTime +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Open +When present, invokes the file after it is downloaded. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Object with System.Uri property named Uri. +## OUTPUTS + +### System.Void +## NOTES + +## RELATED LINKS + +[https://tools.ietf.org/html/rfc2183](https://tools.ietf.org/html/rfc2183) + +[http://test.greenbytes.de/tech/tc2231/](http://test.greenbytes.de/tech/tc2231/) + +[https://msdn.microsoft.com/library/system.net.mime.contentdisposition.filename.aspx](https://msdn.microsoft.com/library/system.net.mime.contentdisposition.filename.aspx) + +[https://msdn.microsoft.com/library/system.io.path.getinvalidfilenamechars.aspx](https://msdn.microsoft.com/library/system.io.path.getinvalidfilenamechars.aspx) + +[Invoke-WebRequest]() + +[Invoke-Item]() + +[Move-Item]() + diff --git a/docs/Show-OpenApiInfo.ps1.md b/docs/Show-OpenApiInfo.ps1.md new file mode 100644 index 00000000..b35cdcf1 --- /dev/null +++ b/docs/Show-OpenApiInfo.ps1.md @@ -0,0 +1,80 @@ +--- +external help file: -help.xml +Module Name: +online version: https://www.openapis.org/ +schema: 2.0.0 +--- + +# Show-OpenApiInfo.ps1 + +## SYNOPSIS +Displays metadata from an OpenAPI definition. + +## SYNTAX + +``` +Show-OpenApiInfo.ps1 [-Path] [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### EXAMPLE 1 +``` +Show-OpenApiInfo .\test\data\sample-openapi.json +``` + +Sample REST API v1.0.0 An example OpenAPI definition. +.\test\data\sample-openapi.json openapi v3.0.3 +GET /users/{userId} Returns a user by ID. +Gets a user's details. +POST /users Creates a new user. +Adds a user account. + +## PARAMETERS + +### -Path +{{ Fill Path Description }} + +```yaml +Type: String +Parameter Sets: (All) +Aliases: FullName + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +## OUTPUTS + +## NOTES + +## RELATED LINKS + +[https://www.openapis.org/](https://www.openapis.org/) + diff --git a/docs/Trace-WebRequest.ps1.md b/docs/Trace-WebRequest.ps1.md new file mode 100644 index 00000000..e4e95070 --- /dev/null +++ b/docs/Trace-WebRequest.ps1.md @@ -0,0 +1,156 @@ +--- +external help file: -help.xml +Module Name: +online version: +schema: 2.0.0 +--- + +# Trace-WebRequest.ps1 + +## SYNOPSIS +Provides details about a retrieving a URI. + +## SYNTAX + +``` +Trace-WebRequest.ps1 [-Uri] [-Method ] [-LogFile ] [-SkipHeaders] [-SkipContent] + [-ProgressAction ] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### EXAMPLE 1 +``` +Trace-WebRequest.ps1 g.co/p3phelp -SkipHeaders -SkipContent +``` + +g.co is CN=*.google.com from CN=WR2, O=Google Trust Services, C=US +Valid 05/12/2025 01:42:58 to 08/04/2025 01:42:57 +GET https://g.co/p3phelp +HTTP/1.1 302 Found +Following redirect to https://support.google.com/accounts/answer/151657?hl=en +support.google.com is CN=*.google.com from CN=WR2, O=Google Trust Services, C=US +Valid 05/12/2025 01:42:58 to 08/04/2025 01:42:57 +GET https://support.google.com/accounts/answer/151657?hl=en +HTTP/1.1 301 MovedPermanently +Following redirect to https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638845176026805186-2907418293&rd=1 +GET https://support.google.com/accounts/topic/3382252?hl=en&visit_id=638845176026805186-2907418293&rd=1 +HTTP/1.1 301 MovedPermanently +Following redirect to https://support.google.com/accounts/?hl=en&visit_id=638845176026805186-2907418293&rd=2&topic=3382252 +GET https://support.google.com/accounts/?hl=en&visit_id=638845176026805186-2907418293&rd=2&topic=3382252 +HTTP/1.1 200 OK + +## PARAMETERS + +### -Uri +The URL to retrieve. + +```yaml +Type: Uri +Parameter Sets: (All) +Aliases: Url, Href, Src + +Required: True +Position: 1 +Default value: None +Accept pipeline input: True (ByPropertyName, ByValue) +Accept wildcard characters: False +``` + +### -Method +The HTTP method verb to use. + +```yaml +Type: HttpMethod +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: GET +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -LogFile +A file to log the request to. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SkipHeaders +Indicates headers shouldn't be output. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -SkipContent +Indicates content shouldn't be output. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: False +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ProgressAction +{{ Fill ProgressAction Description }} + +```yaml +Type: ActionPreference +Parameter Sets: (All) +Aliases: proga + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.Uri to retrieve. +## OUTPUTS + +## NOTES +TODO: Add support for other Invoke-WebRequest parameters. + +## RELATED LINKS + +[Import-CharConstants.ps1]() + +[Write-Info.ps1]() + +[Import-Variables.ps1]() + diff --git a/docs/index.md b/docs/index.md index 43f5b492..83df71f6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@ [![Pester tests status](https://github.com/brianary/scripts/actions/workflows/pester.yml/badge.svg)][pester.yml] [![Pester tests results](https://gist.githubusercontent.com/brianary/4642e5c804aa1b40738def5a7c03607a/raw/badge.svg)][pester.yml] -[![Pester tests coverage](https://img.shields.io/badge/Pester_coverage-3471_%E2%80%B1-orange +[![Pester tests coverage](https://img.shields.io/badge/Pester_coverage-3426_%E2%80%B1-orange red)](https://github.com/brianary/scripts/tree/main/test) [![GitHub license badge](https://badgen.net/github/license/brianary/Scripts?icon=github)](https://mit-license.org/ "MIT License") [![GitHub stars badge](https://badgen.net/github/stars/brianary/Scripts?icon=github)](https://github.com/brianary/scripts/stargazers "Stars") @@ -52,6 +52,7 @@ Scripts from the [Scripts](https://github.com/brianary/Scripts/) repo. ### Database +- 🆙 **[ConvertFrom-DataRow.ps1](ConvertFrom-DataRow.ps1.md)**: Converts a DataRow object to a PSObject, Hashtable, or single value. - **[Export-DatabaseScripts.ps1](Export-DatabaseScripts.ps1.md)**: Exports MS SQL database objects from the given server and database as files, into a consistent folder structure. - **[Export-TableMerge.ps1](Export-TableMerge.ps1.md)**: Exports table data as a T-SQL MERGE statement. - **[Find-DatabaseValue.ps1](Find-DatabaseValue.ps1.md)**: Searches an entire database for a field value. @@ -110,16 +111,20 @@ Scripts from the [Scripts](https://github.com/brianary/Scripts/) repo. - **[ConvertTo-MultipartFormData.ps1](ConvertTo-MultipartFormData.ps1.md)**: Creates multipart/form-data to send as a request body. - **[Get-ContentSecurityPolicy.ps1](Get-ContentSecurityPolicy.ps1.md)**: Returns the content security policy at from the given URL. - **[Get-SslDetails.ps1](Get-SslDetails.ps1.md)**: Enumerates the SSL protocols that the client is able to successfully use to connect to a server. +- 🆙 **[Save-WebRequest.ps1](Save-WebRequest.ps1.md)**: Downloads a given URL to a file, automatically determining the filename. - **[Show-HttpStatus.ps1](Show-HttpStatus.ps1.md)**: Displays the HTTP status code info. +- 🆙 **[Trace-WebRequest.ps1](Trace-WebRequest.ps1.md)**: Provides details about a retrieving a URI. ### Json - **[Export-Json.ps1](Export-Json.ps1.md)**: Exports a portion of a JSON document, recursively importing references. +- 🆙 **[Export-OpenApiSchema.ps1](Export-OpenApiSchema.ps1.md)**: Extracts a JSON schema from an OpenAPI definition. - **[Get-OpenApiInfo.ps1](Get-OpenApiInfo.ps1.md)**: Returns metadata from an OpenAPI definition. - **[Merge-Json.ps1](Merge-Json.ps1.md)**: Create a new JSON string by recursively combining the properties of JSON strings. - **[Resolve-JsonPointer.ps1](Resolve-JsonPointer.ps1.md)**: Returns matching JSON Pointer paths, given a JSON Pointer path with wildcards. - **[Select-Json.ps1](Select-Json.ps1.md)**: Returns a value from a JSON string or file. - **[Set-Json.ps1](Set-Json.ps1.md)**: Sets a property in a JSON string or file. +- 🆙 **[Show-OpenApiInfo.ps1](Show-OpenApiInfo.ps1.md)**: Displays metadata from an OpenAPI definition. ### Mermaid Diagrams @@ -137,10 +142,12 @@ Scripts from the [Scripts](https://github.com/brianary/Scripts/) repo. ### PowerShell - **[Add-ScopeLevel.ps1](Add-ScopeLevel.ps1.md)**: Convert a scope level to account for another call stack level. +- 🆕 **[Convert-ExternalScriptToModule.ps1](Convert-ExternalScriptToModule.ps1.md)**: Convert a script from external script usage to module cmdlet usage. ### Scheduled Tasks - **[Backup-SchTasks.ps1](Backup-SchTasks.ps1.md)**: Exports the local list of Scheduled Tasks into a single XML file. +- 🆙 **[ConvertFrom-CimInstance.ps1](ConvertFrom-CimInstance.ps1.md)**: Convert a CimInstance object to a PSObject. - **[ConvertTo-ICalendar.ps1](ConvertTo-ICalendar.ps1.md)**: Converts supported objects (Scheduled Tasks) to the RFC 5545 iCalendar format. - **[Copy-SchTasks.ps1](Copy-SchTasks.ps1.md)**: Copy scheduled jobs from another computer to this one, using a GUI list to choose jobs. - **[Get-SimpleSchTasks.ps1](Get-SimpleSchTasks.ps1.md)**: Returns simple scheduled task info. @@ -242,5 +249,6 @@ Scripts from the [Scripts](https://github.com/brianary/Scripts/) repo. - **[Remove-PocketArticle.ps1](Remove-PocketArticle.ps1.md)**: Removes an article from a Pocket account. - **[Repair-AppxPackages.ps1](Repair-AppxPackages.ps1.md)**: Re-registers all installed Appx packages. - **[Restore-Workstation.ps1](Restore-Workstation.ps1.md)**: Restores various configuration files and exported settings from a ZIP file. +- 🆙 **[Save-PodcastEpisodes.ps1](Save-PodcastEpisodes.ps1.md)**: Downloads enclosures from a podcast feed. - **[Send-MailMessageFile.ps1](Send-MailMessageFile.ps1.md)**: Sends emails from a drop folder using .NET config defaults. - **[Test-HttpSecurity.ps1](Test-HttpSecurity.ps1.md)**: Scan sites using Mozilla's Observatory. diff --git a/test/README.md b/test/README.md index 39bc241d..bf909841 100644 --- a/test/README.md +++ b/test/README.md @@ -1,7 +1,7 @@ Script Tests ============ -
    257 ‰ Scripts repo (144) 📅 at once +
    263 ‰ Scripts repo (152) 📅 at once
    • 750 ‰ A (4) 📅 at once
      • 750 ‰ Add (4) 📅 at once @@ -19,7 +19,7 @@ Script Tests - ✔️ Backup-Workstation.ps1
    • -
    • 1000 ‰ C (14) 📅 at once +
    • 941 ‰ C (17) 📅 at once
      • 1000 ‰ Compare (1) 📅 147 days - ✔️ Compare-Xml.ps1 @@ -35,14 +35,17 @@ Script Tests - ✔️ Connect-SshKey.ps1
      • -
      • 1000 ‰ Convert (2) 📅 at once +
      • 667 ‰ Convert (3) 📅 at once - ✔️ Convert-ChocolateyToWinget.ps1 +- ✖️ Convert-ExternalScriptToModule.ps1 - ✔️ Convert-Xml.ps1
      • -
      • 1000 ‰ ConvertFrom (2) 📅 at once +
      • 1000 ‰ ConvertFrom (4) 📅 at once +- ✔️ ConvertFrom-CimInstance.ps1 +- ✔️ ConvertFrom-DataRow.ps1 - ✔️ ConvertFrom-EscapedXml.ps1 - ✔️ ConvertFrom-XmlElement.ps1 @@ -62,14 +65,15 @@ Script Tests - ✔️ Copy-SchTasks.ps1
    • -
    • 1000 ‰ E (8) 📅 at once -
      • 1000 ‰ Export (8) 📅 at once +
      • 1000 ‰ E (9) 📅 at once +
        • 1000 ‰ Export (9) 📅 at once - ✔️ Export-DatabaseScripts.ps1 - ✔️ Export-EdgeKeywords.ps1 - ✔️ Export-InstalledPackages.ps1 - ✔️ Export-Json.ps1 - ✔️ Export-MermaidER.ps1 +- ✔️ Export-OpenApiSchema.ps1 - ✔️ Export-Readme.ps1 - ✔️ Export-SecretVault.ps1 - ✔️ Export-TableMerge.ps1 @@ -247,10 +251,12 @@ Script Tests - ✖️ Restore-Workstation.ps1
      • -
      • 77 ‰ S (13) 📅 48 days -
        • not started Save (1) +
        • 62 ‰ S (16) 📅 48 days +
          • not started Save (3) -- ✖️ Save-Secret.ps1 +- ✖️ Save-PodcastEpisodes.ps1 +- ✖️ Save-Secret.ps1 +- ✖️ Save-WebRequest.ps1
          • 1000 ‰ Select (1) 📅 48 days @@ -275,13 +281,14 @@ Script Tests - ✖️ Set-VSCodeSetting.ps1
          • -
          • not started Show (2) +
          • not started Show (3) - ✖️ Show-DataRef.ps1 -- ✖️ Show-HttpStatus.ps1 +- ✖️ Show-HttpStatus.ps1 +- ✖️ Show-OpenApiInfo.ps1
        • -
        • not started T (8) +
        • not started T (9)
          • not started Test (7) - ✖️ Test-ConnectionString.ps1 @@ -293,9 +300,10 @@ Script Tests - ✖️ Test-Xml.ps1
          • -
          • not started Trace (1) +
          • not started Trace (2) -- ✖️ Trace-GitRepoTest.ps1 +- ✖️ Trace-GitRepoTest.ps1 +- ✖️ Trace-WebRequest.ps1
        • not started U (8) From 335bd6f0df7e46607bf182043823e91003155769 Mon Sep 17 00:00:00 2001 From: Brian Lalonde Date: Fri, 15 May 2026 18:51:55 -0700 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=92=84=20Add=20images?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/Networky.mmd | 13 +++++++++++++ data/Networky.png | Bin 0 -> 24237 bytes 2 files changed, 13 insertions(+) create mode 100644 data/Networky.mmd create mode 100644 data/Networky.png diff --git a/data/Networky.mmd b/data/Networky.mmd new file mode 100644 index 00000000..17164485 --- /dev/null +++ b/data/Networky.mmd @@ -0,0 +1,13 @@ +--- +config: + theme: forest +--- +flowchart RL +subgraph https +from@{ shape: sm-circ, rank: source } +to@{ shape: framed-circle, rank: sink } +from a@-.-> to +end +status@{ shape: comment, label: "test/trace
          lookup/connect
          security
          download" } +status:::aside ~~~ https +classDef aside color:#0F7 diff --git a/data/Networky.png b/data/Networky.png new file mode 100644 index 0000000000000000000000000000000000000000..af2c5e39b31c7bcf58b27cc3abb59bba00a58a87 GIT binary patch literal 24237 zcmd43by$>L_diOCf;32Xx4_UXjnXL{(k&$o0@AG@LrQmubPEX514BuQNDL)8(!U#w z=Xu}n@0{y<{yTGB{^9IB``&xqYpuQ3XMGltYAW)W=%nZf2nd*p3Nji92uR8Z2#BF~ z?*QMh9TPMmAW$PH%1CLwFy3B3drhF7`)Pk~O2*36v|nhQni@}rpf>`Akb8ZSuTn_D zW4O7w%znzl!w5gOnil;odQ=WQE^egK>kKPmVq(Tg|Mf)!O?SAvYB>qGa?fi-q^h~J zD9v_ev!lUj0Z->S-91|1!N9#@uBk*l5&+l&$^CBZ6B8u-5E8mP- zcG}$j23Zat_=!5nLohHHF%a~>`Kelojqv&v)-Jy~XkeJ7=QYt(b3Cv%YpDk0C>0*( z*$|lvsl*f_J|9Dea|4UZdgCbaf0 ztmQ}V^tYSMt&+&$_tM|&%R3e#!yS3EC1VSa`V({Dc!|@*$^^-`)A;_sPa{~KNG-B} zwMcC27??DpEZnL0iW^IO_4^5^rl4M|-_IrJ9JD#xFSDGf4`8~3wHM~2yw!M){N}rm z7Wa)<4@mP^f>I$zolm*U*4LiQpH{Jrm8jZ#1?IdL4QKtk;15>tdr!-6yS!NwbBQmD z*+<_+S^Pc(Vrx`km*e~cmJZJtbXN~Z=m);#YL9wNV{o8nq}+165iDZHM=e&h!@6!=o#c3GT5Yfrl8@dJ zuNHF(_-cOl@kXDqoaU#Kwnpa}iQ{&Q@Z+A&#I_$W3JX`4z{G}~5K0VN+{9el9j}l3>qkY-`{9V$H^ux zqGDT$$&9bLep}k0t(NIID|vaXX~#e(!iHv_>dDR;TvOO5<7mNkV)HeoNrC-NW#yf zgh5;IVLeoCf&q@%y$tDVj7Pq_*imW?fcN>d*k9K-?o1A5&~;`OT_T_JoaDJ~oxO0l zP~N>#V{Lwpy}Egv3*$$}s-?rdaW1W&Y|wFtmF+@pXC|2h<)d2s`)g-91khM)`F?y9 zfH$7M8Got3vLo~ka&&RjLZ@;xGW@xZBP4qYHx;ade0~3CKvv_biExD0#lmqF8|0nW z_LCFNd;eN_TEbU6j&i(LNMqi=+eGqHJv;rRLeF6Bo)?_005wtLiyKm&V(gXZjRPZ(H8)itzCQ5RFbM+F zv7H&u-F7;XzdNabK=(Iv8n=eoGU>je#(^#!#~pnj11``cG}auQA(LoAj47Bb7sdg` zF*o11`}c0^uQOl8GOekae)~nuAe&gmI;2y&?D-Aydt5Fm6OU_m<)16%y5&C;nr-@d z*4^ZTt4gS4cga)-lF}gQ5ZC7h{C~fFOd$e^#FkP1dD>*&Clvn5Aj2d5JO>xYXQsaX3QtsmB5KFlt)qFwm>z<^P)?GI@NdiQoYlFkO)}*;#;^H6Z3e*n^q`uSgm!eVWSg<0XJAbu!SsTQ%mE!cNF;Hb975>=Psj+OA!fT)x zdEh9c(*}0qoV_>kD8!fiM5zYXD!Z~W&yQ-(hG83o?W!$Ddj8)H1nqikub>P+zqe@5 zwECc(Y!Apu1q4&hYQWR%7wSmPG9h$UQ#KlZH0?Ed3?m_LL%UyzTj;>c-=dXek<~0m%XJWgA#om zo1~u);)>lI4s0qmMJT0(6A>*1b%{Pb;v)K2=un`znG)V(g^ClorfZsEsZ=sne|)VA zJe2^@gPYhQG5H5>ocLB7t<{)(k;9oIm z=3yd~5u0{omL|B>(N(aK6*p{lyhmp&^E`Wesn;C%DaK=@? zvFEDf)1T`wt}NSSrO?st0g?cualuev&6%W6uu-$)z3e_gY-9 z(0fVXCZ_&AirM4`^>dlp1k1G#TGUHIk}|8@za9_>-S)z{hlw%#C?(n3E-s=J&=f#u zpC!iQMy1S!U0lK?PgFGQ#%*p4O9R zt6riX2A+|4pPuesxg;eeJ&y$ug{witdY362%H*aDe$e;OZ}87z2Nw zQagF}aP3=Ks__Kf<9%1x#tmpPx4UE@v`TZ%Uqw)ahnL%XMAYx-`2J<1l^yzS+bQGG z-o%{uov`k|=ho!=`LmYm$4NNV<__-}y!%b}t6V32j&+;a?f&_Y>nGrs&H?)QR7)== z2?fuGCNlE~q9Ci-HxgHgDP-mMpMt+Q`96JgqTT%phFduB!fQaw@8_g@+vN|VhHs5m z{+V=uZU6Iw4}O!*jXPcPM<*WE@jXpUS~iz`BizzQ zUg8(T0Y>e3bZ8Xe9Wmm43wvRKF(lDd57?n@>69INPF@lu{}M@}b4PYak%=E_?D)j~ zRX29yd0SF)dh}x|f4p-n@-awHQ8hKi}%-_w#JfMy(^O zWohqUiz8Vu`NdrWn|;@J(zipDvA$b{u6hCYAJV_TaB5#uC3Zby*$wFUmujG2Ea3-s ze>6#1hS*nrtXXJjIxqWpL>2h4mMS2$3mI)Wc+S}seom41`Hw@$)YG;74e@gv)>KWBDN6skfd& zWdF*9N;0o`bN8yW+UoGZ{15m#q*B?w^=e!5zs@>;wM?g14-;s0*)kccQw9s}jw6v~qO8ViO0SM3z;*oy|#!3?I`|H_$Ni7|$t-Pm?Z&W-(2; zS8u_8J>#Oac9?=r!&|GER=eARkx{F`0Vt~v zn)@P3G4e{HTFU8r=ra5=Hx%}XVTrUn5;OZ?p9DYB} z9xEs*J&(uD`^-hG-1}L?7lChuI!kYRH(CkPUeb8(-b@1K{*|4Vm!9ptY5^0J9s?XN zj-VGFO}=;i$t1HD@4v0XG@s)45>VGR1!=#-{^TD87bl6=XJI*0YJLz)+T6$btsyqu zWe$TYFQ*!3+QgMa4wDK-Nf&Zs&V@L`8fI1e@RkpD7t^yOnXA1!)Jx)&Z`&}ZY&91y zzxLPaOU3aKP3pBVB9y()pbPT*CfLs=EGgO~cqW|~_X6-8Cr8m$%X53{InvQ%F=dC&RbAKm#$cJp7 zp0P)yLuy{IZz2B9=j!W5HD?}hvG7B1sg$uXWtR6T-%wVAqy%Nae9es;hUBPFtdlUz zHH#oq`HN9#W>!g@hDtTU*T?`5igjzfuP%qvI%^VDuMKwk5Yyo;@pa&P34yS?_Z_ij z>#!2CP`0_o@`P4eDsY@D(1kG{#F5VvH|C2yTe>4zOF+#)+3#v>aizkmYdhizKebay zYTJ7bH{-U4cfn31;P0kN__ur4H#AwZL11r~i)43# z4yLXIFD?&gQ$<3=#6|+p1b=4#DcrxAQv5XU)ge2b2ou_2YDMRTb2@-`dgs{1mEnJnbBn1?rpCpsEi3|&7CF*JW@YhlA9 zBwk5r3OdU#kpz8CZ+>)@mwgpbzDBia!>kM95XIO?!73km$+yBb6FqXrjzMsg{c5p4 z+(&xRi@>yGX&iS3Z>1`lI_rFLflx`@2efJ=rsPMl|4AuAWPNKIgTZ+l=@iN>sc{d^ zH9Qc~_&lXOH=z_QuLOKq7bp*a5?#FU(kasz|H|@}2NjgI*;Fc%gnt zTe4-n-(x>=jg|Z@=!47*8Rx_Jz!@z2pSo5Cz0z5Z^%MuSn!}T>7@i+VMQ69QXp(HC zvSyJEy77-W_lNKzI)s9Cse_RYg-_;j&#b3(H~b1ZHTzQ9G3W-u<@v31rlUypA3@F8-)Z~RNY9zXF?9Oz#B*&!ag z0^hiY7q)<2uS7uDiw&kj!*EI?AG09uYC5!)5|g3qJh?aELP;#=d)}k!l6I|ELKQS7 zND{lC(IVDf8{sGQfMYm~4)}DD{lIJzR@c8sB`Rvj%SV_g@}Uobk92a~24ttUBqmpI zd#$p(6$_+y(K2eI@Ki}g*haNRT$mWP`P{_&F!1p>`R+5l zJs(LGn(}(8bUk!!CWxN|hdt8PN!m2Ch6wISee|%Wq8m7A#nib;A^QYFz*;fR=HBUN zoHmNxM)OfhEON~yp;!iLO2fPR*-P`^g11fN5qC1j$b>P?*L2qVX$}ss60U_+oTE1l zsO1E^bn}%tW;!w~KEmK_)p6PR@}Vz3l-~2*RiGBb?Qa|n6Kr>L&yEgz2VsAn7j6PE+VX$5$+^oBua`|LC6x>lFY9xZ-RjwgsTSld+G_303Hdzn9Zg*W3Qg zdzgkEB2hU&p{zUnl9)`~d_X#$-lM#tq2dGl$VMI4cToX98m5=b{Z;-e0iUgLEM8d5 zqo%zIaQCEp3|6fI)b_E*nMUN%VR8epvieKNDu-M$kSx4>^FaAzS~^(D$~YhEjl_EZ zA=+GTP?)6J*7?T08{ln;);~SW!YZc06Cn0u_Kuq{+mV)*pk+*9uHwA;%AE*|4i7jH zi!&&UGv=wf)Lt!ELJ?uGWblWiNPgowwFV2XRZ~&D=$1wF*1K`{MEclnJTw2yG&v86OqKw)lql z6x2s<+Hz`tH#A^qg*x>8ov2Cg)-)o*+<6EAv7lMMn?bsS z=5RM_t~kvksd5vdiLQwHsISILV@>5B#+&T-Y6X#}YO>RJ-lJcf9h55Mt2c3jb5Zg> z8~jy`s3~@hK7%+^&sQ>PvLyj(7(%78#FKZ2ml>@{P-Kx-zU?pX?5o){ho|` zsSlLxhD(%*V44XkR%tKXBaLy4l$uz490hHbRT{%X3x*tBdg>Jg*w$0{B%Ow| z9c7nrwdlfoFzA@U(9+rX>uqwO{2|DP3qvnL_p&Rr#Ot9TkGBM6i)dCO$#gcEh2a6? zYyshP&RbZgN8COJqSZJnrv+Bmz)GW4aEThdK2sTraccQ`9=A`>sBOY4P|*U9()^UE@c*lS9VJ_P!+m~VolEu4zEM&T;Z7YtQaf$FCdrTC-e(E`Zyro6$y}j^{nOB$f1Qz+8#xH)B$@ zML!Lz)msua#(Q%qGpT8qY$J~?HD9IOOXxd?j6YR!tX_Ub_oX@yh|S_ zT~@~*h;|alm5cvW8K&1ZJzpwQQNGZG^tZx$?BvtBWGHjs}VMG`nxH zxt)thT(@-48cXR`i>Gj^DiPQv7sq5Jv|C%}=b?Ja54_eKn&>Q*tSTvG@$BlH9!pXh zjk3=?J*vI-k8D46ruLUzi5`I`WmfH776nog+8-y=obv^>mPEI77QV10>1mSyuWP>f ziw&{7ZT3-C;iuyYMv{;E@Qt*K(k<6_VnzXK6W#dCYQHX4IKS)ah(I7iDOZIeapJ9W;M0HyzOcSsYtp0I&0E?a8tpuRwp@_aG8mHhEBq;=CQS)aC;V`96d+ z!and}k&yJFwSV`re8x|8qGhqKLsS@gpIBeNSV&u?T+`HBA~-Fvcru?NdEr*lwCSP_ z)%a(RC4zkW`iqbS!-WDQGb8?^rw(?lP0q7v9MqF2Hgyr-uKY~xv3ip3FNaLx zEIGwqm}L+Y?Wu;F0pplKWJL&yDQQc!n+QFsEkW_q4@~k(BF@e_PF|5Oe2Hn^9!A!A zCgrf`EH~&$89Hg_Fq3mP_d%XtyTs~#?6CrgCk3eJIO81lMhHy6SL&{*+kZHRKw+2u zd2!B-`oS*J;yJ}inY2VSDM!+@7a|xsmdHqHjKb}d>1!xb%9&5aKNSV7qdDaub zd<3g4U#bKiWuJv!B6q3cWVdEea-7HWd^lUcH$APt<3m(sP=59Q5~90>G=Jj)1Pl&y zpR$b36B39=8PG&K|3N!m_s`UzO=EkjRo%TBfXXjaItI}G;R5`LCT{UU*+`0XFAKfF zG7pgQ;*a`24&oQg#oXmP>K*+LiuKQxdkZQ4;~sCp!+$QLUn~E;B5pCqD7+X(=YJrL ze?0mvRLP?B5Zv1Pul<{X{{Qjd#3o*hhS(QKvHH;N+HbpVaLwL-U@<`c2IeMK{N;ie zb+8|)ftJAe-ZkfbzWPp{W8p~MfTNQMU$|5+QpcRx;u=d|*&4>7>+rK?x_VgLw`VVBp`N7^1HLfn7Q zV}wC%Y_v<6%RJS9xVkwU1YAm1j&5F5C4Y4Z9k&}oKWc|6bVA?ecnn4;A9x<821<4& zNAs3Ni(n#>7Ok0C2+aS-HvsETumKV2?p=p@?6PlyUJ|kbzMq+Mq)GD>fn9v~bqUMd zm;WzpKvlh5if3Db6Pg~wD2Ff04TOm@+8_q~gw%SpS9L+#+StYEC^L979ysO@CsQB< zblnR2s1fj8XU$`PSoyh@eLoxxIR#;AJIv!Cwey5L$3S>H%zAS@Vtsj-pbS;rmWS8CM3$LG{m z4#6+{QLDwz$J~CQ6z77kf9~z!2wW_Sizht<=Y~4Y0SpN$JiKpBt3hZ$w1vY5f!1Md z?=vAg+BLO&JmbTkYMMA^DXeBa7q*OGB;-0c)bw~}dKjQ5-HvkQBL1T_it+gC*~va2 zBRFzG*4fA?-e09K7O%O zPafp4d*5{5$t$(&{hn_H%8UpnBzOkSSm?y<1r54j*_1LBNL4t_0d=!mMY^x;0 z!-s)O7-iQoms0pW(bFs(V4wW%D<5Vx5%u^Sy&^vn(RW|UY=nPdW{$^hH{M%f@6`)S zq0qBKbcWR$Oq#ttTe(c=p}29GL~D0qcBWlrr+zj5)bi)ufC^(CAaLZVvUnT;*Fnag zlHL}*JIhYk_#u;|K;4rnbQ11nx`lYCx4+_Fg^MQgji;?duIpKYdyWcikK1D!D`(^b zhyE!(8X#D^Z}+U->eyIM-X9$$00|HfOiVNHG1vWv*q*DBqQ@9FNI|j21VR5-4w^k7 zbcI+nbO-#=o1CAE7U8tlHi1ci58K)abx|L+#*^yVBjqIX`pH>(>vlG$TFYQzB_%7ac8&J6PKglpPXHe51-{v4fWZ5@c?TS)Qf|5roOHbP)(ldlA{QM{SN}MBqEthcG!|e z8Tjnoj>VtsZCw=}J8#sKbFQz#JyLG1Yf8@R z$`=_WKS>38MD@~8%it)r6>+fuKoKeQV0UjwXXhE*!r1u)ZB-L!SaI6=$_la;~E{oW`lLl*8layU(59vPPk8V#lb~SC8WR!9X zapaUe?s)0`z@u;=#9Gwp%KgZYK>9r)d8mYPE1#vam0|>UL!H=n0hJL8dRJ|9g^p8y z2LPhDKznC!mEmoO6*Gv zZHdM7HNyVx-bmugElL0@Zm6Kq3~CBrH1VB!NTGAKSKZyXvcFcn9)sXBJyC>FftcNr zmkMCiF^qe^?$hvY3T2;19+1s&o}r2A^;i_2smZys_ulIrS8YC-)sTFZQ$O!JV;#Yi zo4D)4L2v74MJ2SfWhM^9s?Yqa>buq4ELVFpkL$Cl{l7Mh;7VUraIID>9EmcDWwV&l zdM-1EiywQzk=7N6kCTG^z0U}AaYq;7oipm!a-^}5#3nvj5Vy5vYn_E}Bt6+*vgg6X;gA4zJ@Y`?doGN-+{9dRxpAaZ_L#7GSjuhSjfo8Qr7`XkD0H?e(hmf$raY*Qb8^k z@mtSVvsINYT19IEkq`m^C87A09Rtc%V$&siJa{yo#();-6A-G&YTTw`12UTkfI}b8 zC_>+r(t@*0(DyqZ0V0H*FwYGWTJ);;@+or{jY79BEaTd9*%QDU<&2_ixT&?`t}Q;ZSLUZmE>08SMzH$4KLl>k~y@#6Z^5P25;rW+owg8SeXXM zoy~rQQ?7N6`4riC>xR!%#P3501P>ni-04}31!zjE-~6ffVDB1`<>gv^GCOU?i##52 z@)5x=in%P}i&=A7+{fLEWiULazFQd#v)LWj%<5FR$)brt3~GeqrwTVG^0 zE3SR|q|`s@@EsR4PVl_f>?t?+5nwYwf%pbgN}5~GlUohw0z&v!Go8)l9);+ z`i{>WbXnK%)L!9|r_DDwE5;D74!wbV$8b@6g)L&!U?>1k7H04Xk)+{%CZ(9V8#rIT zRbAaIx6%c@A>o-R=+e1O+>%gn%<_UkR@1h~6KNg9v52`f!!=aTVCvkg)|Umg&tD@C zLq~5ImxFx#vF#71^(5djW>R@umxaecO-H0t8$WdQ934CXvdwD`%4z+N7hKZzJaMKK zfk)MJDF)2UUVib?+tpR4W;&8sna%(fITiKO1+#~*_6Dyr2reGH(#HQljO^T|XaWWOGoT_|fGN}a0ziM5>p2SkRqa|Ss zRnH$ZZclfXvlX0Viy)gT?Q2>C1F=u@)=6Zc9fRJZs{lK3~02Q33q0@TDcxoT-NonQx5#w@)bn5(Omf)R~@6fufi5% zKwodqE3p32D;kS``2}&iGA-6N}z08+Og5n{by+2JDoUI#! zD{~;@?0WB~q>*Q474Jz{^O0DjaNfNvkWl=C5>D>3~S5*xrx6^sj0HEB?(Rpw*0QE||*w4PDXZ}foq%(Qp(t4fk zLZ6xYBQQjiR>LA7`QpUJ5?BXH*0M076c~23`3gsWWYOF7!qWAHA0fs>%n3|Yni?RM zoe9%X51nNliRd#mEJH>8%W_suDCX12m#<(4*99~Jq1p|7KUbgiC#Sz1{4$xXtpO_e zws+~YD@CNlLEQAiL99w~X+Ta)hlC+Ut4&A&EfjAbw0J3YTq4Ne zF2<<3=oN3?S39k)OTj6oTLmeg9T)aS|MB?8Qmqbe*L9@5?u9 ztO-XG-5E4*xK3o^558E@I&`L4P2oIvU3kXN9`#~fAcAcDEwcPWAX2$a_Xy7M(g~^S zyef-yM`WWalX4YRTeS~^pgW3CE^Ut}#f1TjVev~EX5Zxy>I;ehW0^MJ-$YZE&PAL7EJa%n$91;3M-AH1-mB2& z=-6MoS>sy=!?W0OX)kr%nst|mf1aG;Y@J9=J!U;t>b2&)Zw9-J40a)vT)$Iu3^;J$0 z$)gg}_hX5VhPRBJ@yG_rR}&ydXwj|tHn}BuRQgqwLepV0Qf(#sF%9K~qKV_vC;CXM zZNig<~U_M?`VUl(UejQ|tK|y4Vtn4HBHM_E-i+ zD+M`PR>c{;L>Fr0{;@vd6N-$P9E=>+dGLf6(O`j$V;Ol)%(DKFx?IO1I({H5nE>sy zC@u&rKOwd-WTJ7Hu45(T*WOiLqV;h{hV{7Jmrw-oM>%UHKA-PVh&kG&Y1Wc7t?jv; z@VA-!)@W9n6)VCU8!JxF%d#ETLMujJy=|YpNY|q>d++^?G+`7TF51qm#)dfKF_!V1 z!*)D?;4kuC!*RS}NYBp^#Ex+Cgd@PNlIN?;8zKVbf=pvN;g>-2cv~4LoMFIYfMxhd zX2U)kr3N7n;w@On(q>xa!Mbd6_5M*IT?nC@onxVxN!sU@udkUhqOuIKs@?(RT7t5_ zuf(C0Z<%^!EB*6Fv=n+8c>IfX1=sJG)LG+)H#|7PJQk&AyF(ux>9QpA9vuJJZalv& zTNTbEk9|Pki|2=@4K9&{Z=Wu5T0LFt&;7IZ$9jenORMgvTD3Bj{m2R}@tDFHJdjO~Mem&@hbjRXJ4`P=Y4j2*pa)5gBgw5a~A&dR}H^<&u z!T_U<^_JD9>7d}09Z#B>>5)vIaO}aly)wxBrnsD2Yib=gG4L0cF3zt`RS1D?_QK~q zHu^LFWF)N|TUri1l2Xy4gNS~Bs&d0_l&^eE*`#2nj_}sEE0?Nl+P zjUY0`3Uulf`jv5d8Nbdd8nXU5y!gxL>tUuOhpjPsp=j7|Yy|GkCp@-`p+jP@y z;s+`EV8c38pU^>vB{Uel^q4a#w@HZsRXs5&OLLr?HkTHtsMS~;I>k7gTZ0^osj{oQ zCl*u*fg-Dl&U?(e!J&7;BFZ!)ehTxKYmw2Ken|okzV2Y7JSWn*I5MP9T#29qc!mJ| zL`GUxw!bqB zpfda5zE#-H$IAyNItN;r=nS&G05LXVAnMPKdMU+LpcA2*izkBH*EP?RyQ3L{4v)xj z-`tqMZPpc~Z0GuQ^PR@Go??A;ZQqWDvoWjSejjH5v9_PqB&>oZVd5t3YPIq9{Brw04q zZC@pb&u8S$!KE8pZtGA@IY)$sWMphh=%i6z}=lA#q*yK-kiS^?kPku!Mb65 zPN(W#XDK`296d+gSXn6EDZk22cMNaaHq3G45L5k3`V)1mg>n_&pE|x08>$#O89-j` z9oQ4Od?H|t)W;8<`x=4K9(?g4!uz2YS~-p8kmtQsq9UoRaV_Vq_0ff|yjQepsdrEeIOj~($Q)c2t_Brow-RNSu#G2i|0Ajto zWN85)$#u|B%!~bXYYoP#W*>s0>u$UG`vdCA3{-B9mht%bB!41kq;B|I7JkqYZD3V#_I=+=)U!Rs-lEBG zns6KnV?Za&=J3vWYR!6|7Hb!oC+lzG0K4rem{ky=K^wnw@`PpS+UcWgvIZN6(3*2u zuEl!O)mm3o8V(nG*iXLh7@SGvm*itO07@d+0=gt{UH6NaetGScFQ01cQb|9Th`bNw z!ZC5=&r?#?qz-QgZCz)k=A&e;Hp4u{`{`Qb9f12arZ~evPOE3AA}H!Z-8uCZ6S6cI zD6{p-q@nc8nxso~e|-uXra(L@MFX%q*P;Oai)xCM)cbA>^C1$5Bu%(^_aYyd-kYg? zg)BCH%*l4?@AgDU@2+}Z43-F!7FmjBIclNrF7(USRW zlEe#ipDf*}w!V*w$4+6b(-FB#BU?J*>P%JD(EHN^CpA#lLFRGawBR~4h4dawtjocd zM7cH`xew~4LWdrKM)c@n9cX)E(*Ow_oqGU;AR`BrWKuDG-*#`V`t`SvvX?8@R|H1;y%XlCJ z2bWP0UTQ{X_c#=rM0DRtZyy4cCre1&D{O%71pKDA7e4`=rippckCj!Dd=_*p6(`iD z+?^&;(o^n3@I73xcn8!!s3kH22`s)f219F%jgyP_{#Zf(}H~zONA$exfU%e6+?{Xol>*|cM z#q$2H)*cNsrFG!p5RU-NVzz_*B`a$TY zgo%-d=Y2u|C{)6lThcRK@(i@;ty(6BJghk^TIKoeXmc277)Z1VbylS;=cn3&@I_Jn zCG%@%_~j6-ULQlLRyhrj9`n$&FCcN-(mnL@tr3!geaI4T)5SgX`X~&MNg8f=4SOD zGmy=Tq*JDWqP>W3whC7ANV{HUT;uVPHG&21z{95$O4Ct%4`r=HR_*E!0MMp%xp)AV zL>YFT5|&k;SKI|;U?Ti`pZeJw>_}{e04OKI zb(jyjjD2XE7O#8E+g?k`u)dJ1=Q+%UmVQIb7L=;Na{;ryzBnT2e>Z$w?{PtI`Yw{L zj<(6T&A^|EXf*U~wXt(}(kNVjEt+kTP?_bLLp)ME=)zY5UlCR(7l3&>MV(_7TV3@S z67nZt0{F`%7pvbXsIM(k$Z)QI60W?<&Y+`N;h33FLA%30jvXTR`i7L{Q`z1dp)c|o z02Okagz!qOkZvkbA*5-Kx6f7X3x^fT)j(}h>VewTL_7Nf*MlC$1d|NA6hSq(nFvf% zK<8^ zQB<7JPuE8nM?TK`Vkv8wUh{wHN$_cc2M7S*4dr+;aC42(sjt*xCcyYvV8%Y$#L5R9 zOp?Z?DnwDL(^~}u&yrBznIFR2MryHKotHG|d5Ltk;)6x6<@`VVO$@Kp5^WC76_TfD zFi(n#8oz4cdFU$}o*2#4MIXfmW($9se+Sljg@8b5c=LAw)EZFiG-}&7EA-J=wf>c& z-`!6Y!m*fYY>DchYf0auNfMef%j8=KRZkU`8l)uHX9vFmiGfN9CFcdvRx(%M?~`@C zLj5dr&Sx?SRMc;hkUxa261=1pYJhcl-yU&RjKU@ZiT-J4Fp}v6VnntlB2^WpaUM&? zT1mpRCl6$zFr`V?NUl0q)(#V6b(h z*&*UQ(47f_R`Lb`D9`{T+W;GibJQHhW=-fnp=PH|E?p)Nu;J^OsgP+L{S&XME!t>w zU8tb~9FVI~Ijk?`Sbv>93#=vz~-Z2{g9+?wteBjP03_t#Hv|U6epe zSl;hTiESy-&nqFd-0pwgAieV?DLC3^De6pl zVjnWf)pRaB>8LliPzdCLS2wdugnrH5`2r4}NH^XT=j8H;enW*J?nb5g?3U1WOR3S$ z1HzWfGuyW{hsbbl*-tlo8BHN_Z6Y9g^wIRICS4g_5<$C=&6>V*(AEX8(vI+ZBmz9* z$Y-}5iID5?gC*XZd64eyG66)K(%EaHBd;f9B6I$Rl&K3ISWf5X+PfA}F#z4iGLmt` z_W46FNDg274#4r}IN$d&T-;NEyFR@~^U&ikP`yL3xh0X+#$PCjr;y(3iXH0Lqj*w;>U|)4+lXjBFP!smIWN!6 zaYiCLPoVc#M~e{7ldL(?gAn}TkRe08;Xd#*)*I8VMIY`2QtY8wtgTh9;8%R6&W(~( z54gC(8?6!5xJVApMiQ*+kn{_YKDz=um5A9nnyV%Py_C(?Wg5%4LZ{6HT@TQn{h?Nl zj%dOgAenge(~0bchq86jq#7@i1tD*&=2(Rs2N$wPCZTS#A?R330nzUMnv!YysQ|fp zx<0^d4Hqq70SfQ^EDx9ZLNRfi%Mni2c)_Lj@-`o`4%z^)(=Cm&KsMQgF?jHL>)xrF zGu)M#+mW~Dn?(0jK%+M~3%GeISnTTAC5=%oz?jbzp_pl0TClwKq#UCq1iDjn;#C(e zgI5Rp9vM%3_IEhGCf7^)D(*=!hXdrHFy&wA3ql><4ZD5Y_go+%HMJ|t=gwH;t3}8)a`pHH(Mv3h9UEk2CfOp-kkgP@b zh}HcyGAd3y*Q=j?Ay*G|aOozQ`%Ic)>X>4%cL5Ed(S@J*Ot0PRNuFwqlC(TnsnG6p zekz#}v<=3ZpP%%{yl5xVxsH@nc^ANJLU9*BYklVI4qay;_yDaS#|TV``6!PR$BQfI zg=Ld(YeZ`Y)2fLwiaxS9TEOQqh^e(pfauI~gq2N`Cu7f6VS7)r7Re9Vvl!K&_VYiGfhHt@QEciZ zaulF;duVFQ*aNUO0*1%v+%;r3vqhxhY;5E9hQlW>13O1T)?9Iqy$-gRbF5wl6w5Un z-JLGHlx(B#p8#)~eggYThJ&cZfY!`jz^Axo56UQP_W~J9sW43!HANzwKPtHtS5EtNH9sWp^6~05@?a9_3uflWA zbv=^t5d%s)86!8V(b0~M4I~~t-n{cg1c{oXLFDs#eQ&TH9<#h5M-!QlNfzg8+(9Vs z(hM37muvZuF9`H?Ab%(=p?Vc(^@dp42-a!*B89~4OCqxUa{fwH)loTy@05!_t7hi= z+Asb{+t_bKrbP))N+D|=JkQOJ!D^xrQ24>renRSpiMgAWq${VzLE3|+s{{d0$lS^# zA&%FuR~*U)kjG%t4V63zgJ=Qm{NYdYA&hZ6K=b}*Dy1k!36$ikPD6(^ypmIqDQMuF1656);hvZD zqPIav^b(!X2g7I+QKGlVK`_dwiB6Qk5WV}qiF?j-Ki%hkxF7G=_ucP$_gZVOz1Oq$ z@3*95oJPPQ2I0{GY%%B1yM~fRwVj6As6tv#HFr4%S|Hsgc)Z{q>8NKQN-B}VLA$lI z+e?XFe#OH)!E|D(@+DdVZuc23!}NhVBxP&luiX;h-k)m2AqQ^``=0VlhMgmQp=x1q zdt8(U1qbQe959=CbzcNOqDU7;jMvpz_2k__gqs75LA>3-*83>CKLAG9kaxhOfl8xu zfV}>#Nki(NehRIVZlPDPWl<+!!}_DXEv;AJgCENPIt9uy>$lSLrWx_|_S+%E;AFmPBWLPt9J0>-MQB2yVCO;iSOrvmh65`t}~7#9A~^6Dxg~3 zv2>DISo3!sU@b4Hz*2f2)L44IrYe4^aR2+vMZ_OR#u67I`t>S-ROFh=ud^hf9XLw> z$qZd|0IsaxKwofnp~jLPPVvS$Gfb6`qqb52SK{SOLxbQzeUtH-{oNz-#T%7eoRGU{ zH5kW;cwB~p={i*+jU1bgDnMB6Ny}EEE;>-Nv`=Kd3=`gMhC(-cx+ZjP@0?7W!#!e{ z(HiN)UDbnW@UHGafCe+hqfrNuP}4N3pdEf4*X`z6&@b&el)5>mWhn6Y-gn}WY>xE& zTV0@dprgxc%aq60JZaD032fKD(j|(hU#{Bx$5lQj02?%2S4AsAg;ktGM+9YdWhLW={aUTQmjT^A_{M`tq5NuiL)e45dP}gYbL&Y7&3@b-V7&ns}M2x zdd#4QM5bU14a%Za-}Sc?H|S#>US03Bbv2lwfpZjiNvGLZIq|l(!b`U|W~GX{!GmlL zj}VX(Y)<119l^E1BJ=h7Hj}^F5rsep51YjF^hkkc9+csU$25XnyTe5xM8ejsaqq53 z^&;!iKeA(i!=_~qz`|UScC-*kdl32DZ|yOZJ`w{^U%DCtFZ1{YxH28=`FdR;S2dB; z6nmnrLK#ZKA~#cqOGy@0xPlhLFw}6sOaZd@tBmOxWT%?PnXG#7uAQc;oIj~U1K!H3Lv8mz#NK-hPFB6nF^Q$CGY03 zhGUv`hqq$l)oleRW7ipixYk6Th|dZ)Q0XzBua$Anj z34EfMiC<`1eN_JZfaY=93AwLH8C-$XS4C%rT+mp&^{b^ruzLS|u*P&)eU-#~xTVVH zhDvpcO$TJp@{OJGJ_N_uKryr=3Rz7xi`uYlXX`KP!&Xhwr*Cjene*b$sLWT$SkzRR z^4LRNSXEZSbgD}>;N6}F?(ioz)V9p~Fpn!U>KV$r!bJ7WMAPY+V)p*L8f-ByBE z*KV*V-wuGc5|_d_kh(dJe=ha1I@)qnR_B||OMpEsX*uCe> zM4H!CT)(Z_!E$ygGgTP!t!nk zCwF*d(%Vy+1U26(s2T#$&&(xq&wL4kl{fDgdwC9PwVk>{-!Dpq`xHtYw;Ji`-F|gY zC*h?xpzmsPIuem>IZ(Gr5H$=0XB3^{^?a~Lomf}YHy^axbSrflkf8%@N-#oCA+7O@ zJkbKUx`&xzMG>BwNpm=d6Ez2Sn<;uRg_COMx8VPZF)yK8tpU+M`RP5wwiC~#aQ>aN zX5pV^hJ`P4l09ghW(5KKG%=XT;X2#}wRW_|==tvO;DuW2U|Pm)ty^**7=aRPH=O+T z-$c$sDr^v9z?K)Q1F0O?BL!NjZYYFB-&+Q#UupLIP7WPGLu-D)_Rov8wy@swd|$}M z4)_(r6JfW|_L?~h@6xBJ3K9^f_2Ol`XL23mvPMXpL&-oKNx3r)l}x=utUxm_xB|^+ zFhaQt;z;PSX2Z!UY{USX9M)}I#pQSMi8^0cRF)wrZRO%j>@R{u47yV+e=)vUGIa1{ zWYFg(a_4)aY)7Ib85^TjWx#%~1F2yKxZkLqg-t2tYJ~X~tjp~!JaT?kJ}=cVxzjB) za>9{3H)a3s^1a(0lQEx7v)~hds+exTC9covdjeEsMV!}ynJaOjE<0S79UFy!w*z23 z9Q|O`ReuljvQr~{P_}hgjcIquL=T1C(uVT<}9r))2Sb4 z-|JYW3k%8V=gyMqljv9(jgy8S6zN~PHuSV5F>ELdEi!b)gz*xio?iT)Y)pFE7COaU z1q5s*<)aU-E!7{o^mM379yzMEfTB27?iCwN#wOuw)_*X!YWl=_XX0z79RB|4B>LiV zN{iTHntPN|QKR~Vl{>;4-D#x~_oO?2J}9cT^}v2FtUPFG)whm>+*BGH_<<_-z)A#G zZj{xKq~IZ#=Li531|e7^BVm?)x|(Ui&{Cr{dv><~MBCTx@BH2Eq)TbD$Gx?Zc$`(^ z(-#o_QDrFhXK=2tgC{xZffGD<5-l@G*=3_%)QzMzo(?X?uo{JN^aA z)wS!)ZW23Qpy79tYLk=FWNiJ+r1*+~St&1rhTo^emgKs#;;+4hE<+*VkogG0#Lp~V zRKRsz2&J7hy&{PbCV$y^uBULk!st@QRs}zJ67kF}Gtmym7)bj3GH}0N7 zdyFbnc+S>o*)Fj!rKAuBo|WY{#VZt1ik0f&21vEun>XEMmw+|d!3uj|f+Byu>2*gQcHY7!M-?*hGyLTp{r^7>2|a7H^ZG8UuTym z6ZbaF_e^yoGjnaHO4Hf9ecQMhplHF%A^e~k70AK!=9%K)}ja@>)=CoUN{NHh(7lr zk(PxbR0eYDRuo8Hi&L~#J&sXy9XC0`ZTliw(iZ>P>vm_ZqsY10JJBhjGD_oGlV}Aa#cor=c5j^(Yx!CHHYr0 zyqc~2abKiBd2pu>OjFY-^0XYIL|9A|WDZ5l`0PqZszNB0w-DwmQXmB;n0$(q9mWjj z(KSNr-9B-aH91vb)UapzLe)rLg#CoY2aLlK*uyXi8nq=GwzINZom3%TU> zeB8LZS#q5RwtQWXnc8;7hraSv6oQ5dO|2*jNcO5&y>n7`EWLQJtHV2#ueP_HT6Jdx zmuzbo(SM1a(APpvaOevG!WPr7*HBO1LeXrX64zVGp`gQg&)z9x{jwaqLGwGi7A$ai zi8KMR{d#-(J|gU2`O@MGLDYrg$7NeSKm7?VE!O#%DWCh1nobXwb<~KHSnP`K2LT`; zP!9>aUyeQi*20BgxUR^|up{?%^0rL8Mzf(sQx2}PVqSSuRirPHw)&@=!g!2B;1!I6 z8ibO(pW<2)@P&{!(Kpo#6Xu$U5%*R=6f^RYN^Hq$r$W`4NF<}LcQqO*RD79~|W;Y_E7IW7d6an|Wg#1|ivAkjxKJgl~ z0Zdew>7THretH8HaK5@&idFv6g5NOoU%P!^2BK4i#oy!x>Ny`^AC8<(@k_hlUu)@q z7^TF7owFXoOY~DTJE;7Ytd{>~NGRm(&JZmVpZk2x9B5h+{rm4Z)wU+8YHfPuRoeYe zK9i(C9+8NEgb>X1l2q28GwK=U#<^=^&Z{8M86)i1WVrYm&_c_xdN+o%N;Dsh0~&Fh zYs5r)ueTUC7xsna71f1l;dALEx5&PM+OF4+z|&3XPrfHe`C8B+`AJJeT~ zd3q^t3gmzPTr?&&Lx;^xL#kJDomJ@YPOvF>gZ_MiL)MCw@tIzeA9K^=ZEk@O62C=( zMMPZhChZ6126Tdo3ia}pwV}~XJaAUqzvbqK+~{kcz&Uy`LTW|{Q7&CIiIbr4khTf zF4?eFxYl}Z^FFUtk0y><|2wd9^E3kamB%?PxM2N?lp9|-gj zNC`k73t(FTfjYqb6d=%hN;EY<8V6P9`GOawbVQS literal 0 HcmV?d00001 From 26e763bfdaeb637af19f76a4e8e81fee37c2bd28 Mon Sep 17 00:00:00 2001 From: Brian Lalonde Date: Sat, 16 May 2026 17:18:15 -0700 Subject: [PATCH 7/7] =?UTF-8?q?=EF=BB=BF=F0=9F=8E=A8=20Fix=20data=20file?= =?UTF-8?q?=20identation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts-to-modules.json | 308 ++++++++++++++++++++-------------------- 1 file changed, 154 insertions(+), 154 deletions(-) diff --git a/scripts-to-modules.json b/scripts-to-modules.json index 531e174b..2bdd8b3b 100644 --- a/scripts-to-modules.json +++ b/scripts-to-modules.json @@ -1,159 +1,159 @@ [ - { - "module": "Networky", - "cmdlets": [ - "Connect-SshKey", - "ConvertTo-BasicAuthentication", - "ConvertTo-MultipartFormData", - "Get-ContentSecurityPolicy", - "Get-Dns", - "Get-ServerCertificate", - "Get-SslDetails", + { + "module": "Networkhorse", + "cmdlets": [ + "Connect-SshKey", + "ConvertTo-BasicAuthentication", + "ConvertTo-MultipartFormData", + "Get-ContentSecurityPolicy", + "Get-Dns", + "Get-ServerCertificate", + "Get-SslDetails", "Save-PodcastEpisodes", "Save-WebRequest", - "Show-HttpStatus", - "Test-HttpSecurity", + "Show-HttpStatus", + "Test-HttpSecurity", "Trace-WebRequest" - ] - }, - { - "module": "XML", - "cmdlets": [ - "Compare-Xml", - "Convert-Xml", - "ConvertFrom-EscapedXml", - "ConvertFrom-XmlElement", - "ConvertTo-XmlElements", - "Format-Xml", - "Get-XmlNamespaces", - "Merge-XmlSelections", - "New-NamespaceManager", - "Resolve-XmlSchemaLocation", - "Resolve-XPath", - "Test-Xml" - ] - }, - { - "module": "JSON", - "cmdlets": [ - "Export-Json", - "Merge-Json", - "Resolve-JsonPointer", - "Select-Json", - "Set-Json" - ] - }, - { - "module": "Development", - "cmdlets": [ - "Add-GitHubMetadata", - "Add-NotebookCell", - "Add-VsCodeDatabaseConnection", - "Copy-GitHubLabels", - "Export-OpenApiSchema", - "Find-DotNetTools", - "Get-AssemblyFramework", - "Get-GitFileMetadata", - "Get-GitFirstCommit", - "Get-GitHubRepoChildItem", - "Get-LibraryVulnerabilityInfo", - "Get-NuGetConfigs", - "Get-OpenApiInfo", - "Get-RepoName", - "Get-Todos", - "Get-VSCCurrentFile", - "Get-VSCodeSetting", - "Get-VSCodeSettingsFile", - "Import-VsCodeDatabaseConnections", - "Initialize-DatabaseNotebook", - "New-Jwt", - "Push-WorkspaceLocation", - "Rename-GitHubLocalBranch", - "Repair-ScriptStyle", - "Set-VSCodeSetting", - "Show-DataRef", - "Show-OpenApiInfo", - "Test-Jwt", - "Trace-GitRepoTest" - ] - }, - { - "module": "Windows/Servers", - "cmdlets": [ - "Backup-File", - "Backup-SchTasks", - "Backup-Workstation", - "Convert-ChocolateyToWinget", - "ConvertFrom-CimInstance", - "ConvertTo-LogParserTimestamp", - "Copy-SchTasks", - "Find-ProjectPackages", - "Get-ADServiceAccountInfo", - "Get-ADUserStatus", - "Get-AspNetEvents", - "Get-DotNetFrameworkVersions", - "Get-DotNetVersions", - "Get-IisLog", - "Get-SimpleSchTasks", - "Get-SystemDetails", - "Measure-Caches", - "Remove-LockyFile", - "Repair-AppxPackages", - "Restore-SchTasks", - "Restore-Workstation", - "Set-SchTaskMsa", - "Set-TerminalProfile", - "Test-LockedFile", - "Test-WindowsTerminal" - ] - }, - { - "module": "Database", - "cmdlets": [ - "Export-DatabaseScripts", - "Export-MermaidER", - "Export-TableMerge", - "Find-DatabaseValue", - "Find-DbColumn", - "Find-DbIndexes", - "Measure-DbColumn", - "Measure-DbColumnValues", - "Measure-DbTable", - "New-DbProviderObject", - "Repair-DatabaseConstraintNames", - "Repair-DatabaseUntrustedConstraints", - "Send-SqlReport", - "Test-ConnectionString", - "Use-DbInstance", - "Use-SqlcmdParams" - ] - }, - { - "module": "Unicode", - "cmdlets": [ - "Get-CharacterDetails", - "Get-Unicode", - "Get-UnicodeByName", - "Get-UnicodeData", - "Get-UnicodeName", - "Import-CharConstants" - ] - }, - { - "module": "Secrets", - "cmdlets": [ - "Export-SecretVault", - "Get-SecretDetails", - "Import-SecretVault", - "Save-Secret" - ] - }, - { - "module": "Seq", - "cmdlets": [ - "Send-SeqEvent", - "Send-SeqScriptEvent", - "Use-SeqServer" - ] - } + ] + }, + { + "module": "XMLLab", + "cmdlets": [ + "Compare-Xml", + "Convert-Xml", + "ConvertFrom-EscapedXml", + "ConvertFrom-XmlElement", + "ConvertTo-XmlElements", + "Format-Xml", + "Get-XmlNamespaces", + "Merge-XmlSelections", + "New-NamespaceManager", + "Resolve-XmlSchemaLocation", + "Resolve-XPath", + "Test-Xml" + ] + }, + { + "module": "JSONLab", + "cmdlets": [ + "Export-Json", + "Merge-Json", + "Resolve-JsonPointer", + "Select-Json", + "Set-Json" + ] + }, + { + "module": "Codesmithy", + "cmdlets": [ + "Add-GitHubMetadata", + "Add-NotebookCell", + "Add-VsCodeDatabaseConnection", + "Copy-GitHubLabels", + "Export-OpenApiSchema", + "Find-DotNetTools", + "Get-AssemblyFramework", + "Get-GitFileMetadata", + "Get-GitFirstCommit", + "Get-GitHubRepoChildItem", + "Get-LibraryVulnerabilityInfo", + "Get-NuGetConfigs", + "Get-OpenApiInfo", + "Get-RepoName", + "Get-Todos", + "Get-VSCCurrentFile", + "Get-VSCodeSetting", + "Get-VSCodeSettingsFile", + "Import-VsCodeDatabaseConnections", + "Initialize-DatabaseNotebook", + "New-Jwt", + "Push-WorkspaceLocation", + "Rename-GitHubLocalBranch", + "Repair-ScriptStyle", + "Set-VSCodeSetting", + "Show-DataRef", + "Show-OpenApiInfo", + "Test-Jwt", + "Trace-GitRepoTest" + ] + }, + { + "module": "StainedGlass", + "cmdlets": [ + "Backup-File", + "Backup-SchTasks", + "Backup-Workstation", + "Convert-ChocolateyToWinget", + "ConvertFrom-CimInstance", + "ConvertTo-LogParserTimestamp", + "Copy-SchTasks", + "Find-ProjectPackages", + "Get-ADServiceAccountInfo", + "Get-ADUserStatus", + "Get-AspNetEvents", + "Get-DotNetFrameworkVersions", + "Get-DotNetVersions", + "Get-IisLog", + "Get-SimpleSchTasks", + "Get-SystemDetails", + "Measure-Caches", + "Remove-LockyFile", + "Repair-AppxPackages", + "Restore-SchTasks", + "Restore-Workstation", + "Set-SchTaskMsa", + "Set-TerminalProfile", + "Test-LockedFile", + "Test-WindowsTerminal" + ] + }, + { + "module": "Databaseline", + "cmdlets": [ + "Export-DatabaseScripts", + "Export-MermaidER", + "Export-TableMerge", + "Find-DatabaseValue", + "Find-DbColumn", + "Find-DbIndexes", + "Measure-DbColumn", + "Measure-DbColumnValues", + "Measure-DbTable", + "New-DbProviderObject", + "Repair-DatabaseConstraintNames", + "Repair-DatabaseUntrustedConstraints", + "Send-SqlReport", + "Test-ConnectionString", + "Use-DbInstance", + "Use-SqlcmdParams" + ] + }, + { + "module": "Unicodery", + "cmdlets": [ + "Get-CharacterDetails", + "Get-Unicode", + "Get-UnicodeByName", + "Get-UnicodeData", + "Get-UnicodeName", + "Import-CharConstants" + ] + }, + { + "module": "Secrecy", + "cmdlets": [ + "Export-SecretVault", + "Get-SecretDetails", + "Import-SecretVault", + "Save-Secret" + ] + }, + { + "module": "SeqLogger", + "cmdlets": [ + "Send-SeqEvent", + "Send-SeqScriptEvent", + "Use-SeqServer" + ] + } ]