diff --git a/.assets/config/bash_cfg/aliases_git.sh b/.assets/config/bash_cfg/aliases_git.sh index d56a8d5c..ce48d4ad 100644 --- a/.assets/config/bash_cfg/aliases_git.sh +++ b/.assets/config/bash_cfg/aliases_git.sh @@ -11,10 +11,13 @@ function git_current_branch { function git_resolve_branch { case "$1" in '') - pattern='(^|/)dev(|el|elop|elopment)$|(^|/)ma(in|ster)$|(^|/)trunk$' + # `(el|elop|elopment)?` instead of the empty-alternative `(|el|elop|elopment)` + # which BSD grep on macOS silently fails to match (returns the literal regex + # instead of resolving to dev/devel/development). + pattern='(^|/)dev(el|elop|elopment)?$|(^|/)ma(in|ster)$|(^|/)trunk$' ;; d) - pattern='(^|/)dev(|el|elop|elopment)$' + pattern='(^|/)dev(el|elop|elopment)?$' ;; m) pattern='(^|/)ma(in|ster)$' @@ -56,7 +59,7 @@ alias gb='git branch' alias gba='git branch -a' alias gbd='git branch -d' alias gbd!='git branch -D' -alias gbda='git branch --format="%(refname:short)" --merged | command grep -vE "^ma(in|ster)$|^dev(|el|elop)$|^qa$|^stage$|^trunk$" | command xargs -n 1 git branch -d' +alias gbda='git branch --format="%(refname:short)" --merged | command grep -vE "^ma(in|ster)$|^dev(el|elop)?$|^qa$|^stage$|^trunk$" | command xargs -n 1 git branch -d' alias gbnm='git branch --no-merged' alias gbr='git branch --remote' alias gbsu='git branch --set-upstream-to=origin/$(git_current_branch)' diff --git a/.assets/provision/install_base.sh b/.assets/provision/install_base.sh index e22a6c79..57bf9d7e 100755 --- a/.assets/provision/install_base.sh +++ b/.assets/provision/install_base.sh @@ -97,9 +97,9 @@ fedora) rpm -q patch >/dev/null 2>&1 || dnf group install -y development-tools 2>/dev/null || true # install base packages if [ "$(readlink "$(which dnf)")" = 'dnf5' ]; then - pkgs="bash-completion bind-utils curl dnf5-plugins fd gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois" + pkgs="bash-completion bind-utils curl dnf5-plugins fd-find gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois" else - pkgs="bash-completion bind-utils curl dnf-plugins-core fd gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois" + pkgs="bash-completion bind-utils curl dnf-plugins-core fd-find gawk git iputils jq man-db nmap shfmt openssl tar tig tree unzip vim wget which whois" fi install_pkgs dnf "$pkgs" ;; @@ -108,7 +108,7 @@ debian | ubuntu) # refresh package index apt-get update 2>/dev/null # install base packages - pkgs="build-essential bash-completion ca-certificates curl fd gawk gnupg dnsutils git iputils-tracepath jq lsb-release man-db nmap shfmt openssl tar tig tree unzip vim wget which whois" + pkgs="build-essential bash-completion ca-certificates curl fd-find gawk gnupg dnsutils git iputils-tracepath jq lsb-release man-db nmap shfmt openssl tar tig tree unzip vim wget which whois" install_pkgs apt "$pkgs" # autoremove unnecessary packages and clean up apt cache apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* diff --git a/.assets/scripts/linux_setup.sh b/.assets/scripts/linux_setup.sh index c9bae628..f475e793 100755 --- a/.assets/scripts/linux_setup.sh +++ b/.assets/scripts/linux_setup.sh @@ -253,29 +253,24 @@ printf "\e[96msetting up profile for current user...\e[0m\n" .assets/provision/setup_profile_user.sh # install powershell modules if [ -f /usr/bin/pwsh ]; then - cmnd="Import-Module (Resolve-Path './modules/InstallUtils'); Invoke-GhRepoClone -OrgRepo 'szymonos/ps-modules' -WarningAction SilentlyContinue" - cloned=$(pwsh -nop -c "$cmnd") - if [ $cloned -gt 0 ]; then - printf "\e[96minstalling ps-modules...\e[0m\n" - # install do-common module for all users - printf "\e[3;32mAllUsers\e[23m : do-common\e[0m\n" - sudo ../ps-modules/module_manage.ps1 'do-common' -CleanUp + printf "\e[96minstalling ps-modules...\e[0m\n" + # install do-common module for all users + printf "\e[3;32mAllUsers\e[23m : do-common\e[0m\n" + sudo mkdir -p /usr/local/share/powershell/Modules + sudo rm -rf /usr/local/share/powershell/Modules/do-common + sudo cp -rf modules/do-common /usr/local/share/powershell/Modules/ - # determine current user scope modules to install - modules=('do-linux') - grep -qw 'az' <<<$scope && modules+=(do-az) || true - [ -f /usr/bin/git ] && modules+=(aliases-git) || true - [ -f /usr/bin/kubectl ] && modules+=(aliases-kubectl) || true - # Convert the modules array to a comma-separated string with quoted elements - printf "\e[3;32mCurrentUser\e[23m : ${modules[*]}\e[0m\n" - mods='' - for element in "${modules[@]}"; do - mods="$mods'$element'," - done - pwsh -nop -c "@(${mods%,}) | ../ps-modules/module_manage.ps1 -CleanUp" - else - printf '\e[33mps-modules repository cloning failed\e[0m.\n' - fi + # determine current user scope modules to install + modules=('do-linux') + grep -qw 'az' <<<$scope && modules+=(do-az) || true + [ -f /usr/bin/git ] && modules+=(aliases-git) || true + [ -f /usr/bin/kubectl ] && modules+=(aliases-kubectl) || true + printf "\e[3;32mCurrentUser\e[23m : ${modules[*]}\e[0m\n" + mkdir -p "$HOME/.local/share/powershell/Modules" + for module in "${modules[@]}"; do + rm -rf "$HOME/.local/share/powershell/Modules/$module" + cp -rf "modules/$module" "$HOME/.local/share/powershell/Modules/" + done fi # restore working directory diff --git a/.assets/scripts/modules_update.ps1 b/.assets/scripts/modules_update.ps1 index e3b0ca21..61c583b9 100755 --- a/.assets/scripts/modules_update.ps1 +++ b/.assets/scripts/modules_update.ps1 @@ -1,4 +1,4 @@ -#!/usr/bin/pwsh -nop +#!/usr/bin/env pwsh #Requires -PSEdition Core -Version 7.3 <# .SYNOPSIS @@ -13,11 +13,11 @@ Check if repository is up to date and reset to origin if necessary. .NOTES # :save script example -./scripts_egsave.ps1 .assets/scripts/modules_update.ps1 +.assets/scripts/scripts_egsave.ps1 .assets/scripts/modules_update.ps1 # :override the existing script example if exists -./scripts_egsave.ps1 .assets/scripts/modules_update.ps1 -Force +.assets/scripts/scripts_egsave.ps1 .assets/scripts/modules_update.ps1 -Force # :open the example script in VSCode -code -r (./scripts_egsave.ps1 .assets/scripts/modules_update.ps1 -WriteOutput) +code -r (.assets/scripts/scripts_egsave.ps1 .assets/scripts/modules_update.ps1 -WriteOutput) #> [CmdletBinding()] param ( @@ -41,38 +41,8 @@ begin { # set location to workspace folder Push-Location "$PSScriptRoot/../.." - # import InstallUtils for the Invoke-GhRepoClone function - Import-Module (Resolve-Path './modules/InstallUtils') - - # specify update functions structure - $import = @{ - 'do-common' = @{ - SetupUtils = @{ - certs = @( - 'ConvertFrom-PEM' - 'ConvertTo-PEM' - 'Get-Certificate' - ) - common = @( - 'Get-LogMessage' - 'ConvertFrom-Cfg' - 'ConvertTo-Cfg' - 'Get-ArrayIndexMenu' - 'Invoke-ExampleScriptSave' - ) - } - } - 'psm-windows' = @{ - InstallUtils = @{ - common = @( - 'Invoke-CommandRetry' - 'Join-Str' - 'Test-IsAdmin' - 'Update-SessionEnvironmentPath' - ) - } - } - } + # import utils-install for the Invoke-GhRepoClone function + Import-Module (Resolve-Path './modules/utils-install') } process { @@ -84,25 +54,20 @@ process { # *perform update Write-Host 'perform modules update..' -ForegroundColor Cyan - foreach ($srcModule in $import.GetEnumerator()) { - Import-Module (Resolve-Path "../ps-modules/modules/$($srcModule.Key)") - Write-Host "`n$($srcModule.Key)" -ForegroundColor Green - foreach ($dstModule in $srcModule.Value.GetEnumerator()) { - Write-Host $dstModule.Key - foreach ($destFile in $dstModule.Value.GetEnumerator()) { - Write-Host " - $($destFile.Key).ps1" - $filePath = "./modules/$($dstModule.Key)/Functions/$($destFile.Key).ps1" - Set-Content -Value $null -Path $filePath - $builder = [System.Text.StringBuilder]::new() - foreach ($function in $destFile.Value) { - Write-Host " • $function" - $def = " $((Get-Command $function -CommandType Function).Definition.Trim())" - $builder.AppendLine("function $function {") | Out-Null - $builder.AppendLine($def) | Out-Null - $builder.AppendLine("}`n") | Out-Null - } - Set-Content -Value $builder.ToString().Trim().Replace("`r`n", "`n") -Path $filePath -Encoding utf8 - } + $modules = @( + 'aliases-git' + 'aliases-kubectl' + 'do-az' + 'do-common' + 'do-linux' + 'psm-windows' + ) + foreach ($module in $modules) { + try { + Remove-Item -Path "./modules/$module" -Recurse -Force -ErrorAction SilentlyContinue + Copy-Item -Path "../ps-modules/modules/$module" -Destination "./modules" -Recurse + } catch { + Write-Warning "Failed to update module ${module}: $_" } } } diff --git a/.assets/scripts/vg_cacert_fix.ps1 b/.assets/scripts/vg_cacert_fix.ps1 index b0c1edd8..14fe49aa 100644 --- a/.assets/scripts/vg_cacert_fix.ps1 +++ b/.assets/scripts/vg_cacert_fix.ps1 @@ -13,8 +13,8 @@ begin { # set location to workspace folder Push-Location "$PSScriptRoot/../.." - # import SetupUtils for the Set-WslConf function - Import-Module (Convert-Path './modules/SetupUtils') -Force + # import utils-setup for the Set-WslConf function + Import-Module (Convert-Path './modules/utils-setup') -Force } process { diff --git a/.assets/scripts/vg_certs_add.ps1 b/.assets/scripts/vg_certs_add.ps1 index f2d99ab7..68964b18 100755 --- a/.assets/scripts/vg_certs_add.ps1 +++ b/.assets/scripts/vg_certs_add.ps1 @@ -33,8 +33,8 @@ $ErrorActionPreference = 'Stop' # set location to workspace folder Push-Location "$PSScriptRoot/../.." -# import SetupUtils for the Set-WslConf function -Import-Module (Convert-Path './modules/SetupUtils') -Force +# import utils-setup for the Set-WslConf function +Import-Module (Convert-Path './modules/utils-setup') -Force function Get-SshInstallScript ([string]$CertSaveStr) { $script = [string]::Join("`n", diff --git a/BACKPORT.md b/BACKPORT.md index 08bb75a9..53dc76e7 100644 --- a/BACKPORT.md +++ b/BACKPORT.md @@ -16,9 +16,9 @@ against the rules below. ## Last ported through ```text -envy-nx commit: c859bba # bump on each backport PR; agent reads CHANGELOG entries newer than this -envy-nx tag: v1.4.0 # nearest released tag for human readability -ported on: 2026-05-01 +envy-nx commit: 8e23552 # bump on each backport PR; agent reads CHANGELOG entries newer than this +envy-nx tag: v1.5.0 # nearest released tag for human readability +ported on: 2026-05-02 ``` When you finish a backport PR, update all three lines and include the bump in @@ -137,16 +137,16 @@ A blank "this repo" cell means **no equivalent - skip**. | envy-nx | this repo | | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `modules/InstallUtils/Functions/git.ps1` | `modules/InstallUtils/Functions/git.ps1` | -| `modules/do-common/Functions/common.ps1` | `modules/SetupUtils/Functions/common.ps1` | -| `modules/do-common/Functions/logs.ps1` | `modules/SetupUtils/Functions/logs.ps1` | -| `modules/do-common/Functions/certs.ps1` | `modules/SetupUtils/Functions/certs.ps1` | +| `modules/utils-install/Functions/git.ps1` | `modules/utils-install/Functions/git.ps1` | +| `modules/do-common/Functions/common.ps1` | `modules/utils-setup/Functions/common.ps1` | +| `modules/do-common/Functions/logs.ps1` | `modules/do-common/Functions/logs.ps1` | +| `modules/do-common/Functions/certs.ps1` | `modules/do-common/Functions/certs.ps1` | | `modules/do-common/Functions/cli.ps1` | (no equivalent - evaluate on demand) | | `modules/do-common/Functions/python.ps1` | (no equivalent) | | `modules/do-common/Functions/dotnet.ps1` | (no equivalent) | | `modules/do-common/Functions/net.ps1` | (no equivalent) | -| `modules/psm-windows/Functions/common.ps1` | `modules/InstallUtils/Functions/common.ps1` (`Invoke-CommandRetry`, `Join-Str`, `Test-IsAdmin`, `Update-SessionEnvironmentPath`) | -| `modules/SetupUtils/Functions/wsl.ps1` | `modules/SetupUtils/Functions/wsl.ps1` (only `Get-WslDistro`, `Set-WslConf` - scope helpers are nix-only) | +| `modules/psm-windows/Functions/common.ps1` | `modules/do-common/Functions/common.ps1` (`Invoke-CommandRetry`, `Join-Str`, `Test-IsAdmin`, `Update-SessionEnvironmentPath`) | +| `modules/utils-setup/Functions/wsl.ps1` | `modules/utils-setup/Functions/wsl.ps1` (only `Get-WslDistro`, `Set-WslConf` - scope helpers are nix-only) | | `modules/{do-az,do-linux,aliases-git,aliases-kubectl}/...` | (no equivalent - these are vendored in envy-nx; this repo clones `szymonos/ps-modules` at runtime in `linux_setup.sh`. See *Module layout difference*) | ### Shell config @@ -251,7 +251,7 @@ When porting Pester tests, adapt the dot-source path: ```text envy-nx: . $PSScriptRoot/../../modules/do-common/Functions/common.ps1 -this repo: . $PSScriptRoot/../../modules/SetupUtils/Functions/common.ps1 +this repo: . $PSScriptRoot/../../modules/utils-setup/Functions/common.ps1 ``` When porting bats tests, adapt the source directive: @@ -331,8 +331,8 @@ Practical implication: when envy-nx changes a function in `modules/do-common/`, the actual fix lives upstream in `szymonos/ps-modules`. envy-nx's vendored copy is a snapshot. To port the fix to this repo: -1. Apply it to the corresponding function in `modules/SetupUtils/` or - `modules/InstallUtils/` (the module names this repo uses pre-clone), AND +1. Apply it to the corresponding function in `modules/utils-setup/` or + `modules/utils-install/` (the module names this repo uses pre-clone), AND 2. Optionally raise the same fix in `szymonos/ps-modules` (out of scope for this doc; mention in the PR body if relevant) @@ -347,7 +347,7 @@ envy-nx CHANGELOG entry: *added Pester tests for `Get-LogLine` covering the 2. Copy to `tests/pester/GetLogLine.Tests.ps1` 3. Change the dot-source line: `. $PSScriptRoot/../../modules/do-common/Functions/logs.ps1` - → `. $PSScriptRoot/../../modules/SetupUtils/Functions/logs.ps1` + → `. $PSScriptRoot/../../modules/do-common/Functions/logs.ps1` 4. Run `pwsh -nop -c 'Invoke-Pester tests/pester/GetLogLine.Tests.ps1'` 5. Commit diff --git a/modules/SetupUtils/Functions/certs.ps1 b/modules/SetupUtils/Functions/certs.ps1 deleted file mode 100644 index c8fbbc66..00000000 --- a/modules/SetupUtils/Functions/certs.ps1 +++ /dev/null @@ -1,144 +0,0 @@ -function ConvertFrom-PEM { - [CmdletBinding()] - [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2[]])] - param ( - [Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'FromString')] - [string]$InputObject, - - [Parameter(Mandatory, Position = 0, ParameterSetName = 'FromPath')] - [ValidateScript({ Test-Path $_ -PathType 'Leaf' }, ErrorMessage = "'{0}' is not a valid file path.")] - [string]$Path - ) - - begin { - # list to store input certificate strings - $pemTxt = [System.Collections.Generic.List[string]]::new() - # hashset for storing parsed pem certificates - $pemSplit = [System.Collections.Generic.HashSet[string]]::new() - # list to store decoded certificates - $x509Certs = [System.Collections.Generic.List[Security.Cryptography.X509Certificates.X509Certificate2]]::new() - } - - process { - switch ($PsCmdlet.ParameterSetName) { - FromPath { - # read certificate file - Resolve-Path $Path | ForEach-Object { - $pemTxt.Add([IO.File]::ReadAllText($_)) - } - continue - } - FromString { - $InputObject.ForEach({ $pemTxt.Add($_) }) - continue - } - } - } - - end { - # parse certificate string - [regex]::Matches( - [string]::Join("`n", $pemTxt).Replace("`r`n", "`n"), - '(?<=-{5}BEGIN[\w ]+CERTIFICATE-{5}\n)[\S\n]+(?=\n-{5}END[\w ]+CERTIFICATE-{5})' - ).Value.ForEach({ $pemSplit.Add($_) | Out-Null }) - # convert PEM encoded certificates to X509 certificate objects - foreach ($pem in $pemSplit) { - $decCrt = [Security.Cryptography.X509Certificates.X509Certificate2]::new([Convert]::FromBase64String($pem)) - $x509Certs.Add($decCrt) - } - - return $x509Certs - } -} - -function ConvertTo-PEM { - [CmdletBinding()] - [OutputType([System.Collections.Generic.List[string]])] - param ( - [Parameter(Mandatory, Position = 0, ValueFromPipeline)] - [System.Security.Cryptography.X509Certificates.X509Certificate2]$Certificate, - - [switch]$AddHeader - ) - - begin { - # instantiate list for storing PEM encoded certificates - $pems = [System.Collections.Generic.List[string]]::new() - } - - process { - # convert certificate to base64 - $base64 = [System.Convert]::ToBase64String($Certificate.RawData) - # build PEM encoded X.509 certificate - $builder = [System.Text.StringBuilder]::new() - if ($AddHeader) { - $builder.AppendLine("# Issuer: $($Certificate.Issuer)") | Out-Null - $builder.AppendLine("# Subject: $($Certificate.Subject)") | Out-Null - $builder.AppendLine("# Label: $([regex]::Match($Certificate.Subject, '(?<=CN=)(.)+?(?=,|$)').Value)") | Out-Null - $builder.AppendLine("# Serial: $($Certificate.SerialNumber)") | Out-Null - $builder.AppendLine("# SHA1 Fingerprint: $($Certificate.Thumbprint)") | Out-Null - } - $builder.AppendLine('-----BEGIN CERTIFICATE-----') | Out-Null - for ($i = 0; $i -lt $base64.Length; $i += 64) { - $length = [System.Math]::Min(64, $base64.Length - $i) - $builder.AppendLine($base64.Substring($i, $length)) | Out-Null - } - $builder.AppendLine('-----END CERTIFICATE-----') | Out-Null - # create object with parsed common name and PEM encoded certificate - $pems.Add($builder.ToString().Replace("`r`n", "`n")) - } - - end { - return $pems - } -} - -function Get-Certificate { - [CmdletBinding()] - [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2[]])] - param ( - [Parameter(Mandatory, Position = 0)] - [string]$Uri, - - [switch]$BuildChain, - - [switch]$IgnoreValidation - ) - - begin { - $tcpClient = [System.Net.Sockets.TcpClient]::new($Uri, 443) - if ($BuildChain) { - $chain = [System.Security.Cryptography.X509Certificates.X509Chain]::new() - } - if ($IgnoreValidation) { - $sslStream = [System.Net.Security.SslStream]::new($tcpClient.GetStream(), $false, { $true }) - if ($BuildChain) { - $chain.ChainPolicy.VerificationFlags = [System.Security.Cryptography.X509Certificates.X509VerificationFlags]::AllFlags - } - } else { - $sslStream = [System.Net.Security.SslStream]::new($tcpClient.GetStream()) - } - } - - process { - try { - $sslStream.AuthenticateAsClient($Uri) - $certificate = $sslStream.RemoteCertificate - } finally { - $sslStream.Close() - } - - if ($BuildChain) { - $isChainValid = $chain.Build($certificate) - if ($isChainValid) { - $certificate = $chain.ChainElements.Certificate - } else { - Write-Warning 'SSL certificate chain validation failed.' - } - } - } - - end { - return $certificate - } -} diff --git a/modules/SetupUtils/Functions/common.ps1 b/modules/SetupUtils/Functions/common.ps1 deleted file mode 100644 index 57abef0a..00000000 --- a/modules/SetupUtils/Functions/common.ps1 +++ /dev/null @@ -1,368 +0,0 @@ -function Get-LogMessage { - [CmdletBinding()] - param ( - [Parameter(Mandatory, Position = 0)] - [ValidateNotNullOrEmpty()] - [string]$Message, - - [ValidateSet('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL')] - [string]$Level = 'INFO' - ) - - # calculate message color - $msgColor = switch ($Level) { - DEBUG { "`e[36m" } - INFO { "`e[34m" } - WARNING { "`e[33m" } - ERROR { "`e[31m" } - CRITICAL { "`e[91m" } - } - # calculate message information - $position = "$(Split-Path $MyInvocation.ScriptName -Leaf):$($MyInvocation.ScriptLineNumber)" - $ts = (Get-Date).ToString('s').Replace('T', ' ') - - # print log message - $msg = "`e[32m{0}`e[0m|`e[30m{1}`e[0m|{2} - $msgColor{3}`e[0m" -f $ts, $Level.ToUpper(), $position, $Message - Write-Host $msg -} - -function ConvertFrom-Cfg { - [CmdletBinding()] - [OutputType([System.Collections.Specialized.OrderedDictionary])] - param ( - [Parameter(Mandatory, Position = 0, ParameterSetName = 'FromFile')] - [ValidateScript({ Test-Path $_ -PathType Leaf }, ErrorMessage = "'{0}' is not a valid file path.")] - [string]$Path, - - [Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'FromPipeline')] - [object]$InputObject - ) - - begin { - # instantiate generic list for the configuration content - $cfgList = [System.Collections.Generic.List[string]]::new() - } - - process { - switch ($PsCmdlet.ParameterSetName) { - FromFile { - $content = [System.IO.File]::ReadAllLines((Resolve-Path $Path)) - $content.ForEach({ $cfgList.Add($_) }) - } - FromPipeline { - if ($InputObject) { - $cfgList.Add( $InputObject ) - } - } - } - } - - end { - # build an ordered dictionary from cfg object - $cfg = [ordered]@{} - $header = @() - $section = $null - $CommentCount = 0 - - foreach ($line in $cfgList) { - if (-not $section -and $line -match '^\s*\[(.+)\]') { - # first section encountered; store section header - $section = $matches[1] - $cfg[$section] = [ordered]@{} - continue - } - if (-not $section) { - # before any section header, preserve header comments (only if they are comments) - if ($line -match '^\s*[#;].*') { - $header += $line - } - continue - } - if ($line -match '^\s*\[(.+)\]') { - # new section header encountered - $section = $matches[1] - $cfg[$section] = [ordered]@{} - $CommentCount = 0 - continue - } - elseif ($line -match '^\s*([#;].*)') { - # Comment within section - $CommentCount++ - $name = "Comment$CommentCount" - $cfg[$section][$name] = $matches[1] - continue - } - elseif ($line -match '^\s*(\w+)\s*=(.*)') { - # Key value pair - $name, $value = $matches[1..2] - $cfg[$section][$name] = $value.Trim() - continue - } - } - # store header in special key if any header comments were collected - if ($header.Count -gt 0) { - $cfg['__header__'] = $header -join "`n" - } - return $cfg - } -} - -function ConvertTo-Cfg { - [CmdletBinding()] - param ( - [Parameter(Mandatory, Position = 0, ValueFromPipeline)] - [System.Collections.IDictionary]$OrderedDict, - - [string]$Path, - - [switch]$LineFeed, - - [switch]$Force - ) - - $ErrorActionPreference = 'Stop' - - if (-not $Force -and (Test-Path $Path)) { - Write-Error "$Path destination already exists." - } - - $builder = [System.Text.StringBuilder]::new() - # Restore header comments at the beginning if they exist - if ($OrderedDict.Contains("__header__")) { - $builder.AppendLine($OrderedDict['__header__']) | Out-Null - } - foreach ($enum in $OrderedDict.GetEnumerator()) { - if ($enum.Key -eq '__header__') { continue } - $section = $enum.Key - $builder.AppendLine("`n[$section]") | Out-Null - foreach ($cfg in $enum.Value.GetEnumerator()) { - if ($cfg.Key -like 'Comment*') { - $builder.AppendLine($cfg.Value) | Out-Null - } else { - $builder.AppendLine([string]::Join(' = ', $cfg.Key, $cfg.Value)) | Out-Null - } - } - } - - $content = $builder.ToString().Trim() - if ($LineFeed) { - $content = $content.Replace("`r`n", "`n") - } - if ($Path) { - Set-Content -Value $content -Path $Path - } else { - $content - } -} - -function Get-ArrayIndexMenu { - [CmdletBinding()] - param ( - [Parameter(Mandatory, Position = 0, ValueFromPipeline)] - [object[]]$Array, - - [Parameter(Position = 1)] - [string]$Message, - - [switch]$Value, - - [switch]$List, - - [switch]$AllowNoSelection - ) - begin { - # instantiate generic list to store the input array - $lst = [System.Collections.Generic.List[object]]::new() - } - - process { - # determine if the input array has multiple properties - if (-not $arrayType) { - $arrayType = ($Array | Select-Object * | Get-Member -MemberType NoteProperty).Count -gt 1 ? 'object' : 'string' - } - # add input array items to the generic list - $Array.ForEach({ $lst.Add($_) }) - } - - end { - # return if the input array has less then 2 items - if ($lst.Count -eq 0) { - return - } elseif ($lst.Count -eq 1) { - $indexes = [System.Collections.Generic.HashSet[int]]::new([int[]]0) - } else { - # create selection menu - $menu = switch ($arrayType) { - object { - $i = 0 - $lst ` - | Select-Object @{ N = '#'; E = { $lst.IndexOf($_) } }, @{ N = ' '; E = { '-' } }, * ` - | Format-Table -AutoSize ` - | Out-String -Stream ` - | ForEach-Object { $i -lt 3 ? "`e[1;92m$_`e[0m" : $_; $i++ } ` - | Out-String - continue - } - string { - $lst.ToArray().ForEach({ [PSCustomObject]@{ '#' = $lst.IndexOf($_); ' ' = '-'; 'V' = $_ } }) ` - | Format-Table -AutoSize -HideTableHeaders ` - | Out-String - continue - } - } - - # create prompt message - if (-not $Message) { - $Message = $List ? 'Enter comma/space separated selection list' : 'Enter selection' - } - $msg = "`n`e[4m$Message`e[0m:`n$menu" - - # read and validate input - do { - # instantiate indexes collection - $indexes = [System.Collections.Generic.HashSet[int]]::new() - # prompt for a selection from the input array - (Read-Host -Prompt $msg).Split([char[]]@(' ', ','), [StringSplitOptions]::RemoveEmptyEntries).ForEach({ - try { $indexes.Add($_) | Out-Null } catch { } - } - ) - # calculate stats for returned indexes - $stat = $indexes | Measure-Object -Minimum -Maximum - # evaluate if the Read-Host input is valid - $continue = if ($stat.Count -eq 0) { - $AllowNoSelection - } elseif ($stat.Count -eq 1 -or ($List -and $stat.Count -gt 0)) { - $stat.Minimum -ge 0 -and $stat.Maximum -lt $lst.Count - } else { - $false - } - } until ($continue) - } - - # return result - return $Value ? $indexes.ForEach({ $lst[$_] }) : [int[]]$indexes.ForEach({ $_ }) - } -} - -function Invoke-ExampleScriptSave { - [CmdletBinding()] - param ( - [Parameter(Position = 0)] - [ValidateScript({ Test-Path $_ }, ErrorMessage = "'{0}' is not a valid path.")] - [string]$Path = '.', - - [ValidateScript({ $_.ForEach({ $_ -in @('.ps1', '.py', '.sh') }) -notcontains $false }, - ErrorMessage = 'Wrong extensions provided. Valid values: .ps1, .py, .sh')] - [string[]]$ExtensionFilter = @('.ps1', '.py', '.sh'), - - [ValidateNotNullOrEmpty()] - [string[]]$Exclude = '.', - - [switch]$FolderFromBase, - - [switch]$Force, - - [switch]$WriteOutput - ) - - begin { - # get list of scripts in the specified directory - $scripts = Get-ChildItem $Path -File -Force | Where-Object { - $_.Extension -in $ExtensionFilter -and $_.FullName -notin (Resolve-Path $Exclude -ErrorAction SilentlyContinue).Path - } - # instantiate generic list to store example script(s) name(s) - $lst = [Collections.Generic.List[hashtable]]::new() - if ($scripts) { - # get git root - $gitRoot = git rev-parse --show-toplevel - # add the console folder to .gitignored if necessary - if (-not (Select-String '\bconsole\b' "$gitRoot/.gitignore" -Quiet)) { - [IO.File]::AppendAllLines("$gitRoot/.gitignore", [string[]]'/console/') - } - # determine and create example folder to put example scripts in - $exampleDir = if ($PSBoundParameters.FolderFromBase) { - [IO.Path]::Combine($gitRoot, 'console', $scripts[0].Directory.Name) - } else { - [IO.Path]::Combine($gitRoot, 'console') - } - # create example dir if not exists - if (-not (Test-Path $exampleDir -PathType Container)) { - New-Item $exampleDir -ItemType Directory | Out-Null - } - # script's initial comment regex pattern - $pattern = @{ - '.ps1' = '(?s)(?<=\n\.EXAMPLE\n).*?(?=(\n#>|\n\.[A-Z]))' - '.sh' = "(?s)(?<=\n: '\n).*?(?=\n'\n)" - '.py' = '(?<=^(#.*?\n)?"""\n)((?!""")[\s\S])*(?=\n""")' - } - } else { - return - } - } - - process { - foreach ($script in $scripts) { - $content = [IO.File]::ReadAllText($script) - # get script examples - $example = [regex]::Matches($content, $pattern[$script.Extension]).Value - if ($example) { - # get PowerShell parameters descriptions - if ($script.Extension -eq '.ps1') { - $synopsis = [regex]::Matches($content, '(?s)(?<=\n)\.SYNOPSIS\n(.*?)(?=(\n\.[A-Z]+( \w+)?\n|#>))').Value - $param = [regex]::Matches($content, '(?s)(?<=\n)\.PARAMETER \w+\n(.*?)(?=(\n\.[A-Z]+\n|#>))').Value - } else { - # quote sentences and links - $example = $example ` - -replace '(^|\n)([A-Z].*\.)(\n|$)', '$1# $2$3' ` - -replace '(^|\n)(http.*)(\n|$)', '$1# $2$3' - # clean param variable - $synopsis = $null - $param = $null - } - # calculate example file path - $fileName = $script.Extension -eq '.py' ? "$($script.BaseName)_py.ps1" : $script.Name - # create hashtable that will store the example script path and information if it was saved - $lstItem = @{ path = [IO.Path]::Combine($exampleDir, $fileName) } - # build content string - $builder = [System.Text.StringBuilder]::new() - if ($synopsis -or $param) { - $builder.AppendLine('<#') | Out-Null - if ($synopsis) { $builder.AppendLine($synopsis.Trim()) | Out-Null } - if ($param) { $builder.AppendLine($synopsis ? "`n$($param.Trim())" : $param.Trim()) | Out-Null } - $builder.AppendLine('#>') | Out-Null - if ($example) { $builder.AppendLine('') | Out-Null } - } - if ($example) { - $example.Trim().Split("`n") | Select-String -NotMatch 'ExampleScriptSave' | ForEach-Object { - $builder.AppendLine($_) | Out-Null - } - } - if (-not $PSBoundParameters.Force -and (Test-Path $lstItem.path)) { - $lstItem.saved = $false - } else { - # save the example script - [IO.File]::WriteAllText($lstItem.path, $builder.ToString()) - $lstItem.saved = $true - } - # add item to the list - $lst.Add($lstItem) - } - } - } - - end { - # print list of saved file paths - foreach ($item in $lst) { - if ($WriteOutput) { - return $item.path - } else { - $relPath = ($item.path).Replace($HOME, '~') - if ($item.saved) { - Write-Host "`e[4;94m$relPath`e[0m" - } else { - Write-Host "`e[4;96m$relPath`e[0m" - } - } - } - } -} diff --git a/modules/SetupUtils/SetupUtils.psm1 b/modules/SetupUtils/SetupUtils.psm1 deleted file mode 100644 index e9bbb2ba..00000000 --- a/modules/SetupUtils/SetupUtils.psm1 +++ /dev/null @@ -1,30 +0,0 @@ -$ErrorActionPreference = 'Stop' - -. $PSScriptRoot/Functions/certs.ps1 -. $PSScriptRoot/Functions/common.ps1 -. $PSScriptRoot/Functions/logs.ps1 -. $PSScriptRoot/Functions/wsl.ps1 - -$exportModuleMemberParams = @{ - Function = @( - # certs - 'ConvertFrom-PEM' - 'ConvertTo-PEM' - 'Get-Certificate' - # common - 'Get-LogMessage' - 'ConvertFrom-Cfg' - 'ConvertTo-Cfg' - 'Get-ArrayIndexMenu' - 'Invoke-ExampleScriptSave' - # logs - 'Show-LogContext' - # wsl - 'Get-WslDistro' - 'Set-WslConf' - ) - Variable = @() - Alias = @() -} - -Export-ModuleMember @exportModuleMemberParams diff --git a/modules/aliases-git/Functions/alias.ps1 b/modules/aliases-git/Functions/alias.ps1 new file mode 100644 index 00000000..1ace6336 --- /dev/null +++ b/modules/aliases-git/Functions/alias.ps1 @@ -0,0 +1,2418 @@ +function ga { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git add' @PSBoundParameters +} +function gaa { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git add --all' @PSBoundParameters +} +function gapa { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git add --patch' @PSBoundParameters +} +function gau { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git add --update' @PSBoundParameters +} +function gbl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git blame -b -w' @PSBoundParameters +} +function gb { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git branch' @PSBoundParameters +} +function gba { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git branch --all' @PSBoundParameters +} +function gbnm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git branch --no-merged' @PSBoundParameters +} +function gbr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git branch --remote' @PSBoundParameters +} +function gbsu { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + if ($remote = @(git remote)[0]) { + # calculate command string + $cmnd = "git branch --set-upstream-to=${remote}/$(Get-GitCurrentBranch)" + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + } else { + Write-Host 'fatal: Remote repository not set.' + return + } +} +function gbs { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git bisect' @PSBoundParameters +} +function gbsb { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git bisect bad' @PSBoundParameters +} +function gbsg { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git bisect good' @PSBoundParameters +} +function gbsr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git bisect reset' @PSBoundParameters +} +function gbss { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git bisect start' @PSBoundParameters +} +function gcv { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --verbose' @PSBoundParameters +} +function gc! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --verbose --amend' @PSBoundParameters +} +function gca { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --verbose --all' @PSBoundParameters +} +function gcap { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + gca @PSBoundParameters + + $PSBoundParameters.Remove('Xargs') | Out-Null + gpush @PSBoundParameters +} +function gac { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $PSBoundParameters.Remove('Xargs') | Out-Null + gaa @PSBoundParameters + + gcv -Xargs $Xargs @PSBoundParameters +} +function gacp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + gac @PSBoundParameters + + $PSBoundParameters.Remove('Xargs') | Out-Null + gpush @PSBoundParameters +} +function gca! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --verbose --all --amend' @PSBoundParameters +} +function gac! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $PSBoundParameters.Remove('Xargs') | Out-Null + gaa @PSBoundParameters + + gca! -Xargs $Xargs @PSBoundParameters +} +function gcam { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --all -m' @PSBoundParameters +} +function gcamp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + gcam @PSBoundParameters + + $PSBoundParameters.Remove('Xargs') | Out-Null + gpush @PSBoundParameters +} +function gacm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $PSBoundParameters.Remove('Xargs') | Out-Null + gaa @PSBoundParameters + + gcmsg -Xargs $Xargs @PSBoundParameters +} +function gacmp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + gacm @PSBoundParameters + + $PSBoundParameters.Remove('Xargs') | Out-Null + gpush @PSBoundParameters +} +function gcan! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --verbose --all --no-edit --amend' @PSBoundParameters +} +function gcanp! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + gcan! @PSBoundParameters + + $PSBoundParameters.Remove('Xargs') | Out-Null + gpush! @PSBoundParameters +} +function gcempty { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand 'git commit --allow-empty -m' @PSBoundParameters +} +function gacn! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $PSBoundParameters.Remove('Xargs') | Out-Null + gaa @PSBoundParameters + + gcn! -Xargs $Xargs @PSBoundParameters +} +function gacnp! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + gacn! @PSBoundParameters + + $PSBoundParameters.Remove('Xargs') | Out-Null + gpush! @PSBoundParameters +} +function gcns! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --verbose --signoff --no-edit --amend' @PSBoundParameters +} +function gcans! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --verbose --all --signoff --no-edit --amend' @PSBoundParameters +} +function gacns! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $PSBoundParameters.Remove('Xargs') | Out-Null + gaa @PSBoundParameters + + gcns! -Xargs $Xargs @PSBoundParameters +} +function gcmsg { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit -m' @PSBoundParameters +} +function gcmsgp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + gcmsg @PSBoundParameters + + $PSBoundParameters.Remove('Xargs') | Out-Null + gpush @PSBoundParameters +} +function gcn! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --verbose --no-edit --amend' @PSBoundParameters +} +function gcnp! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + gcn! @PSBoundParameters + + $PSBoundParameters.Remove('Xargs') | Out-Null + gpush! @PSBoundParameters +} +function gcsm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git commit --signoff -m' @PSBoundParameters +} +function gcd { Set-Location $(git rev-parse --show-toplevel 2>$null || '.') } +function gcf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git config' @PSBoundParameters +} +function gcfg { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git config --global' @PSBoundParameters +} +function gcfge { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git config --global --edit' @PSBoundParameters +} +function gcfgl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git config --global --list' @PSBoundParameters +} +function gcfl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git config --local' @PSBoundParameters +} +function gcfle { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git config --local --edit' @PSBoundParameters +} +function gcfll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git config --local --list' @PSBoundParameters +} +function gcl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git clone --recursive' @PSBoundParameters +} +function gclean { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git clean --force -d' @PSBoundParameters +} +function gclean! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $PSBoundParameters.Remove('Xargs') | Out-Null + grh @PSBoundParameters + + gclean -Xargs $Xargs @PSBoundParameters +} +function gpristine { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $PSBoundParameters.Remove('Xargs') | Out-Null + grh @PSBoundParameters + + $Xargs = @('-x') + $Xargs + gclean -Xargs $Xargs @PSBoundParameters +} +function gco { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git checkout' @PSBoundParameters +} +function gcount { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git shortlog --summary --numbered' @PSBoundParameters +} +function gcp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git cherry-pick' @PSBoundParameters +} +function gcpa { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git cherry-pick --abort' @PSBoundParameters +} +function gcpc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git cherry-pick --continue' @PSBoundParameters +} +function gcps { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git cherry-pick --signoff' @PSBoundParameters +} +function gd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git diff' @PSBoundParameters +} +function gdca { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git diff --cached' @PSBoundParameters +} +function gdno { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git diff --name-only' @PSBoundParameters +} +function gdt { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git diff-tree --no-commit-id --name-only -r' @PSBoundParameters +} +function gdw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git diff --word-diff' @PSBoundParameters +} +function gdct { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git describe --tags `git rev-list --tags --max-count=1`' @PSBoundParameters +} +function gf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git fetch' @PSBoundParameters +} +function gfa { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git fetch --all --prune' @PSBoundParameters +} +function gfa! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git fetch --all --tags --prune --prune-tags --force' @PSBoundParameters +} +function gfo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + if ($remote = @(git remote)[0]) { + Invoke-WriteExecCommand -Command "git fetch $remote" @PSBoundParameters + } else { + Write-Host 'fatal: Remote repository not set.' + } +} +function gg { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git grep --ignore-case' @PSBoundParameters +} +function ggc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git gc' @PSBoundParameters +} +function ggca { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git gc --aggressive' @PSBoundParameters +} +function gge { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git grep --ignore-case --extended-regexp' @PSBoundParameters +} +function ggp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git grep --ignore-case --perl-regexp' @PSBoundParameters +} +function ghh { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git help' @PSBoundParameters +} +function gignore { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git update-index --assume-unchanged' @PSBoundParameters +} +function gignored { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git ls-files -v | Select-String "^[a-z]" -CaseSensitive' @PSBoundParameters +} +function glo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --date=rfc' @PSBoundParameters +} +function gloa { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --date=rfc --all' @PSBoundParameters +} +function glog { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --date=rfc --graph' @PSBoundParameters +} +function gloga { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --date=rfc --graph --decorate --all' @PSBoundParameters +} +function glol { + # command string + $cmnd = 'git log --graph --pretty="%C(yellow)%h%C(reset) %C(green)(%cr)%C(reset)%C(red)%d%C(reset) %s %C(bold blue)<%an>%C(reset)" --abbrev-commit' + # run command + Invoke-WriteExecCommand -Command $cmnd -Quiet +} +function glola { + # command string + $cmnd = 'git log --graph --pretty="%C(yellow)%h%C(reset) %C(green)(%cr)%C(reset)%C(red)%d%C(reset) %s %C(bold blue)<%an>%C(reset)" --abbrev-commit --all' + # run command + Invoke-WriteExecCommand -Command $cmnd -Quiet +} +function glon { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --oneline --decorate' @PSBoundParameters +} +function glona { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --oneline --decorate --all' @PSBoundParameters +} +function glong { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --oneline --decorate --graph' @PSBoundParameters +} +function glonga { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --oneline --decorate --graph --all' @PSBoundParameters +} +function glont { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --oneline --decorate --no-walk --tags="*"' @PSBoundParameters +} +function glop { + # command string + $cmnd = 'git log --pretty=format:"%C(yellow)%h%C(reset) %C(green)(%ai)%C(reset)%C(red)%d%C(reset) %s %C(bold blue)<%ae>%C(reset)" --abbrev-commit' + # run command + Invoke-WriteExecCommand -Command $cmnd -Quiet +} +function glopa { + # command string + $cmnd = 'git log --pretty=format:"%C(yellow)%h%C(reset) %C(green)(%ai)%C(reset)%C(red)%d%C(reset) %s %C(bold blue)<%ae>%C(reset)" --abbrev-commit --all' + # run command + Invoke-WriteExecCommand -Command $cmnd -Quiet +} +function glos { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --date=rfc --stat' @PSBoundParameters +} +function glosa { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --date=rfc --stat --all' @PSBoundParameters +} +function glosp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --date=rfc --stat --patch' @PSBoundParameters +} +function glospa { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git log --date=rfc --stat --patch --all' @PSBoundParameters +} +function gmt { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git mergetool --no-prompt' @PSBoundParameters +} +function gmtvim { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git mergetool --no-prompt --tool=vimdiff' @PSBoundParameters +} +function gpl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + if ($remote = @(git remote)[0]) { + # calculate command string + $cmnd = "git pull $remote $(Get-GitCurrentBranch) --tags --prune" + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + } else { + Write-Host 'fatal: Remote repository not set.' + } +} +function gpl! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $PSBoundParameters.Xargs = @('--force') + $Xargs + gpl @PSBoundParameters +} +function gpull { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git pull' @PSBoundParameters +} +function gpullr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git pull --rebase' @PSBoundParameters +} +function gpullra { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git pull --rebase --autostash' @PSBoundParameters +} +function gpullrav { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git pull --rebase --autostash --verbose' @PSBoundParameters +} +function gpullrv { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git pull --rebase --verbose' @PSBoundParameters +} +function gpush { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git push' @PSBoundParameters +} +function gpush! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git push --force-with-lease' @PSBoundParameters +} +function gpushdr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git push --dry-run' @PSBoundParameters +} +function gpushoat { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + if ($remote = @(git remote)[0]) { + # calculate command string + $cmnd = "git push $remote --all && git push $remote --tags" + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + } else { + Write-Host 'fatal: Remote repository not set.' + } +} +function gpushsup { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command "git push --set-upstream origin $(Get-GitCurrentBranch)" @PSBoundParameters +} +function gpusht { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git push --tags' @PSBoundParameters +} +function gpusht! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git push --tags --force' @PSBoundParameters +} +function gpushv { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git push --verbose' @PSBoundParameters +} +function grba { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git rebase --abort' @PSBoundParameters +} +function grbc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git rebase --continue' @PSBoundParameters +} +function grbi { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git rebase --interactive' @PSBoundParameters +} +function grbs { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git rebase --skip' @PSBoundParameters +} +function gr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git reset' @PSBoundParameters +} +function grh { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git reset --hard' @PSBoundParameters +} +function grho { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + if ($remote = @(git remote)[0]) { + $PSBoundParameters.Remove('Xargs') | Out-Null + $cmnd = "git fetch $remote --tags --prune --prune-tags --force" + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + + $cmnd = "git reset --hard $remote/$(Get-GitCurrentBranch)" + Invoke-WriteExecCommand -Command $cmnd -Xargs $Xargs @PSBoundParameters + } else { + Write-Host 'fatal: Remote repository not set.' + } +} +function grho! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + grho @PSBoundParameters + + git clean --force -d +} +function grs { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git reset --soft' @PSBoundParameters +} +function grl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git reflog' @PSBoundParameters +} +function grmc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git rm --cached' @PSBoundParameters +} +function grm! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git rm --force' @PSBoundParameters +} +function grmrc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git rm -r --cached' @PSBoundParameters +} +function grmr! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git rm -r --force' @PSBoundParameters +} +function grp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git rev-parse' @PSBoundParameters +} +function grr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git restore' @PSBoundParameters +} +function grrsrc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git restore --source' @PSBoundParameters +} +function grrstg { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git restore --staged' @PSBoundParameters +} +function grrstga { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git restore --staged .' @PSBoundParameters +} +function grt { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git remote' @PSBoundParameters +} +function grta { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git remote add' @PSBoundParameters +} +function grtrm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git remote remove' @PSBoundParameters +} +function grtrn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git remote rename' @PSBoundParameters +} +function grtsu { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git remote set-url' @PSBoundParameters +} +function grtup { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + if ($remote = @(git remote)[0]) { + # calculate command string + $cmnd = "git remote update $remote" + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + } else { + Write-Host 'fatal: Remote repository not set.' + } +} +function grtupp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + if ($remote = @(git remote)[0]) { + # calculate command string + $cmnd = "git remote update $remote --prune" + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + } else { + Write-Host 'fatal: Remote repository not set.' + } +} +function grtv { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git remote --verbose' @PSBoundParameters +} +function grturl { + (git remote get-url origin) -replace '^git@(.+?):', 'https://$1/' -replace '\.git$' +} +function grturlb { + $url = (git remote get-url origin) -replace '^git@(.+?):', 'https://$1/' -replace '\.git$' + $branch = git branch --show-current + "$url/tree/$branch" +} +function gswc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git switch --create' @PSBoundParameters +} +function gswd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git switch --detach' @PSBoundParameters +} +function gswo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git switch --orphan' @PSBoundParameters +} +function gsmi { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git submodule init' @PSBoundParameters +} +function gsmu { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git submodule update' @PSBoundParameters +} +function gsps { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git show --pretty=short --show-signature' @PSBoundParameters +} +function gsta { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git stash push' @PSBoundParameters +} +function gstaa { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git stash push --all' @PSBoundParameters +} +function gstac { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git stash clear' @PSBoundParameters +} +function gstal { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git stash list' @PSBoundParameters +} +function gstap { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git stash pop' @PSBoundParameters +} +function gst { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git status' @PSBoundParameters +} +function gstb { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git status --short --branch' @PSBoundParameters +} +function gsts { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git status --short' @PSBoundParameters +} +function gsvnd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git svn dcommit' @PSBoundParameters +} +function gsvnr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git svn rebase' @PSBoundParameters +} +function gt { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git tag --sort=-v:refname' @PSBoundParameters +} +function gts { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git tag --sign' @PSBoundParameters +} +function gtr { + # command string + $cmnd = "git for-each-ref refs/tags/ --sort=-v:refname --format='%1B[33m%(objectname:short)%1B[m %1B[31m%(refname:short)%1B[m %(subject) %1B[1;94m%(authorname)%1B[m %1B[36m%(authoremail)%1B[m'" + # run command + Invoke-WriteExecCommand -Command $cmnd -Quiet +} +function gunignore { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git update-index --no-assume-unchanged' @PSBoundParameters +} +function gwch { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'git whatchanged -p --abbrev-commit --pretty=medium' @PSBoundParameters +} diff --git a/modules/aliases-git/Functions/completers.ps1 b/modules/aliases-git/Functions/completers.ps1 new file mode 100644 index 00000000..4147b9ae --- /dev/null +++ b/modules/aliases-git/Functions/completers.ps1 @@ -0,0 +1,40 @@ +<# +.SYNOPSIS +Get list of git branches for the function ArgumentCompleter attribute. +#> +function ArgGitGetBranches { + param ( + $commandName, + $parameterName, + $wordToComplete, + $commandAst, + $fakeBoundParameters + ) + + # get list of all branches + $branches = git branch --all --format='%(refname:short)' + # build remote names filter + $remoteFilter = [string]::Join('|', (git remote).ForEach({ "$_/?(HEAD)?" })) + # filter list of branches + [string[]]$possibleValues = $branches -replace $remoteFilter ` + | Where-Object { $_ } ` + | Sort-Object -Unique + + # return matching branches + $possibleValues.Where({ $_ -like "$wordToComplete*" }).ForEach({ $_ }) +} +function ArgGitGetStashList { + param ( + $commandName, + $parameterName, + $wordToComplete, + $commandAst, + $fakeBoundParameters + ) + + # get list of stashes + $possibleValues = (git stash list).ForEach({ "'$($_.Split(':')[0])'" }) + + # return matching branches + $possibleValues.Where({ $_ -like "'stash@{$wordToComplete*" }).ForEach({ $_ }) +} diff --git a/modules/aliases-git/Functions/gh.ps1 b/modules/aliases-git/Functions/gh.ps1 new file mode 100644 index 00000000..1d0fad79 --- /dev/null +++ b/modules/aliases-git/Functions/gh.ps1 @@ -0,0 +1,350 @@ +# *issue +function ghil { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh issue list' @PSBoundParameters +} +function ghiv { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh issue view' @PSBoundParameters +} +# *pr +function ghprc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr create' @PSBoundParameters +} +function ghprcf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr create --fill' @PSBoundParameters +} +function ghprco { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr checkout' @PSBoundParameters +} +function ghprd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr diff' @PSBoundParameters +} +function ghprl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr list' @PSBoundParameters +} +function ghprm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr merge' @PSBoundParameters +} +function ghprmd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr merge --delete-branch' @PSBoundParameters +} +function ghprr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr ready' @PSBoundParameters +} +function ghprs { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr status' @PSBoundParameters +} +function ghprurl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command "gh pr view --json url --jq '.url'" @PSBoundParameters +} +function ghprv { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr view' @PSBoundParameters +} +function ghprck { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh pr checks' @PSBoundParameters +} +# *repo +function ghrv { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh repo view' @PSBoundParameters +} +function ghrcl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh repo clone' @PSBoundParameters +} +function ghrfk { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh repo fork' @PSBoundParameters +} +function ghrsy { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh repo sync' @PSBoundParameters +} +# *run +function ghrnl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh run list' @PSBoundParameters +} +function ghrnv { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh run view' @PSBoundParameters +} +function ghrnw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh run watch' @PSBoundParameters +} +function ghrnrr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh run rerun' @PSBoundParameters +} +# *status +function ghst { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecCommand -Command 'gh status' @PSBoundParameters +} diff --git a/modules/aliases-git/Functions/helper.ps1 b/modules/aliases-git/Functions/helper.ps1 new file mode 100644 index 00000000..84cb03cb --- /dev/null +++ b/modules/aliases-git/Functions/helper.ps1 @@ -0,0 +1,554 @@ +#region helper git branch delete functions +function gbd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0, Mandatory)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command string + $cmnd = "git branch --delete $Branch" + $PSBoundParameters.Remove('Branch') | Out-Null + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +function gbd! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0, Mandatory)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command string + $cmnd = "git branch -D $Branch" + $PSBoundParameters.Remove('Branch') | Out-Null + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +function gbdo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0, Mandatory)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command strings + if ($remote = @(git remote)[0]) { + $commands = [System.Collections.Generic.List[string]]::new() + $commands.Add("git branch --delete $Branch") + $commands.Add("git push --delete $remote $Branch") + $PSBoundParameters.Remove('Branch') | Out-Null + } else { + Write-Host 'fatal: Remote repository not set.' + return + } + + # run commands + foreach ($cmnd in $commands) { + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + } +} +function gbdo! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0, Mandatory)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command strings + if ($remote = @(git remote)[0]) { + $commands = [System.Collections.Generic.List[string]]::new() + $commands.Add("git branch -D $Branch") + $commands.Add("git push --delete $remote $Branch") + $PSBoundParameters.Remove('Branch') | Out-Null + } else { + Write-Host 'fatal: Remote repository not set.' + return + } + + # run commands + foreach ($cmnd in $commands) { + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + } +} +function gbdl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + Remove-GitLocalBranches @PSBoundParameters +} +function gbdl! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + Remove-GitLocalBranches -DeleteNoMerged @PSBoundParameters +} +function gbdm { + Remove-GitMergedBranches +} +function gbdm! { + Remove-GitMergedBranches -DeleteRemote +} +function gpushd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0, Mandatory)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + if ($remote = @(git remote)[0]) { + # calculate command string + $cmnd = "git push --delete $remote $Branch" + $PSBoundParameters.Remove('Branch') | Out-Null + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + } else { + Write-Host 'fatal: Remote repository not set.' + } +} +#endregion + + +#region helper merge/rebase functions +function gmg { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command string + $rmt, $br = $Branch.Split('/', 2) + $resolvedBranch = if ($rmt -in (git remote)) { + "${rmt}/$(Get-GitResolvedBranch $br)" + } else { + Get-GitResolvedBranch $Branch + } + $cmnd = "git merge $resolvedBranch" + $PSBoundParameters.Remove('Branch') | Out-Null + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +function gmgo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command strings + if ($remote = @(git remote)[0]) { + # get current branch + $currentBranch = git branch --show-current + # resolve provided branch + $resolvedBranch = Get-GitResolvedBranch $Branch + $PSBoundParameters.Remove('Branch') | Out-Null + # build list of commands to execute + Invoke-WriteExecCommand -Command "git fetch $remote --prune" @PSBoundParameters + if ($currentBranch -ne $resolvedBranch) { + Invoke-WriteExecCommand -Command "git merge ${remote}/${currentBranch} --quiet" @PSBoundParameters + } + Invoke-WriteExecCommand -Command "git merge ${remote}/${resolvedBranch}" @PSBoundParameters | Tee-Object -Variable merge + if ($merge | Select-String 'Fast-forward' -Quiet) { + Invoke-WriteExecCommand -Command "git push ${remote}" @PSBoundParameters + } + } else { + Write-Host 'fatal: Remote repository not set.' + } +} +function grb { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command string + $rmt, $br = $Branch.Split('/', 2) + $resolvedBranch = if ($rmt -in (git remote)) { + "${rmt}/$(Get-GitResolvedBranch $br)" + } else { + Get-GitResolvedBranch $Branch + } + $cmnd = "git rebase $resolvedBranch" + $PSBoundParameters.Remove('Branch') | Out-Null + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +function grbo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command strings + if ($remote = @(git remote)[0]) { + # get current branch + $currentBranch = git branch --show-current + # resolve provided branch + $resolvedBranch = Get-GitResolvedBranch $Branch + $PSBoundParameters.Remove('Branch') | Out-Null + # build list of commands to execute + $commands = [System.Collections.Generic.List[string]]::new() + $commands.Add("git fetch $remote --prune") + if ($currentBranch -ne $resolvedBranch) { + $commands.Add("git rebase ${remote}/${currentBranch} --quiet") + } + $commands.Add("git rebase ${remote}/${resolvedBranch}") + } else { + Write-Host 'fatal: Remote repository not set.' + return + } + + # run commands + foreach ($cmnd in $commands) { + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters + } + # check if rebase was successful and push changes + $behind, $ahead = (git rev-list --count --left-right '@{u}...HEAD') -split "`t" + if ($? -and $behind -eq 0 -and $ahead -gt 0) { + Invoke-WriteExecCommand -Command "git push ${remote}" @PSBoundParameters + } +} +function gmb { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command string + $cmnd = "git merge-base $(Get-GitResolvedBranch $Branch) HEAD" + $PSBoundParameters.Remove('Branch') | Out-Null + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +function grmb { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command string + $cmnd = "git reset `$(git merge-base $(Get-GitResolvedBranch $Branch) HEAD)" + $PSBoundParameters.Remove('Branch') | Out-Null + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +#endregion + + +#region helper grun functions +<# +.DESCRIPTION +Alias functions using the Invoke-GitRepoCommand internal function that runs specified git commands in the current repo, +or all repos located in subdirectories of the current folder. +Function runs only in repositories with remote set. +#> + +<# +.SYNOPSIS +Invoke-GitRepoCommand alias function. + +.PARAMETER cmd +Script block of commands to execute. +#> +function grunrepocmd ([scriptblock]$cmd) { + Invoke-GitRepoCommand -Command $cmd +} + + +<# +.SYNOPSIS +Refresh all git repositories in subdirectories of the current folder. +#> +function grunrefresh { + # prepare commands to execute + $cmd = { + # calculate arguments + $defaultBranch = Get-GitResolvedBranch + $remote = @(git remote)[0] + + # run git commands + git fetch --all --tags --prune --prune-tags --force + $switch = Invoke-WriteExecCommand -Command "git switch $defaultBranch" + # run commands if switched branch successfully + if ($?) { + if ($switch -ne "Your branch is up to date with '$remote/$defaultBranch'.") { + Invoke-WriteExecCommand -Command "git merge ${remote}/${defaultBranch}" + } + Remove-GitMergedBranches + } + } + # run git repository command + Invoke-GitRepoCommand -Command $cmd +} + + +<# +.SYNOPSIS +Set git local settings in all git repositories. + +.PARAMETER Option +Git local setting option. +.PARAMETER Value +Git local setting value. +#> +function gruncfl { + param ( + [Parameter(Mandatory, Position = 0)] + [ValidateNotNullOrEmpty()] + [string]$Option, + + [Parameter(Mandatory, Position = 1)] + [ValidateNotNullOrEmpty()] + [string]$Value + ) + + $cmd = { + git config --local $Option $Value + Write-Host "${Option}: $(git config --local $Option)" + } + Invoke-GitRepoCommand -Command $cmd +} +#endregion + + +#region git stash functions +function gstaap { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [ArgumentCompleter({ ArgGitGetStashList @args })] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # command string + $cmnd = 'git stash apply --force' + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +function gstad { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [ArgumentCompleter({ ArgGitGetStashList @args })] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # command string + $cmnd = 'git stash drop' + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +function gstas { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [ArgumentCompleter({ ArgGitGetStashList @args })] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # command string + $cmnd = 'git stash show' + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +function gstast { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [ArgumentCompleter({ ArgGitGetStashList @args })] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # command string + $cmnd = 'git stash show --text' + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +#endregion + + +#region helper switch functions +function gsw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command string + $cmnd = "git switch $(Get-GitResolvedBranch $Branch)" + $PSBoundParameters.Remove('Branch') | Out-Null + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +function gsw! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgGitGetBranches @args })] + [string]$Branch, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # calculate command string + $cmnd = "git switch $(Get-GitResolvedBranch $Branch) --force" + $PSBoundParameters.Remove('Branch') | Out-Null + # run command + Invoke-WriteExecCommand -Command $cmnd @PSBoundParameters +} +#endregion diff --git a/modules/aliases-git/Functions/internal.ps1 b/modules/aliases-git/Functions/internal.ps1 new file mode 100644 index 00000000..9a1a08aa --- /dev/null +++ b/modules/aliases-git/Functions/internal.ps1 @@ -0,0 +1,467 @@ +<# +.SYNOPSIS +Get git log object. + +.PARAMETER Xargs +Additional arguments to pass to the git log command. +#> +function Get-GitLogObject { + [CmdletBinding()] + param ( + [switch]$All, + + [switch]$Grep, + + [switch]$Limit, + + [switch]$Tags, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + begin { + #region build arguments list + # build git log command arguments + $cmdArgs = [System.Collections.Generic.List[string]]::new( + [string[]]@( + '--reverse' + "--pretty=format:%h`f%ai`f%s`f%an`f%ae`f%D" + ) + ) + # limit result to 30 + if ($PSBoundParameters.Limit -and $PSBoundParameters.Xargs -notmatch '^(-?\d+)$') { + $cmdArgs.Add('-30') + } + # return commits from all branches + if ($PSBoundParameters.All) { + $cmdArgs.Add('--all') + } + # add additional grep filter parameters + if ($PSBoundParameters.Grep) { + $cmdArgs.AddRange( + [string[]]@( + '--perl-regexp' + '--regexp-ignore-case' + ) + ) + } + # return tags only + if ($PSBoundParameters.Tags) { + $cmdArgs.AddRange( + [string[]]@( + '--tags=*' + '--no-walk' + ) + ) + } + # parse Xargs for count specification + $parsedXargs = if ($PSBoundParameters.Xargs -match '^0$') { + $Xargs -notmatch '^0$' + } elseif ($PSBoundParameters.Xargs -match '^\d+$') { + $Xargs -replace '^\d+$', "-`$&" + } else { + $Xargs + } + + if ($parsedXargs) { + $cmdArgs.AddRange([string[]]$parsedXargs) + } + #endregion + + #region specify headers and output parameters + # specify CSV headers + $headers = @( + 'Commit' + 'Date' + 'Subject' + 'Author' + 'Email' + 'Ref' + ) + # property selection + $prop = @( + 'Commit' + @{ Name = 'DateUTC'; Expression = { [TimeZoneInfo]::ConvertTimeToUtc($_.Date).ToString('s').Replace('T', ' ') } } + 'Subject' + 'Author' + 'Email' + 'Ref' + ) + #endregion + } + + process { + # show the expression + Write-Verbose "git log $cmdArgs".Replace("`f", ' ').Replace('%h', '"$h').Replace('%D', '$D"') + # run git log and convert output to objects + $result = git log @cmdArgs | ConvertFrom-Csv -Delimiter "`f" -Header $headers | Select-Object -Property $prop + } + + end { + return $result + } +} + + +<# +.SYNOPSIS +Get git reflog object. + +.PARAMETER Xargs +Additional arguments to pass to the git reflog command. +#> +function Get-GitReflogObject { + [CmdletBinding()] + param ( + [switch]$Limit, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + begin { + #region build arguments list + # build git reflog command arguments + $cmdArgs = [System.Collections.Generic.List[string]]::new( + [string[]]@( + "--format=%h`f%gd`f%ai`f%gs`f%an`f%ae`f%D" + ) + ) + # limit result to 30 + if ($PSBoundParameters.Limit -and $PSBoundParameters.Xargs -notmatch '^(-?\d+)$') { + $cmdArgs.Add('-30') + } + # parse Xargs for count specification + $parsedXargs = if ($PSBoundParameters.Xargs -match '^0$') { + $Xargs -notmatch '^0$' + } elseif ($PSBoundParameters.Xargs -match '^\d+$') { + $Xargs -replace '^\d+$', "-`$&" + } else { + $Xargs + } + + if ($parsedXargs) { + $cmdArgs.AddRange([string[]]$parsedXargs) + } + #endregion + + #region specify headers and output parameters + # specify CSV headers + $headers = @( + 'Commit' + 'Selector' + 'Date' + 'Subject' + 'Author' + 'Email' + 'Ref' + ) + # property selection + $prop = @( + 'Commit' + 'Selector' + @{ Name = 'DateUTC'; Expression = { [TimeZoneInfo]::ConvertTimeToUtc($_.Date).ToString('s').Replace('T', ' ') } } + 'Subject' + 'Author' + 'Email' + 'Ref' + ) + #endregion + } + + process { + # show the expression + Write-Verbose "git reflog $cmdArgs".Replace("`f", ' ').Replace('%h', '"$h').Replace('%D', '$D"') + # run git reflog and convert output to objects, reverse to show oldest first + [array]$result = git reflog @cmdArgs | ConvertFrom-Csv -Delimiter "`f" -Header $headers | Select-Object -Property $prop + [array]::Reverse($result) + } + + end { + return $result + } +} + + +<# +.SYNOPSIS +Get last git commit message. + +.PARAMETER First +Switch whether to return only the first line of the commit message. +#> +function Get-GitLogMessage ([switch]$First) { + # get the last commit message + $msg = (git log -1 --pretty=%B).ForEach({ "$_".Trim() }).Where({ $_ }) + + # return first line or full message + if ($PSBoundParameters.First) { + $msg | Select-Object -First 1 + } else { + $msg -join ' ' + } +} + +<# +.SYNOPSIS +Write provided command with its arguments and then execute it. +You can suppress writing the command by providing -Quiet as one of the arguments. +You can suppress executing the command by providing -WhatIf as one of the arguments. + +.PARAMETER Command +Command to be executed. +.PARAMETER Xargs +Command arguments to be passed to the provided command. +.PARAMETER WhatIf +Do not execute the command. +.PARAMETER Quiet +Do not print the command string. +#> +function Invoke-WriteExecCommand { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$Command, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + begin { + # build command + $sb = [System.Text.StringBuilder]::new($Command) + if ($PSBoundParameters.Xargs) { + $Xargs | ForEach-Object { + $arg = $_ -match '\s|@' ? "'$_'" : $_ + $sb.Append(" $arg") | Out-Null + } + } + # get command string + $cmnd = $sb.ToString() + } + + process { + if (-not $PSBoundParameters.Quiet) { + # write command + Write-Host $cmnd -ForegroundColor Magenta + } + if (-not $PSBoundParameters.WhatIf) { + # execute command + return Invoke-Expression $cmnd + } + } +} + + +<# +.SYNOPSIS +Get current branch name. +#> +function Get-GitCurrentBranch { + git branch --show-current +} + + +<# +.SYNOPSIS +Resolve main, dev, stage branch names. + +.PARAMETER BranchName +Name of the branch to switch to. +#> +function Get-GitResolvedBranch { + [CmdletBinding()] + param ( + [string[]]$BranchName + ) + + if (git rev-parse --is-inside-work-tree) { + # build remote names filter + filter remoteFilter { + "$_".Trim() -replace [string]::Join('|', (git remote).ForEach({ "$_/?" })) | Where-Object { $_ } + } + [string]$BranchName = $BranchName | remoteFilter + $match = @{ + d = @('^dev(|el|elop|elopment)$') + m = @('^ma(in|ster)$') + p = @('^prod(uction)?$') + s = @('^st(g|age|aging)$') + t = @('^trunk$') + } + $branchMatch = switch ($BranchName) { + '' { $match.m + $match.p + $match.s + $match.d + $match.t; break } + d { $match.d; break } + m { $match.m; break } + p { $match.p; break } + s { $match.s; break } + t { $match.t; break } + default { @("^$BranchName$") } + } + Write-Verbose "BranchMatch: $($branchMatch -join ', ')" + # instantiate collections + $matched = [System.Collections.Generic.HashSet[string]]::new() + } else { + break + } + + # get list of branches + $branches = git branch --all --format='%(refname:short)' | remoteFilter | Sort-Object -Unique + # match branches + foreach ($match in $branchMatch) { + $branches.Where({ $_ -match $match }).ForEach({ $matched.Add($_) | Out-Null }) + } + Write-Verbose "Matched branches: $($matched -join ', ')" + + if ($matched.Count -eq 0) { + if ($BranchName) { + Write-Warning "Invalid reference: '$BranchName'. Valid reference values are: `e[0;1m$([string]::Join(', ', $branches))`e[0m" + break + } else { + $matched = Get-GitCurrentBranch + } + } + + return $matched | Select-Object -First 1 +} + + +<# +.SYNOPSIS +Delete local branches. +.DESCRIPTION +If DeleteNoMerged parameter is not specified, all local merged branches will be deleted. + +.PARAMETER DeleteNoMerged +Switch whether to delete non merged branches. +#> +function Remove-GitLocalBranches { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [switch]$DeleteNoMerged, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + begin { + # remove DeleteNoMerged from PSBoundParameters + $PSBoundParameters.Remove('DeleteNoMerged') | Out-Null + # switch to dev/main branch + git switch $(Get-GitResolvedBranch) --quiet + # update remote + git remote update --prune + # instantiate sorted set for branches to delete + $branches = [System.Collections.Generic.SortedSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase) + $regex = '^(ma(in|ster)|(non)?prod(uction)?|dev(|el|elop|elopment)|qa|stag(e|ing)|trunk|docs)$' + filter branchFilter { $_.Where({ $_ -notmatch $regex }) } + } + + process { + # add merged branches + git branch --format='%(refname:short)' --merged | branchFilter | ForEach-Object { $branches.Add($_) | Out-Null } + # add branches with gone upstream (e.g. squash-merged PRs) + git branch --format='%(refname:short) %(upstream:track)' | ForEach-Object { + if ($_ -match '^(\S+)\s+\[gone\]$') { $Matches[1] } + } | branchFilter | ForEach-Object { $branches.Add($_) | Out-Null } + # delete merged and gone branches + foreach ($branch in $branches) { + Invoke-WriteExecCommand -Command "git branch -D $branch" @PSBoundParameters + } + if ($DeleteNoMerged) { + $no_merged = git branch --format='%(refname:short)' --no-merged | branchFilter + foreach ($branch in $no_merged) { + if ((Read-Host -Prompt "Do you want to remove branch: `e[1;97m$branch`e[0m? [y/N]") -eq 'y') { + Invoke-WriteExecCommand -Command "git branch -D $branch" @PSBoundParameters + } + } + } + } +} + + +<# +.SYNOPSIS +Delete merged branches. + +.PARAMETER DeleteRemote +Switch whether to delete remote merged branches. +#> +function Remove-GitMergedBranches { + param ( + [switch]$DeleteRemote + ) + + # remove local merged and gone branches + Remove-GitLocalBranches -Quiet + + # remove remote merged branches + if ($DeleteRemote) { + $regex = '^(ma(in|ster)|(non)?prod(uction)?|dev(|el|elop|elopment)|qa|stag(e|ing)|trunk|docs)$' + [string[]]$remotes = git remote + $remoteFilter = $remotes.ForEach({ "^$_/" }) | Join-String -Separator '|' + $knownFilter = "($remoteFilter)($($regex.Replace('^', '')))" + filter remoteFilter { $_.Where({ $_ -match $remoteFilter -and $_ -notmatch $knownFilter }) } + [string[]]$mergedRemote = git branch --remotes --format='%(refname:short)' --merged | remoteFilter + foreach ($remote in $remotes) { + $mergedRemote | Select-String "^$remote/(.*)" | ForEach-Object { + git push --delete $remote $_.Matches.Groups[1].Value + } + } + } +} + + +<# +.SYNOPSIS +Run specified git commands in a current repo or all repos located in subdirectories of the current folder. +Function runs only for repositories with remote set. + +.PARAMETER Command +Script block of commands to execute. +#> +function Invoke-GitRepoCommand { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0, HelpMessage = 'The command to be invoked.')] + [scriptblock]$Command + ) + + Push-Location + # instantiate list for storing git directories with remote set + $dirs = [System.Collections.Generic.List[System.IO.DirectoryInfo]]::new() + + # check if in git repo + $isGitRepo = git rev-parse --is-inside-work-tree 2>$null && $true || $false + # build list of directories with remote set + if ($isGitRepo) { + (git remote) ? $dirs.Add($(Get-Item .)) : $null + } else { + Get-ChildItem -Directory | ForEach-Object { + (git -C $_.FullName remote 2>$null) ? $dirs.Add($_) : $null + } + } + + # iterate over all git repos with remote set + foreach ($dir in $dirs) { + Set-Location $dir + # set line separator for printing the following results + $follow = $dir -eq $dirs[0] ? '' : "`n" + if ($dirs.Count -gt 1) { + Write-Host "$follow$($dir.Name)" -ForegroundColor Cyan + } + # execute commands + Invoke-Command -ScriptBlock $Command + } + + Pop-Location +} diff --git a/modules/aliases-git/Functions/log.ps1 b/modules/aliases-git/Functions/log.ps1 new file mode 100644 index 00000000..092b4e41 --- /dev/null +++ b/modules/aliases-git/Functions/log.ps1 @@ -0,0 +1,301 @@ +#region alias +Set-Alias -Name gglobj -Value Get-GitLogObject -Scope Global +Set-Alias -Name grlobj -Value Get-GitReflogObject -Scope Global +#endregion + + +#region helper git log functions +<# +.SYNOPSIS +Get-GitLogObject function aliases. +#> +function gglogs { + [CmdletBinding()] + param ( + [switch]$All, + + [switch]$Grep, + + [switch]$Limit, + + [switch]$Tags, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + Get-GitLogObject @PSBoundParameters | Select-Object Commit, DateUTC, Subject, Author +} + + +function gglo { + [CmdletBinding()] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + gglogs @PSBoundParameters -Limit +} + + +function ggloa { + [CmdletBinding()] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + gglogs @PSBoundParameters -Limit -All +} +#endregion + + +#region helper git log colored functions +<# +.SYNOPSIS +Get-GitLogObject function colored aliases. +#> +function gglogc { + [CmdletBinding()] + param ( + [switch]$All, + + [switch]$Grep, + + [switch]$Limit, + + [switch]$Tags, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + # build properties for Format-Table + $refCmd = { + $refs = switch -Regex ($_.Ref.Split(',').Trim().Where({ $_ -ne 'origin/HEAD' })) { + '^tag:' { "`e[1;93m$($_ -replace '^tag: ')`e[0m" } + '^origin/' { "`e[1;91m$_`e[0m" } + '^HEAD' { "`e[1;96mHEAD -> `e[92m$($_ -replace 'HEAD -> ')`e[0m" } + Default { "`e[1;92m$_`e[0m" } + } + $([string]::Join(', ', $refs)) + } + $prop = @( + @{ Name = 'Commit'; Expression = { "`e[33m$($_.Commit)`e[0m" } } + @{ Name = 'DateUTC'; Expression = { "`e[32m$($_.DateUTC)`e[0m" } } + @{ Name = 'Subject'; Expression = { $_.Subject.Substring(0, [Math]::Min(59, $_.Subject.Length)) } } + @{ Name = 'Author'; Expression = { "`e[94;1m$($_.Author)`e[0m" } } + @{ Name = 'Email'; Expression = { "`e[34;3m$($_.Email -match 'users.noreply.github.com' ? 'noreply@github.com' : $_.Email)`e[0m" } } + @{ Name = 'Ref'; Expression = $refCmd } + ) + + Get-GitLogObject @PSBoundParameters | Format-Table -Property $prop -Wrap +} + + +function ggloc { + [CmdletBinding()] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + gglogc @PSBoundParameters -Limit +} + + +function ggloca { + [CmdletBinding()] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + gglogc @PSBoundParameters -Limit -All +} + + +function gglot { + [CmdletBinding()] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + gglogc @PSBoundParameters -Limit -Tags +} +#endregion + + + +#region helper git reflog functions +<# +.SYNOPSIS +Get-GitReflogObject function aliases. +#> +function grlogs { + [CmdletBinding()] + param ( + [switch]$Limit, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + Get-GitReflogObject @PSBoundParameters | Select-Object Commit, Selector, DateUTC, Subject, Author, Ref +} + + +function grlo { + [CmdletBinding()] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + grlogs @PSBoundParameters -Limit +} +#endregion + + +#region helper git reflog colored functions +<# +.SYNOPSIS +Get-GitReflogObject function colored aliases. +#> +function grlogc { + [CmdletBinding()] + param ( + [switch]$Limit, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + # build properties for Format-Table + $refCmd = { + $refs = switch -Regex ($_.Ref.Split(',').Trim().Where({ $_ -ne 'origin/HEAD' })) { + '^tag:' { "`e[1;93m$($_ -replace '^tag: ')`e[0m" } + '^origin/' { "`e[1;91m$_`e[0m" } + '^HEAD' { "`e[1;96mHEAD -> `e[92m$($_ -replace 'HEAD -> ')`e[0m" } + Default { "`e[1;92m$_`e[0m" } + } + $([string]::Join(', ', $refs)) + } + $prop = @( + @{ Name = 'Commit'; Expression = { "`e[33m$($_.Commit)`e[0m" } } + @{ Name = 'Selector'; Expression = { "`e[36m$($_.Selector)`e[0m" } } + @{ Name = 'DateUTC'; Expression = { "`e[32m$($_.DateUTC)`e[0m" } } + @{ Name = 'Subject'; Expression = { $_.Subject.Substring(0, [Math]::Min(59, $_.Subject.Length)) } } + @{ Name = 'Author'; Expression = { "`e[94;1m$($_.Author)`e[0m" } } + @{ Name = 'Email'; Expression = { "`e[34;3m$($_.Email -match 'users.noreply.github.com' ? 'noreply@github.com' : $_.Email)`e[0m" } } + @{ Name = 'Ref'; Expression = $refCmd } + ) + + Get-GitReflogObject @PSBoundParameters | Format-Table -Property $prop -Wrap +} + + +function grloc { + [CmdletBinding()] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + grlogc @PSBoundParameters -Limit +} +#endregion + + +#region helper git grep functions +function ggrep { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$Grep, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + $arguments = if ($PSBoundParameters.Xargs) { + ,"--grep=$Grep" + $Xargs + } else { + "--grep=$Grep" + } + + gglogs $arguments -Grep +} + + +function ggrepa { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$Grep, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + $arguments = if ($PSBoundParameters.Xargs) { + ,"--grep=$Grep" + $Xargs + } else { + "--grep=$Grep" + } + + gglogs $arguments -Grep -All +} + + +function ggrepc { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$Grep, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + $arguments = if ($PSBoundParameters.Xargs) { + ,"--grep=$Grep" + $Xargs + } else { + "--grep=$Grep" + } + + gglogc $arguments -Grep +} + + +function ggrepca { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$Grep, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs + ) + + $arguments = if ($PSBoundParameters.Xargs) { + ,"--grep=$Grep" + $Xargs + } else { + "--grep=$Grep" + } + + gglogc $arguments -Grep -All +} + + +function glom { + Get-GitLogMessage +} + + +function glom1 { + Get-GitLogMessage -First +} +#endregion diff --git a/modules/aliases-git/aliases-git.psd1 b/modules/aliases-git/aliases-git.psd1 new file mode 100644 index 00000000..adea6f41 --- /dev/null +++ b/modules/aliases-git/aliases-git.psd1 @@ -0,0 +1,377 @@ +# +# Module manifest for module 'aliases-git' +# +# Generated by: szymono +# +# Generated on: 2023-04-04 +# + +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'aliases-git.psm1' + + # Version number of this module. + ModuleVersion = '1.23.1' + + # Supported PSEditions + CompatiblePSEditions = @('Core') + + # ID used to uniquely identify this module + GUID = 'f3f1a553-f6f5-452d-affb-ab82ff97a896' + + # Author of this module + Author = 'Szymon Osiecki' + + # Company or vendor of this module + # CompanyName = 'Unknown' + + # Copyright statement for this module + Copyright = '(c) Szymon Osiecki. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'This module contains git alias functions.' + + # Minimum version of the PowerShell engine required by this module + PowerShellVersion = '7.0' + + # Name of the PowerShell host required by this module + # PowerShellHostName = '' + + # Minimum version of the PowerShell host required by this module + # PowerShellHostVersion = '' + + # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # DotNetFrameworkVersion = '' + + # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # ClrVersion = '' + + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' + + # Modules that must be imported into the global environment prior to importing this module + # RequiredModules = @() + + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() + + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() + + # Format files (.ps1xml) to be loaded when importing this module + # FormatsToProcess = @() + + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + # NestedModules = @() + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @( + # :completer functions + 'ArgGitGetBranches' + 'ArgGitGetStashList' + # :helper function + # branch delete + 'gbd' + 'gbd!' + 'gbdo' + 'gbdo!' + 'gbdl' + 'gbdl!' + 'gbdm' + 'gbdm!' + 'gpushd' + # grep + 'ggrep' + 'ggrepa' + 'ggrepc' + 'ggrepca' + # log + 'gglo' + 'ggloa' + 'glom' + 'glom1' + # log colored + 'ggloc' + 'ggloca' + 'gglot' + # reflog + 'grlo' + # reflog colored + 'grloc' + # merge/rebase + 'gmg' + 'gmgo' + 'grb' + 'grbo' + 'gmb' + 'grmb' + # grun + 'grunrepocmd' + 'grunrefresh' + 'gruncfl' + # stash + 'gstaap' + 'gstad' + 'gstas' + 'gstast' + # switch + 'gsw' + 'gsw!' + # :alias functions + 'ga' + 'gaa' + 'gapa' + 'gau' + 'gbl' + 'gb' + 'gba' + 'gbnm' + 'gbr' + 'gbsu' + 'gbs' + 'gbsb' + 'gbsg' + 'gbsr' + 'gbss' + 'gcv' + 'gc!' + 'gca' + 'gcap' + 'gac' + 'gacp' + 'gca!' + 'gac!' + 'gcam' + 'gcamp' + 'gacm' + 'gacmp' + 'gcan!' + 'gcanp!' + 'gacn!' + 'gacnp!' + 'gcns!' + 'gcans!' + 'gacns!' + 'gcmsg' + 'gcmsgp' + 'gcempty' + 'gcn!' + 'gcnp!' + 'gcsm' + 'gcd' + 'gcf' + 'gcfg' + 'gcfge' + 'gcfgl' + 'gcfl' + 'gcfle' + 'gcfll' + 'gcl' + 'gclean' + 'gclean!' + 'gpristine' + 'gco' + 'gcount' + 'gcp' + 'gcpa' + 'gcpc' + 'gcps' + 'gd' + 'gdca' + 'gdno' + 'gdt' + 'gdw' + 'gdct' + 'gf' + 'gfa' + 'gfa!' + 'gfo' + 'gg' + 'ggc' + 'ggca' + 'gge' + 'ggp' + 'ghh' + # :gh alias functions + # issue + 'ghil' + 'ghiv' + # pr + 'ghprc' + 'ghprcf' + 'ghprco' + 'ghprd' + 'ghprl' + 'ghprm' + 'ghprmd' + 'ghprr' + 'ghprs' + 'ghprurl' + 'ghprv' + 'ghprck' + # repo + 'ghrv' + 'ghrcl' + 'ghrfk' + 'ghrsy' + # run + 'ghrnl' + 'ghrnv' + 'ghrnw' + 'ghrnrr' + # status + 'ghst' + # :alias functions (continued) + 'gignore' + 'gignored' + 'glo' + 'gloa' + 'glog' + 'gloga' + 'glol' + 'glola' + 'glon' + 'glona' + 'glong' + 'glonga' + 'glont' + 'glop' + 'glopa' + 'glos' + 'glosa' + 'glosp' + 'glospa' + 'gmt' + 'gmtvim' + 'gpl' + 'gpl!' + 'gpull' + 'gpullr' + 'gpullra' + 'gpullrav' + 'gpullrv' + 'gpush' + 'gpush!' + 'gpushdr' + 'gpushoat' + 'gpushsup' + 'gpusht' + 'gpusht!' + 'gpushv' + 'grba' + 'grbc' + 'grbi' + 'grbs' + 'gr' + 'grh' + 'grho' + 'grho!' + 'grs' + 'grl' + 'grmc' + 'grm!' + 'grmrc' + 'grmr!' + 'grp' + 'grr' + 'grrsrc' + 'grrstg' + 'grrstga' + 'grt' + 'grta' + 'grtrm' + 'grtrn' + 'grtsu' + 'grtup' + 'grtupp' + 'grturl' + 'grturlb' + 'grtv' + 'gswc' + 'gswd' + 'gswo' + 'gsmi' + 'gsmu' + 'gsps' + 'gsta' + 'gstaa' + 'gstac' + 'gstal' + 'gstap' + 'gst' + 'gstb' + 'gsts' + 'gsvnd' + 'gsvnr' + 'gt' + 'gts' + 'gtr' + 'gunignore' + 'gwch' + ) + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = '*' + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @( + 'gglobj' + 'grlobj' + ) + + # DSC resources to export from this module + # DscResourcesToExport = @() + + # List of all modules packaged with this module + # ModuleList = @() + + # List of all files packaged with this module + # FileList = @() + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + LicenseUri = 'https://github.com/szymonos/ps-modules/blob/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/szymonos/ps-modules' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + # Prerelease = 'beta' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + } # End of PrivateData hashtable + + # HelpInfo URI of this module + # HelpInfoURI = '' + + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' + +} diff --git a/modules/aliases-git/aliases-git.psm1 b/modules/aliases-git/aliases-git.psm1 new file mode 100644 index 00000000..2a9ab85a --- /dev/null +++ b/modules/aliases-git/aliases-git.psm1 @@ -0,0 +1,263 @@ +$ErrorActionPreference = 'Stop' + +. $PSScriptRoot/Functions/alias.ps1 +. $PSScriptRoot/Functions/completers.ps1 +. $PSScriptRoot/Functions/gh.ps1 +. $PSScriptRoot/Functions/helper.ps1 +. $PSScriptRoot/Functions/internal.ps1 +. $PSScriptRoot/Functions/log.ps1 + +$exportModuleMemberParams = @{ + Function = @( + # :completer functions + 'ArgGitGetBranches' + 'ArgGitGetStashList' + # :helper function + # branch delete + 'gbd' + 'gbd!' + 'gbdo' + 'gbdo!' + 'gbdl' + 'gbdl!' + 'gbdm' + 'gbdm!' + 'gpushd' + # grep + 'ggrep' + 'ggrepa' + 'ggrepc' + 'ggrepca' + # log + 'gglo' + 'ggloa' + 'glom' + 'glom1' + # log colored + 'ggloc' + 'ggloca' + 'gglot' + # reflog + 'grlo' + # reflog colored + 'grloc' + # merge/rebase + 'gmg' + 'gmgo' + 'grb' + 'grbo' + 'gmb' + 'grmb' + # grun + 'grunrepocmd' + 'grunrefresh' + 'gruncfl' + # stash + 'gstaap' + 'gstad' + 'gstas' + 'gstast' + # switch + 'gsw' + 'gsw!' + # :alias functions + 'ga' + 'gaa' + 'gapa' + 'gau' + 'gbl' + 'gb' + 'gba' + 'gbnm' + 'gbr' + 'gbsu' + 'gbs' + 'gbsb' + 'gbsg' + 'gbsr' + 'gbss' + 'gcv' + 'gc!' + 'gca' + 'gcap' + 'gac' + 'gacp' + 'gca!' + 'gac!' + 'gcam' + 'gcamp' + 'gacm' + 'gacmp' + 'gcan!' + 'gcanp!' + 'gacn!' + 'gacnp!' + 'gcns!' + 'gcans!' + 'gacns!' + 'gcmsg' + 'gcmsgp' + 'gcempty' + 'gcn!' + 'gcnp!' + 'gcsm' + 'gcd' + 'gcf' + 'gcfg' + 'gcfge' + 'gcfgl' + 'gcfl' + 'gcfle' + 'gcfll' + 'gcl' + 'gclean' + 'gclean!' + 'gpristine' + 'gco' + 'gcount' + 'gcp' + 'gcpa' + 'gcpc' + 'gcps' + 'gd' + 'gdca' + 'gdno' + 'gdt' + 'gdw' + 'gdct' + 'gf' + 'gfa' + 'gfa!' + 'gfo' + 'gg' + 'ggc' + 'ggca' + 'gge' + 'ggp' + 'ghh' + # :gh alias functions + # issue + 'ghil' + 'ghiv' + # pr + 'ghprc' + 'ghprcf' + 'ghprco' + 'ghprd' + 'ghprl' + 'ghprm' + 'ghprmd' + 'ghprr' + 'ghprs' + 'ghprurl' + 'ghprv' + 'ghprck' + # repo + 'ghrv' + 'ghrcl' + 'ghrfk' + 'ghrsy' + # run + 'ghrnl' + 'ghrnv' + 'ghrnw' + 'ghrnrr' + # status + 'ghst' + # :alias functions (continued) + 'gignore' + 'gignored' + 'glo' + 'gloa' + 'glog' + 'gloga' + 'glol' + 'glola' + 'glon' + 'glona' + 'glong' + 'glonga' + 'glont' + 'glop' + 'glopa' + 'glos' + 'glosa' + 'glosp' + 'glospa' + 'gmt' + 'gmtvim' + 'gpl' + 'gpl!' + 'gpull' + 'gpullr' + 'gpullra' + 'gpullrav' + 'gpullrv' + 'gpush' + 'gpush!' + 'gpushdr' + 'gpushoat' + 'gpushsup' + 'gpusht' + 'gpusht!' + 'gpushv' + 'grba' + 'grbc' + 'grbi' + 'grbs' + 'gr' + 'grh' + 'grho' + 'grho!' + 'grs' + 'grl' + 'grmc' + 'grm!' + 'grmrc' + 'grmr!' + 'grp' + 'grr' + 'grrsrc' + 'grrstg' + 'grrstga' + 'grt' + 'grta' + 'grtrm' + 'grtrn' + 'grtsu' + 'grtup' + 'grtupp' + 'grturl' + 'grturlb' + 'grtv' + 'gswc' + 'gswd' + 'gswo' + 'gsmi' + 'gsmu' + 'gsps' + 'gsta' + 'gstaa' + 'gstac' + 'gstal' + 'gstap' + 'gst' + 'gstb' + 'gsts' + 'gsvnd' + 'gsvnr' + 'gt' + 'gts' + 'gtr' + 'gunignore' + 'gwch' + ) + + Variable = @() + Alias = @( + 'gglobj' + 'grlobj' + ) +} + +Export-ModuleMember @exportModuleMemberParams diff --git a/modules/aliases-kubectl/Functions/alias.ps1 b/modules/aliases-kubectl/Functions/alias.ps1 new file mode 100644 index 00000000..54811967 --- /dev/null +++ b/modules/aliases-kubectl/Functions/alias.ps1 @@ -0,0 +1,12735 @@ +function kinf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('cluster-info') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kav { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('api-versions') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kcv { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + Invoke-WriteExecKubectl -Command @('config', 'view') @PSBoundParameters +} +function ksys { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ka { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('apply', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kadryc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('apply', '--recursive', '--dry-run=client', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kadrys { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('apply', '--recursive', '--dry-run=server', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysa { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'apply', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kak { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('apply', '-k') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kk { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('kustomize') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmk { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', '-k') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kre { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('replace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kre! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('replace', '--force') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kref { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('replace', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kref! { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('replace', '--force', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysex { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'exec', '-i', '-t') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksyslo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'logs', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksyslop { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'logs', '-f', '-p') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kp { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('proxy') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kpf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('port-forward') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kg { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysg { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krun { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('run', '--rm', '--restart=Never', '--image-pull-policy=IfNotPresent', '-i', '-t') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrun { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'run', '--rm', '--restart=Never', '--image-pull-policy=IfNotPresent', '-i', '-t') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdpo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'pods') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmpo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'pods') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmpo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'pods') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdep { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdep { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kddep { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'deployment') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysddep { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'deployment') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmdep { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'deployment') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmdep { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'deployment') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdsvc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'service') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdsvc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'service') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmsvc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'service') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmsvc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'service') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kging { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysging { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kding { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'ingress') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysding { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'ingress') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krming { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'ingress') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrming { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'ingress') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdcm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'configmap') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdcm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'configmap') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmcm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'configmap') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmcm { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'configmap') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsec { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdsec { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'secret') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdsec { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'secret') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmsec { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'secret') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmsec { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'secret') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgno { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdno { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'nodes') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgns { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdns { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmns { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpooyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpooyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnooyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpoowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnoowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpoojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnoojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kga { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdpoall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'pods', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kddepall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'deployment', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdsvcall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'service', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdingall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'ingress', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdcmall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'configmap', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdsecall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'secret', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdnsall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'namespaces', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgposl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmpoall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'pods', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmpoall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'pods', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmdepall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'deployment', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmdepall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'deployment', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmsvcall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'service', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmsvcall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'service', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmingall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'ingress', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmingall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'ingress', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmcmall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'configmap', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmcmall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'configmap', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmsecall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'secret', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmsecall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'secret', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmnsall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'namespaces', '--all') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpow { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpow { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnow { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpooyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnowoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpoowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgposlowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnowowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnowojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgslw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--show-labels', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgposlw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--show-labels', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepslw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--show-labels', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcallwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--all-namespaces', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingallwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--all-namespaces', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmallwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--all-namespaces', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecallwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--all-namespaces', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsallwoyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--all-namespaces', '--watch', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswoyamlall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-o=yaml', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswalloyaml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '--all-namespaces', '-o=yaml') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowideallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoowideallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=wide', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepowideallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=wide', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowideslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoowideslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=wide', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepowideslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=wide', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgslwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--show-labels', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgposlwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--show-labels', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepslwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--show-labels', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcallwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--all-namespaces', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingallwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--all-namespaces', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmallwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--all-namespaces', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecallwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--all-namespaces', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsallwojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--all-namespaces', '--watch', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswojsonall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-o=json', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswallojson { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '--all-namespaces', '-o=json') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallslw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--show-labels', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallslw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--show-labels', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallslw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--show-labels', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallwsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--watch', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallwsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--watch', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallwsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--watch', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslallw { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--all-namespaces', '--watch') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlwall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslwall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--watch', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallslwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--show-labels', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallslwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--show-labels', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallslwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--show-labels', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallwowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--watch', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallwowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--watch', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallwowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--watch', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgallwslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--all-namespaces', '--watch', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoallwslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--all-namespaces', '--watch', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepallwslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--all-namespaces', '--watch', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslallwowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--all-namespaces', '--watch', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlwowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslwowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--watch', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlwallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslwallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--watch', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowideallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowowideallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=wide', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwowideallsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=wide', '--all-namespaces', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowideslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowowideslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=wide', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwowideslall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=wide', '--show-labels', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwallowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--all-namespaces', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowallowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--all-namespaces', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwallowidesl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--all-namespaces', '-o=wide', '--show-labels') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwallslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--all-namespaces', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowallslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--all-namespaces', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwallslowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--all-namespaces', '--show-labels', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwslowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowslowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--show-labels', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwslowideall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--show-labels', '-o=wide', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwslallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowslallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--show-labels', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwslallowide { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--show-labels', '--all-namespaces', '-o=wide') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgoyamlf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=yaml', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowidef { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgojsonf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=json', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwoyamlf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=yaml', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowideslf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '--show-labels', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslowidef { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '-o=wide', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowidef { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwojsonf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=json', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwslf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwowidef { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '-o=wide', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowideslf { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '--show-labels', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwslowidef { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '-o=wide', '--recursive', '-f') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpol { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpol { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdpol { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'pods', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdpol { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'pods', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmpol { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'pods', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmpol { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'pods', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kddepl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'deployment', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysddepl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'deployment', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmdepl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'deployment', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmdepl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'deployment', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdsvcl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'service', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdsvcl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'service', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmsvcl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'service', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmsvcl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'service', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdingl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'ingress', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdingl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'ingress', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmingl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'ingress', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmingl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'ingress', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdcml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'configmap', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdcml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'configmap', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmcml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'configmap', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmcml { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'configmap', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdsecl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'secret', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysdsecl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'describe', 'secret', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmsecl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'secret', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysrmsecl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'delete', 'secret', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnol { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdnol { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'nodes', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdnsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'namespaces', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmnsl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'namespaces', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpooyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpooyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnooyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpoowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnoowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpoojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnoojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnsojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgposll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnowl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecwoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnowoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswoyamll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-o=yaml', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpoowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgposlowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnowowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsvcwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'service', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgingwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'ingress', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgcmwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'configmap', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgsecwojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'secret', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnowojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'nodes', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgnswojsonl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'namespaces', '--watch', '-o=json', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgslwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--show-labels', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgposlwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--show-labels', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepslwl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--show-labels', '--watch', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwsll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgslwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--show-labels', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgposlwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--show-labels', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepslwowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--show-labels', '--watch', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwowidesll { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '-o=wide', '--show-labels', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgwslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', '--watch', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgpowslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'pods', '--watch', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ksysgdepwslowidel { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('--namespace=kube-system', 'get', 'deployment', '--watch', '--show-labels', '-o=wide', '-l') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kpfn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('port-forward', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgponr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--field-selector=status.phase!=Running') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgponrall { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--field-selector=status.phase!=Running', '--all-namespaces') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpon { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdpon { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'pods', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmponr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'pods', '--field-selector=status.phase!=Running') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmpon { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'pods', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kddepn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'deployment', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmdepn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'deployment', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdsvcn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'service', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmsvcn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'service', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdingn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'ingress', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmingn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'ingress', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdcmn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'configmap', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmcmn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'configmap', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kdsecn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('describe', 'secret', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function krmsecn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('delete', 'secret', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpooyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepsln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpown { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwoyamln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=yaml', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgowidesln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '-o=wide', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpoowidesln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '-o=wide', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepowidesln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '-o=wide', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsvcwojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'service', '--watch', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgingwojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'ingress', '--watch', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgcmwojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'configmap', '--watch', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgsecwojsonn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'secret', '--watch', '-o=json', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlwn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslwn { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--watch', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwsln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowsln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwsln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgslwowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--show-labels', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgposlwowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--show-labels', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepslwowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--show-labels', '--watch', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwowidesln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '-o=wide', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowowidesln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '-o=wide', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwowidesln { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '-o=wide', '--show-labels', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgwslowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', '--watch', '--show-labels', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgpowslowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'pods', '--watch', '--show-labels', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function kgdepwslowiden { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('get', 'deployment', '--watch', '--show-labels', '-o=wide', '--namespace') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} +function ktno { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $cmnd = @('top', 'nodes', '--use-protocol-buffers') + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters +} diff --git a/modules/aliases-kubectl/Functions/completers.ps1 b/modules/aliases-kubectl/Functions/completers.ps1 new file mode 100644 index 00000000..69301f0b --- /dev/null +++ b/modules/aliases-kubectl/Functions/completers.ps1 @@ -0,0 +1,160 @@ +<# +.SYNOPSIS +Get list of kubectl config clusters for the function ArgumentCompleter attribute. +#> +function ArgK8sGetClusters { + param ( + $commandName, + $parameterName, + $wordToComplete, + $commandAst, + $fakeBoundParameters + ) + + # get clusters + $cmdArgs = @( + 'config', 'view' + '--output', 'json' + ) + [string[]]$possibleValues = (& kubectl @cmdArgs | ConvertFrom-Json).clusters.name + + # return matching clusters + $possibleValues.Where({ $_ -like "$wordToComplete*" }).ForEach({ $_ }) +} + + +<# +.SYNOPSIS +Get list of kubectl config contexts for the function ArgumentCompleter attribute. +#> +function ArgK8sGetContexts { + param ( + $commandName, + $parameterName, + $wordToComplete, + $commandAst, + $fakeBoundParameters + ) + + # get contexts + $cmdArgs = @( + 'config', 'view' + '--output', 'json' + ) + [string[]]$possibleValues = (& kubectl @cmdArgs | ConvertFrom-Json).contexts.name + + # return matching contexts + $possibleValues.Where({ $_ -like "$wordToComplete*" }).ForEach({ $_ }) +} + + +<# +.SYNOPSIS +Get list of kubernetes namespaces for the function ArgumentCompleter attribute. +#> +function ArgK8sGetNamespaces { + param ( + $commandName, + $parameterName, + $wordToComplete, + $commandAst, + $fakeBoundParameters + ) + + # get namespaces + $cmdArgs = @( + 'get', 'namespaces' + '--field-selector=status.phase=Active' + '--output', 'json' + ) + [string[]]$possibleValues = (& kubectl @cmdArgs | ConvertFrom-Json).items.metadata.name + + # return matching namespaces + $possibleValues.Where({ $_ -like "$wordToComplete*" }).ForEach({ $_ }) +} + + +<# +.SYNOPSIS +Get list of kubernetes pods for the function ArgumentCompleter attribute. +#> +function ArgK8sGetPods { + param ( + $commandName, + $parameterName, + $wordToComplete, + $commandAst, + $fakeBoundParameters + ) + + # build kubectl command string + $cmdArgs = [System.Collections.Generic.List[string]]::new() + $cmdArgs.AddRange([string[]]@('get', 'pods', '--field-selector=status.phase=Running')) + if ($fakeBoundParameters.ContainsKey('Namespace')) { + $cmdArgs.AddRange([string[]]@('--namespace', $fakeBoundParameters.Namespace)) + } + $cmdArgs.AddRange([string[]]@('--output', 'json')) + # get pods + [string[]]$possibleValues = (& kubectl @cmdArgs | ConvertFrom-Json).items.metadata.name + + # return matching pods + $possibleValues.Where({ $_ -like "$wordToComplete*" }).ForEach({ $_ }) +} + + +<# +.SYNOPSIS +Get list of pod containers for the function ArgumentCompleter attribute. +#> +function ArgK8sGetPodContainers { + param ( + $commandName, + $parameterName, + $wordToComplete, + $commandAst, + $fakeBoundParameters + ) + + if ($fakeBoundParameters.ContainsKey('Pod')) { + # build kubectl command string + $cmdArgs = [System.Collections.Generic.List[string]]::new() + $cmdArgs.AddRange([string[]]@('get', 'pod', $fakeBoundParameters.Pod)) + if ($fakeBoundParameters.ContainsKey('Namespace')) { + $cmdArgs.AddRange([string[]]@('--namespace', $fakeBoundParameters.Namespace)) + } + $cmdArgs.AddRange([string[]]@('--output', 'json')) + # get pod containers + [string[]]$possibleValues = (& kubectl @cmdArgs | ConvertFrom-Json).spec.containers.name + + # # return matching containers + $possibleValues.Where({ $_ -like "$wordToComplete*" }).ForEach({ $_ }) + } +} + + +<# +.SYNOPSIS +Get list of kubernetes secrets for the function ArgumentCompleter attribute. +#> +function ArgK8sGetSecrets { + param ( + $commandName, + $parameterName, + $wordToComplete, + $commandAst, + $fakeBoundParameters + ) + + # build kubectl command string + $cmdArgs = [System.Collections.Generic.List[string]]::new() + $cmdArgs.AddRange([string[]]@('get', 'secrets')) + if ($fakeBoundParameters.ContainsKey('Namespace')) { + $cmdArgs.AddRange([string[]]@('--namespace', $fakeBoundParameters.Namespace)) + } + $cmdArgs.AddRange([string[]]@('--output', 'json')) + # get pods + [string[]]$possibleValues = (& kubectl @cmdArgs | ConvertFrom-Json).items.metadata.name + + # return matching pods + $possibleValues.Where({ $_ -like "$wordToComplete*" }).ForEach({ $_ }) +} diff --git a/modules/aliases-kubectl/Functions/helper.ps1 b/modules/aliases-kubectl/Functions/helper.ps1 new file mode 100644 index 00000000..b64a8a43 --- /dev/null +++ b/modules/aliases-kubectl/Functions/helper.ps1 @@ -0,0 +1,651 @@ +#region helper functions +<# +.SYNOPSIS +Get kubectl client version. +#> +function Get-KubectlVersion { + # get-full version + $v = kubectl version -o=json 2>$null | ConvertFrom-Json + # convert back to json selected properties + $verJson = [ordered]@{ + clientVersion = [ordered]@{ + gitVersion = $v.clientVersion.gitVersion + buildDate = $v.clientVersion.buildDate + goVersion = $v.clientVersion.goVersion + platform = $v.clientVersion.platform + } + serverVersion = [ordered]@{ + gitVersion = $v.serverVersion.gitVersion -replace '(v[\d.]+).*', "`$1" + buildDate = $v.serverVersion.buildDate + goVersion = $v.serverVersion.goVersion + platform = $v.serverVersion.platform + } + } | ConvertTo-Json + + # format output command + if (Get-Command yq -CommandType Application -ErrorAction SilentlyContinue) { + $verJson | yq -p json -o yaml + } elseif (Get-Command jq -CommandType Application -ErrorAction SilentlyContinue) { + $verJson | jq + } else { + $verJson + } +} + + +<# +.SYNOPSIS +Get kubectl client version. +#> +function Get-KubectlClientVersion { + return (kubectl version -o=json 2>$null | ConvertFrom-Json).clientVersion.gitVersion +} + + +<# +.SYNOPSIS +Get kubernetes server version. +#> +function Get-KubectlServerVersion { + return (kubectl version -o=json 2>$null | ConvertFrom-Json).serverVersion.gitVersion -replace '(v[\d.]+).*', "`$1" +} + + +<# +.SYNOPSIS +Set kubernetes current namespace context. + +.PARAMETER Namespace +Kubernetes namespace name to set the namespace current context to. +#> +function Set-KubectlContextCurrentNamespace { + [CmdletBinding()] + param ( + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [string]$Namespace + ) + + begin { + # get namespace name + $namespace = if ($PsBoundParameters.Namespace) { + $PsBoundParameters.Namespace + } else { + $prop = @( + @{ Name = 'Name'; Expression = { $_.metadata.name } } + @{ Name = 'Status'; Expression = { $_.status.phase } } + @{ Name = 'CreatedAt'; Expression = { $_.metadata.creationTimestamp } } + ) + kubectl get namespace --output json ` + | ConvertFrom-Json ` + | Select-Object -ExpandProperty items ` + | Select-Object -Property $prop ` + | Get-ArrayIndexMenu -Value -Message 'Select namespace to switch context to' ` + | Select-Object -ExpandProperty name + } + } + + process { + # execute command + $cmnd = @('config', 'set-context', '--current', '--namespace', $namespace) + Invoke-WriteExecKubectl -Command $cmnd + } +} + + +<# +.SYNOPSIS +Set kubernetes current namespace context using kubens cli. + +.PARAMETER Namespace +Kubernetes namespace name to set the current namespace context to. +#> +function Set-KubensContextCurrentNamespace { + [CmdletBinding()] + param ( + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [string]$Namespace + ) + + # build kubectl command string + [System.Collections.Generic.List[string]]$cmdArgs = @() + if ($PSBoundParameters.Namespace) { + $cmdArgs.Add($Namespace) + } + + # execute kubens command + & kubens @cmdArgs +} + + +<# +.SYNOPSIS +Change kubernetes context and sets the corresponding kubectl client version. + +.PARAMETER Context +Kubernetes cluster context name to be set. +.PARAMETER Cluster +Kubernetes cluster name for the context to be set. +#> +function Set-KubectlContext { + [CmdletBinding(DefaultParameterSetName = 'context')] + param ( + [Alias('n')] + [Parameter(Position = 0, ParameterSetName = 'context')] + [ArgumentCompleter({ ArgK8sGetContexts @args })] + [string]$Context, + + [Alias('c')] + [Parameter(Position = 0, ParameterSetName = 'cluster')] + [ArgumentCompleter({ ArgK8sGetClusters @args })] + [string]$Cluster + ) + + begin { + # get kubectl contexts + $ctxs = Get-KubectlContext -Object + + # get context name + $ctx = if ($PSBoundParameters.Context) { + $ctxs.Where({ $_.name -eq $Context }).name + } elseif ($PSBoundParameters.Cluster) { + $ctxs.Where({ $_.cluster -eq $Cluster }).name + } else { + Get-KubectlContext -Object ` + | Select-Object name, cluster, namespace ` + | Get-ArrayIndexMenu -Value -Message 'Select kubernetes context to switch to.' ` + | Select-Object -ExpandProperty name + } + } + + process { + if ($ctx) { + # execute command + $cmnd = @('config', 'use-context', $ctx) + Invoke-WriteExecKubectl -Command $cmnd + # set kubectl binary to server version + Set-KubectlLocal + } else { + Write-Warning "$($Context ? "Context '$Context'" : "Cluster '$Cluster'") not found." + } + } +} + + +<# +.SYNOPSIS +Get list of available kubernetes contexts. +#> +function Remove-KubectlContext { + $ctx = Get-KubectlContext -Object | Select-Object name, cluster, user | Get-ArrayIndexMenu -Value + + # unset context + kubectl config unset "contexts.$($ctx.name)" + kubectl config unset "clusters.$($ctx.cluster)" + kubectl config unset "users.$($ctx.user)" +} + + +<# +.SYNOPSIS +Get list of available kubernetes contexts. + +.PARAMETER Table +Switch whether to return the output in table format. +.PARAMETER Json +Switch whether to return the output in JSON format. +.PARAMETER Object +Switch whether to return the output as a PowerShell object. +.PARAMETER Context +Get kubernetes context details by context name. +.PARAMETER Cluster +Get kubernetes context details by cluster name. +.PARAMETER Current +The parameter to specify if the current context should be returned. +#> +function Get-KubectlContext { + [CmdletBinding(DefaultParameterSetName = 'table')] + param ( + [Parameter(ParameterSetName = 'table')] + [switch]$Table, + + [Parameter(ParameterSetName = 'json')] + [switch]$Json, + + [Parameter(ParameterSetName = 'object')] + [switch]$Object, + + [Alias('n')] + [Parameter(Mandatory, ParameterSetName = 'context')] + [Parameter(ParameterSetName = 'table')] + [Parameter(ParameterSetName = 'json')] + [Parameter(ParameterSetName = 'object')] + [string]$Context, + + [Alias('c')] + [Parameter(Mandatory, ParameterSetName = 'cluster')] + [Parameter(ParameterSetName = 'table')] + [Parameter(ParameterSetName = 'json')] + [Parameter(ParameterSetName = 'object')] + [string]$Cluster, + + [Parameter(Mandatory, ParameterSetName = 'current')] + [Parameter(ParameterSetName = 'table')] + [Parameter(ParameterSetName = 'json')] + [Parameter(ParameterSetName = 'object')] + [switch]$Current + ) + + begin { + [System.Collections.Generic.List[string]]$cmdArgs = @() + # get kubectl config + @('config', 'view', '--output', 'json').ForEach({ $cmdArgs.Add($_) }) + if ($PSBoundParameters.Current) { + $cmdArgs.Add('--minify') + } + Write-Debug "kubectl $($cmdArgs -join ' ')" + $config = & kubectl @cmdArgs | ConvertFrom-Json + } + + process { + # create context objects + $ctxs = foreach ($ctx in $config.contexts) { + [PSCustomObject]@{ + '@' = $ctx.name -eq $config.'current-context' ? '*' : $null + name = $ctx.name + cluster = $ctx.context.cluster + namespace = $ctx.context.namespace + user = $ctx.context.user + } + } + + # filter contexts + if ($PSBoundParameters.Cluster) { + $ctxs = $ctxs.Where({ $_.cluster -eq $Cluster }) + } elseif ($PSBoundParameters.Context) { + $ctxs = $ctxs.Where({ $_.name -eq $Context }) + } + + } + + end { + # return output + switch ($PsCmdlet.ParameterSetName) { + json { + if (Get-Command jq -CommandType Application -ErrorAction SilentlyContinue) { + $ctxs | ConvertTo-Json | jq + } else { + $ctxs | ConvertTo-Json + } + } + object { + $ctxs + } + table { + $ctxs | Format-Table + } + } + } +} + + +<# +.SYNOPSIS +Downloads kubectl client version corresponding to kubernetes server version and creates symbolic link +to the client in $HOME/.local/bin directory. +.DESCRIPTION +Function requires the $HOME/.local/bin directory to be preceding path in $PATH environment variable. +#> +function Set-KubectlLocal { + begin { + # determine kubectl binary name + $KUBECTL = $IsWindows ? 'kubectl.exe' : 'kubectl' + # calculate paths + $LOCAL_BIN = [IO.Path]::Combine($HOME, '.local', 'bin') + $KUBECTL_LOCAL = [IO.Path]::Combine($LOCAL_BIN, $KUBECTL) + $KUBECTL_DIR = [IO.Path]::Combine($HOME, '.local', 'share', 'kubectl') + # initialize retry variable for kubectl download loop + $RETRY_COUNT = 0 + } + + process { + # check kubernetes server version + $serverVersion = Get-KubectlServerVersion + if (-not $serverVersion) { + Write-Warning 'Server not available.' + break + } + # calculate kubectl path corresponding to server version + $kctlVer = [IO.Path]::Combine($KUBECTL_DIR, $serverVersion, $KUBECTL) + + # check if ~/.local/bin/kubectl symbolic link points to the above path + if ((Get-ItemPropertyValue $KUBECTL_LOCAL -Name LinkTarget -ErrorAction SilentlyContinue) -ne $kctlVer) { + if (-not (Test-Path $LOCAL_BIN)) { + New-Item $LOCAL_BIN -ItemType Directory | Out-Null + } + if (-not (Test-Path $kctlVer -PathType Leaf)) { + New-Item $([IO.Path]::Combine($KUBECTL_DIR, $serverVersion)) -ItemType Directory -ErrorAction SilentlyContinue | Out-Null + $dlSysArch = if ($IsWindows) { + 'windows/amd64' + } elseif ($IsLinux) { + 'linux/amd64' + } elseif ($IsMacOS) { + 'darwin/arm64' + } + do { + [Net.WebClient]::new().DownloadFile("https://dl.k8s.io/release/${serverVersion}/bin/$dlSysArch/$KUBECTL", $kctlVer) + $RETRY_COUNT++ + } until ((Test-Path $kctlVer -PathType Leaf) -or $RETRY_COUNT -ge 2) + } + + # replace existing ~/.local/bin/kubectl symbolic link + if (Test-Path $kctlVer -PathType Leaf) { + New-Item -ItemType SymbolicLink -Path $KUBECTL_LOCAL -Target $kctlVer -Force | Out-Null + } + } + } + + clean { + # add executable bit to the kubectl binary + if ($serverVersion) { + if (-not $IsWindows -and (Test-Path $kctlVer -PathType Leaf) -and ((Get-Item $kctlVer).UnixMode -ne '-rwxr-xr-x')) { + chmod +x $kctlVer + } + } + + # check if the symbolic link points to the existing file and remove otherwise + if ((Test-Path $KUBECTL_LOCAL -PathType Leaf) -and (Get-ItemPropertyValue $KUBECTL_LOCAL -Name 'LinkType')) { + $linkTarget = Get-ItemPropertyValue $KUBECTL_LOCAL -Name LinkTarget + if (-not (Test-Path $linkTarget -PathType Leaf)) { + Remove-Item $KUBECTL_LOCAL -Force + } + } + } +} + + +<# +.SYNOPSIS +Connect remotely to the specified pod on the cluster. By default sh shell is being executed. + +.PARAMETER Pod +Name of the pod to connect to. +.PARAMETER Container +Explicitly specify the container in the pod to connect to. +.PARAMETER Namespace +Specify namespace of the pod. +.PARAMETER Command +Specify to run any specified command. +.PARAMETER bash +Specify to run bash shell. +.PARAMETER python +Specify to run python REPL. +.PARAMETER pwsh +Specify to run PowerShell shell. +#> +function Connect-KubernetesContainer { + [CmdletBinding(DefaultParameterSetName = 'Shell')] + param ( + [Alias('p')] + [Parameter(Position = 0, Mandatory = $true)] + [ArgumentCompleter({ ArgK8sGetPods @args })] + [string]$Pod, + + [Alias('c')] + [Parameter(Position = 1)] + [ArgumentCompleter({ ArgK8sGetPodContainers @args })] + [string]$Container, + + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [string]$Namespace, + + [Alias('cmd')] + [Parameter(ParameterSetName = 'Command')] + [string]$Command, + + [Parameter(ParameterSetName = 'Shell')] + [switch]$bash, + + [Parameter(ParameterSetName = 'Shell')] + [switch]$python, + + [Parameter(ParameterSetName = 'Shell')] + [switch]$pwsh + ) + + begin { + # build kubectl command parameters + $cmnd = [System.Collections.Generic.List[string]]::new([string[]]@('exec', '--stdin', '--tty')) + $cmnd.Add($PSBoundParameters.Pod) + if ($PSBoundParameters.Namespace) { + $cmnd.AddRange([string[]]@('--namespace', $Namespace)) + } + if ($PSBoundParameters.Container) { + $cmnd.AddRange([string[]]@('--container', $Container)) + } + # specify command to be used in the container + switch ($PsCmdlet.ParameterSetName) { + Shell { + if ($PSBoundParameters.bash) { + $cmnd.AddRange([string[]]@('--', 'bash')) + } elseif ($PSBoundParameters.python) { + $cmnd.AddRange([string[]]@('--', 'python')) + } elseif ($PSBoundParameters.PowerShell) { + $cmnd.AddRange([string[]]@('--', 'pwsh')) + } else { + $cmnd.AddRange([string[]]@('--', 'sh')) + } + } + Command { + $cmnd.AddRange([string[]]@('--', $Command)) + } + } + } + + process { + # execute command + Invoke-WriteExecKubectl -Command $cmnd + } +} + + +<# +.SYNOPSIS +Debug cluster pods using interactive debugging containers. + +.PARAMETER Pod +Name of the pod to be debugged. +.PARAMETER Namespace +Specify namespace of the pod. +.PARAMETER Command +Specify to run any specified command in the debug container. +.PARAMETER bash +Specify to run bash shell in the debug container. +.PARAMETER python +Specify to run python REPL in the debug container. +.PARAMETER pwsh +Specify to run PowerShell shell in the debug container. +#> +function Debug-KubernetesPod { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Mandatory, Position = 0)] + [ArgumentCompleter({ ArgK8sGetPods @args })] + [string]$Pod, + + [Parameter(Position = 1)] + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [string]$Namespace, + + [ValidateNotNullOrEmpty()] + [string]$Image = 'busybox', + + [Alias('cmd')] + [Parameter(ParameterSetName = 'Command')] + [string]$Command, + + [Parameter(ParameterSetName = 'Shell')] + [switch]$sh, + + [Parameter(ParameterSetName = 'Shell')] + [switch]$bash, + + [Parameter(ParameterSetName = 'Shell')] + [switch]$python, + + [Parameter(ParameterSetName = 'Shell')] + [switch]$pwsh + ) + + begin { + # build kubectl command parameters + $cmnd = [System.Collections.Generic.List[string]]::new([string[]]@('debug', '--stdin', '--tty')) + $cmnd.AddRange([string[]]@($PSBoundParameters.Pod, "--image=$Image")) + if ($PSBoundParameters.Namespace) { + $cmnd.AddRange([string[]]@('--namespace', $Namespace)) + } + # specify command to be used in the container + switch ($PsCmdlet.ParameterSetName) { + Shell { + if ($PSBoundParameters.bash) { + $cmnd.AddRange([string[]]@('--', 'bash')) + } elseif ($PSBoundParameters.python) { + $cmnd.AddRange([string[]]@('--', 'python')) + } elseif ($PSBoundParameters.PowerShell) { + $cmnd.AddRange([string[]]@('--', 'pwsh')) + } else { + $cmnd.AddRange([string[]]@('--', 'sh')) + } + } + Command { + $cmnd.AddRange([string[]]@('--', $Command)) + } + } + } + + process { + # execute command + Invoke-WriteExecKubectl -Command $cmnd + } +} + + +<# +.SYNOPSIS +Get logs from the specified pod. + +.PARAMETER Pod +Name of the pod to get logs from. +.PARAMETER Container +Specify container in the pod to get logs from. +.PARAMETER Namespace +Specify namespace of the pod. +#> +function Get-KubectlPodLogs { + [CmdletBinding(DefaultParameterSetName = 'Shell')] + param ( + [Alias('p')] + [Parameter(Position = 0, Mandatory = $true)] + [ArgumentCompleter({ ArgK8sGetPods @args })] + [string]$Pod, + + [Alias('c')] + [Parameter(Position = 1)] + [ArgumentCompleter({ ArgK8sGetPodContainers @args })] + [string]$Container, + + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [string]$Namespace + ) + + begin { + # build kubectl command parameters + $cmnd = [System.Collections.Generic.List[string]]::new([string[]]@('logs', '-f')) + $cmnd.Add($PSBoundParameters.Pod) + if ($PSBoundParameters.Namespace) { + $cmnd.AddRange([string[]]@('--namespace', $Namespace)) + } + if ($PSBoundParameters.Container) { + $cmnd.AddRange([string[]]@('--container', $Container)) + } + } + + process { + # execute command + Invoke-WriteExecKubectl -Command $cmnd + } +} + + +function Get-KubectlApiResourceShortNames { + [CmdletBinding()] + param () + + begin { + Write-Debug 'Retrieving kubernetes API resources...' + $apiResources = kubectl api-resources + if (-not $?) { + throw 'Failed to retrieve kubernetes API resources.' + } + Write-Debug "kubectl api-resources returned $($apiResources.Length - 1) results." + + # index columns + $idxName = $apiResources[0].IndexOf('NAME') + $idxShort = $apiResources[0].IndexOf('SHORTNAMES') + $idxAPI = $apiResources[0].IndexOf('APIVERSION') + } + + process { + # parse API resources + # return as list of objects + $collection = [System.Collections.Generic.List[pscustomobject]]::new() + for ($i = 1; $i -lt $apiResources.Length; $i++) { + $apiResource = [PSCustomObject]@{ + Name = $apiResources[$i].Substring($idxName, $idxShort).TrimEnd() + ShortNames = $apiResources[$i].Substring($idxShort, $idxAPI - $idxShort).TrimEnd().Split(',') + } + if ($apiResource.ShortNames) { + $collection.Add($apiResource) + } + } + } + + end { + $collection | Sort-Object -Property Name + } +} + +<# +.SYNOPSIS +Get kubernetes short names for resources. +#> +function kapishortnames { + $apiResources = (Get-KubectlApiResources -AsObject).Where({ $_.ShortName }) + + $props = @( + @{ Name = 'Name'; Expression = { $_.Plural } } + @{ Name = 'ShortName'; Expression = { $_.ShortName -join ',' } } + ) + $apiResources | Select-Object -Property $props | Sort-Object Name +} +#endregion + + +#region aliases +New-Alias -Name kv -Value Get-KubectlVersion +New-Alias -Name kvc -Value Get-KubectlClientVersion +New-Alias -Name kvs -Value Get-KubectlServerVersion +New-Alias -Name kcgctx -Value Get-KubectlContext +New-Alias -Name kcuctx -Value Set-KubectlContext +New-Alias -Name kc -Value Set-KubectlContext +New-Alias -Name kcrmctx -Value Remove-KubectlContext +New-Alias -Name kcsctxcns -Value Set-KubectlContextCurrentNamespace +New-Alias -Name kex -Value Connect-KubernetesContainer +New-Alias -Name kdbg -Value Debug-KubernetesPod +New-Alias -Name klo -Value Get-KubectlPodLogs +if (Test-Path '/usr/bin/kubens' -PathType Leaf) { + New-Alias -Name kn -Value Set-KubensContextCurrentNamespace +} else { + New-Alias -Name kn -Value Set-KubectlContextCurrentNamespace +} +New-Alias -Name kapishorts -Value Get-KubectlApiResourceShortNames +#endregion diff --git a/modules/aliases-kubectl/Functions/internal.ps1 b/modules/aliases-kubectl/Functions/internal.ps1 new file mode 100644 index 00000000..fb4e0232 --- /dev/null +++ b/modules/aliases-kubectl/Functions/internal.ps1 @@ -0,0 +1,138 @@ +<# +.SYNOPSIS +Write provided kubectl with its arguments and then execute it. +You can suppress writing the kubectl by providing -Quiet as one of the arguments. +You can suppress executing the kubectl by providing -WhatIf as one of the arguments. + +.PARAMETER Command +kubectl command to be executed. +.PARAMETER Xargs +Additional arguments to be passed to the kubectl command. +.PARAMETER WhatIf +If specified, the command will not be executed, but only written to the console. +.PARAMETER Quiet +If specified, the command will not be printed to the console. +#> +function Invoke-WriteExecKubectl { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Mandatory, Position = 0)] + [string[]]$Command, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + if (-not $PsBoundParameters.Quiet) { + # write command + $writeCmd = , 'kubectl' + $Command + $Xargs | ForEach-Object { + switch -Regex ($_) { + "'" { + "`"$_`"" + break + } + '\s|"' { + "'$_'" + break + } + Default { + $_ + break + } + } + } | Join-String -Separator ' ' + Write-Host $writeCmd -ForegroundColor Magenta + } + + if (-not $PsBoundParameters.WhatIf) { + # write debug information + Write-Debug "Invoke-WriteExecKubectl.Command`n`e[22m$Command`n" + if ($PSBoundParameters.Xargs) { + Write-Debug "Invoke-WriteExecKubectl.Xargs`n`e[22m$Xargs`n" + } + # execute command + & kubectl @Command @Xargs + } +} + + +<# +.SYNOPSIS +Build a kubectl command for specific kinds and o operations (verbs). +.DESCRIPTION +The command allows to create functions with autocompletion for specific kubectl operations. + +.PARAMETER Verb +The kubectl operation to be performed. Valid values are 'get', 'describe', and 'delete'. +.PARAMETER Kind +The kind of kubernetes object to be operated on. Valid values are 'Pod', 'Service', 'Namespace', and 'Secret'. +.PARAMETER Name +The name of the resource to be operated on. Optional parameter. +.PARAMETER Namespace +The namespace in which the operation should be performed. Optional parameter. +.PARAMETER Xargs +Additional arguments to be passed to the kubectl command. +.PARAMETER WhatIf +If specified, the command will not be executed, but only written to the console. +.PARAMETER Quiet +If specified, the command will not be printed to the console. +#> +function Build-KubectlCommand { + param ( + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$Verb, + + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$Kind, + + [ValidateNotNullOrEmpty()] + [string]$Resource, + + [ValidateNotNullOrEmpty()] + [string]$Namespace, + + [string[]]$Xargs, + + [switch]$WhatIf, + + [switch]$Quiet + ) + + begin { + # write debug information + Write-Debug "Build-KubectlCommand.PSBoundParameters`n`e[22m$($PSBoundParameters.GetEnumerator().ForEach({ "$($_.Key): $($_.Value)" }) -join "`n")`n" + + # build command + $cmnd = [System.Collections.Generic.List[string]]::new() + $cmnd.AddRange([string[]]@($PSBoundParameters.Verb.ToLower(), $PSBoundParameters.Kind.ToLower())) + @('Verb', 'Kind').ForEach({ $PSBoundParameters.Remove($_) | Out-Null }) + + # build parameters + if ($PSBoundParameters.Resource) { + $cmnd.Add($Resource) + $PSBoundParameters.Remove('Resource') | Out-Null + } + + if ($PSBoundParameters.Namespace) { + if ($Kind -notin @('ns', 'namespace', 'namespaces')) { + $cmnd.AddRange([string[]]@('--namespace', $Namespace)) + } + $PSBoundParameters.Remove('Namespace') | Out-Null + } + } + + process { + # write debug information + Write-Debug "Build-KubectlCommand.Command`n`e[22m$cmnd`n" + # execute command + Invoke-WriteExecKubectl -Command $cmnd @PSBoundParameters + } +} diff --git a/modules/aliases-kubectl/Functions/pods.ps1 b/modules/aliases-kubectl/Functions/pods.ps1 new file mode 100644 index 00000000..da2be9fa --- /dev/null +++ b/modules/aliases-kubectl/Functions/pods.ps1 @@ -0,0 +1,199 @@ +#region functions with autocomplete +<# +.SYNOPSIS +Kubernetes pod(s) information. + +.PARAMETER Resource +Name of the pod. +.PARAMETER Namespace +Specify namespace of the pod. +.PARAMETER Xargs +Additional arguments to be passed to the kubectl command. +.PARAMETER WhatIf +If specified, the command will not be executed, but only written to the console. +.PARAMETER Quiet +If specified, the command will not be printed to the console. +#> +function kgpo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgK8sGetPods @args })] + [ValidateNotNullOrEmpty()] + [string]$Resource, + + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [ValidateNotNullOrEmpty()] + [string]$Namespace, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $param = @{ + Verb = 'get' + Kind = 'pods' + } + return Build-KubectlCommand @param @PSBoundParameters +} +function kdpo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgK8sGetPods @args })] + [ValidateNotNullOrEmpty()] + [string]$Resource, + + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [ValidateNotNullOrEmpty()] + [string]$Namespace, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $param = @{ + Verb = 'describe' + Kind = 'pods' + } + return Build-KubectlCommand @param @PSBoundParameters +} +function kgpocntr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0, Mandatory)] + [ArgumentCompleter({ ArgK8sGetPods @args })] + [string]$Resource, + + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [ValidateNotNullOrEmpty()] + [string]$Namespace, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $param = @{ + Verb = 'get' + Kind = 'pods' + Xargs = @('--output', 'jsonpath={.spec.containers[*].name}') + } + return (Build-KubectlCommand @param @PSBoundParameters).Split() +} +function kgporsrc { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgK8sGetPods @args })] + [ValidateNotNullOrEmpty()] + [string]$Resource, + + [Alias('ns')] + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [ValidateNotNullOrEmpty()] + [string]$Namespace, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + # resources columns + $columns = [string]::Join(',', + 'NAMESPACE:.metadata.namespace', + 'POD:.metadata.name', + 'CONTAINER:.spec.containers[*].name', + 'CPU_REQUEST:.spec.containers[*].resources.requests.cpu', + 'CPU_LIMIT:.spec.containers[*].resources.limits.cpu', + 'MEM_REQUEST:.spec.containers[*].resources.requests.memory', + 'MEM_LIMIT:.spec.containers[*].resources.limits.memory' + ) + + $param = @{ + Verb = 'get' + Kind = 'pods' + Xargs = @('--output', "custom-columns=$columns") + } + return Build-KubectlCommand @param @PSBoundParameters +} +function ktpo { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgK8sGetPods @args })] + [ValidateNotNullOrEmpty()] + [string]$Resource, + + [Alias('ns')] + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [ValidateNotNullOrEmpty()] + [string]$Namespace, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $param = @{ + Verb = 'top' + Kind = 'pods' + Xargs = @('--use-protocol-buffers') + } + return Build-KubectlCommand @param @PSBoundParameters +} +function ktpocntr { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgK8sGetPods @args })] + [ValidateNotNullOrEmpty()] + [string]$Resource, + + [Alias('ns')] + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [ValidateNotNullOrEmpty()] + [string]$Namespace, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $param = @{ + Verb = 'top' + Kind = 'pods' + Xargs = @('--use-protocol-buffers', '--containers') + } + return Build-KubectlCommand @param @PSBoundParameters +} +#endregion diff --git a/modules/aliases-kubectl/Functions/secrets.ps1 b/modules/aliases-kubectl/Functions/secrets.ps1 new file mode 100644 index 00000000..d7f75602 --- /dev/null +++ b/modules/aliases-kubectl/Functions/secrets.ps1 @@ -0,0 +1,79 @@ +#region functions with autocomplete +<# +.SYNOPSIS +Get kubernetes secret(s). + +.PARAMETER Resource +Name of the secret. Optional parameter. If not specified, all secrets in the namespace will be returned. +.PARAMETER Namespace +Specify namespace of the pod. Optional parameter. +.PARAMETER Xargs +Additional arguments to be passed to the kubectl command. +.PARAMETER WhatIf +If specified, the command will not be executed, but only written to the console. +.PARAMETER Quiet +If specified, the command will not be printed to the console. +#> +function kgsec { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Position = 0)] + [ArgumentCompleter({ ArgK8sGetSecrets @args })] + [ValidateNotNullOrEmpty()] + [string]$Resource, + + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [ValidateNotNullOrEmpty()] + [string]$Namespace, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $param = @{ + Verb = 'get' + Kind = 'secrets' + } + return Build-KubectlCommand @param @PSBoundParameters +} +function kgsecd { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Mandatory, Position = 0)] + [ArgumentCompleter({ ArgK8sGetSecrets @args })] + [string]$Resource, + + [ArgumentCompleter({ ArgK8sGetNamespaces @args })] + [ValidateNotNullOrEmpty()] + [string]$Namespace, + + [Parameter(ValueFromRemainingArguments)] + [string[]]$Xargs, + + [Parameter(ParameterSetName = 'whatif')] + [switch]$WhatIf, + + [Parameter(ParameterSetName = 'quiet')] + [switch]$Quiet + ) + + $param = @{ + Verb = 'get' + Kind = 'secrets' + Xargs = @('--output', 'json') + } + # convert secret to PSObject + $secretObj = Build-KubectlCommand @param @PSBoundParameters | ConvertFrom-Json + # decode and write secret data + $secretObj.data.PSobject.Properties | ForEach-Object { + Write-Host "# $($_.Name)" -ForegroundColor DarkGreen + [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($_.Value)).Trim() + } +} +#endregion diff --git a/modules/aliases-kubectl/aliases-kubectl.psd1 b/modules/aliases-kubectl/aliases-kubectl.psd1 new file mode 100644 index 00000000..e28f72af --- /dev/null +++ b/modules/aliases-kubectl/aliases-kubectl.psd1 @@ -0,0 +1,976 @@ +# +# Module manifest for module 'aliases-kubectl' +# +# Generated by: szymono +# +# Generated on: 2023-04-04 +# + +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'aliases-kubectl.psm1' + + # Version number of this module. + ModuleVersion = '0.13.0' + + # Supported PSEditions + # CompatiblePSEditions = @() + + # ID used to uniquely identify this module + GUID = '5130f101-34ad-4995-9502-0f8322b1ad6f' + + # Author of this module + Author = 'Szymon Osiecki' + + # Company or vendor of this module + # CompanyName = 'Unknown' + + # Copyright statement for this module + Copyright = '(c) Szymon Osiecki. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'This module contains kubectl alias functions.' + + # Minimum version of the PowerShell engine required by this module + CompatiblePSEditions = @('Core') + PowerShellVersion = '7.3' + + # Name of the PowerShell host required by this module + # PowerShellHostName = '' + + # Minimum version of the PowerShell host required by this module + # PowerShellHostVersion = '' + + # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # DotNetFrameworkVersion = '' + + # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # ClrVersion = '' + + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' + + # Modules that must be imported into the global environment prior to importing this module + # RequiredModules = @() + + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() + + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() + + # Format files (.ps1xml) to be loaded when importing this module + # FormatsToProcess = @() + + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + # NestedModules = @() + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @( + # completers + 'ArgK8sGetClusters' + 'ArgK8sGetContexts' + 'ArgK8sGetNamespaces' + 'ArgK8sGetPods' + 'ArgK8sGetPodContainers' + 'ArgK8sGetSecrets' + # helper + 'Get-KubectlVersion' + 'Get-KubectlClientVersion' + 'Get-KubectlServerVersion' + 'Set-KubectlLocal' + 'Get-KubectlContext' + 'Set-KubectlContext' + 'Remove-KubectlContext' + 'Get-KubectlSecretDecodedData' + 'Set-KubectlContextCurrentNamespace' + 'Set-KubensContextCurrentNamespace' + 'Connect-KubernetesContainer' + 'Debug-KubernetesPod' + 'Get-KubectlPodContainers' + 'Get-KubectlPodLogs' + 'Get-KubectlApiResourceShortNames' + # pods + 'kgpo' + 'kgpocntr' + 'kdpo' + 'ktno' + 'ktpo' + 'ktpocntr' + 'kgporsrc' + # alias + 'kinf' + 'kav' + 'kcv' + 'ksys' + 'ka' + 'kadryc' + 'kadrys' + 'ksysa' + 'kak' + 'kk' + 'krmk' + 'kre' + 'kre!' + 'kref' + 'kref!' + 'ksysex' + 'ksyslo' + 'ksyslop' + 'kp' + 'kpf' + 'kg' + 'ksysg' + 'kd' + 'ksysd' + 'krm' + 'ksysrm' + 'krun' + 'ksysrun' + 'ksysgpo' + 'ksysdpo' + 'krmpo' + 'ksysrmpo' + 'kgdep' + 'ksysgdep' + 'kddep' + 'ksysddep' + 'krmdep' + 'ksysrmdep' + 'kgsvc' + 'ksysgsvc' + 'kdsvc' + 'ksysdsvc' + 'krmsvc' + 'ksysrmsvc' + 'kging' + 'ksysging' + 'kding' + 'ksysding' + 'krming' + 'ksysrming' + 'kgcm' + 'ksysgcm' + 'kdcm' + 'ksysdcm' + 'krmcm' + 'ksysrmcm' + 'kgsec' + 'kgsecd' + 'ksysgsec' + 'kdsec' + 'ksysdsec' + 'krmsec' + 'ksysrmsec' + 'kgno' + 'kdno' + 'kgns' + 'kdns' + 'krmns' + 'kgoyaml' + 'ksysgoyaml' + 'kgpooyaml' + 'ksysgpooyaml' + 'kgdepoyaml' + 'ksysgdepoyaml' + 'kgsvcoyaml' + 'ksysgsvcoyaml' + 'kgingoyaml' + 'ksysgingoyaml' + 'kgcmoyaml' + 'ksysgcmoyaml' + 'kgsecoyaml' + 'ksysgsecoyaml' + 'kgnooyaml' + 'kgnsoyaml' + 'kgowide' + 'ksysgowide' + 'kgpoowide' + 'ksysgpoowide' + 'kgdepowide' + 'ksysgdepowide' + 'kgsvcowide' + 'ksysgsvcowide' + 'kgingowide' + 'ksysgingowide' + 'kgcmowide' + 'ksysgcmowide' + 'kgsecowide' + 'ksysgsecowide' + 'kgnoowide' + 'kgnsowide' + 'kgojson' + 'ksysgojson' + 'kgpoojson' + 'ksysgpoojson' + 'kgdepojson' + 'ksysgdepojson' + 'kgsvcojson' + 'ksysgsvcojson' + 'kgingojson' + 'ksysgingojson' + 'kgcmojson' + 'ksysgcmojson' + 'kgsecojson' + 'ksysgsecojson' + 'kgnoojson' + 'kgnsojson' + 'kga' + 'kgall' + 'kdall' + 'kgpoall' + 'kdpoall' + 'kgdepall' + 'kddepall' + 'kgsvcall' + 'kdsvcall' + 'kgingall' + 'kdingall' + 'kgcmall' + 'kdcmall' + 'kgsecall' + 'kdsecall' + 'kgnsall' + 'kdnsall' + 'kgsl' + 'ksysgsl' + 'kgposl' + 'ksysgposl' + 'kgdepsl' + 'ksysgdepsl' + 'krmall' + 'ksysrmall' + 'krmpoall' + 'ksysrmpoall' + 'krmdepall' + 'ksysrmdepall' + 'krmsvcall' + 'ksysrmsvcall' + 'krmingall' + 'ksysrmingall' + 'krmcmall' + 'ksysrmcmall' + 'krmsecall' + 'ksysrmsecall' + 'krmnsall' + 'kgw' + 'ksysgw' + 'kgpow' + 'ksysgpow' + 'kgdepw' + 'ksysgdepw' + 'kgsvcw' + 'ksysgsvcw' + 'kgingw' + 'ksysgingw' + 'kgcmw' + 'ksysgcmw' + 'kgsecw' + 'ksysgsecw' + 'kgnow' + 'kgnsw' + 'kgoyamlall' + 'kgpooyamlall' + 'kgdepoyamlall' + 'kgsvcoyamlall' + 'kgingoyamlall' + 'kgcmoyamlall' + 'kgsecoyamlall' + 'kgnsoyamlall' + 'kgalloyaml' + 'kgpoalloyaml' + 'kgdepalloyaml' + 'kgsvcalloyaml' + 'kgingalloyaml' + 'kgcmalloyaml' + 'kgsecalloyaml' + 'kgnsalloyaml' + 'kgwoyaml' + 'ksysgwoyaml' + 'kgpowoyaml' + 'ksysgpowoyaml' + 'kgdepwoyaml' + 'ksysgdepwoyaml' + 'kgsvcwoyaml' + 'ksysgsvcwoyaml' + 'kgingwoyaml' + 'ksysgingwoyaml' + 'kgcmwoyaml' + 'ksysgcmwoyaml' + 'kgsecwoyaml' + 'ksysgsecwoyaml' + 'kgnowoyaml' + 'kgnswoyaml' + 'kgowideall' + 'kgpoowideall' + 'kgdepowideall' + 'kgsvcowideall' + 'kgingowideall' + 'kgcmowideall' + 'kgsecowideall' + 'kgnsowideall' + 'kgallowide' + 'kgpoallowide' + 'kgdepallowide' + 'kgsvcallowide' + 'kgingallowide' + 'kgcmallowide' + 'kgsecallowide' + 'kgnsallowide' + 'kgowidesl' + 'ksysgowidesl' + 'kgpoowidesl' + 'ksysgpoowidesl' + 'kgdepowidesl' + 'ksysgdepowidesl' + 'kgslowide' + 'ksysgslowide' + 'kgposlowide' + 'ksysgposlowide' + 'kgdepslowide' + 'ksysgdepslowide' + 'kgwowide' + 'ksysgwowide' + 'kgpowowide' + 'ksysgpowowide' + 'kgdepwowide' + 'ksysgdepwowide' + 'kgsvcwowide' + 'ksysgsvcwowide' + 'kgingwowide' + 'ksysgingwowide' + 'kgcmwowide' + 'ksysgcmwowide' + 'kgsecwowide' + 'ksysgsecwowide' + 'kgnowowide' + 'kgnswowide' + 'kgojsonall' + 'kgpoojsonall' + 'kgdepojsonall' + 'kgsvcojsonall' + 'kgingojsonall' + 'kgcmojsonall' + 'kgsecojsonall' + 'kgnsojsonall' + 'kgallojson' + 'kgpoallojson' + 'kgdepallojson' + 'kgsvcallojson' + 'kgingallojson' + 'kgcmallojson' + 'kgsecallojson' + 'kgnsallojson' + 'kgwojson' + 'ksysgwojson' + 'kgpowojson' + 'ksysgpowojson' + 'kgdepwojson' + 'ksysgdepwojson' + 'kgsvcwojson' + 'ksysgsvcwojson' + 'kgingwojson' + 'ksysgingwojson' + 'kgcmwojson' + 'ksysgcmwojson' + 'kgsecwojson' + 'ksysgsecwojson' + 'kgnowojson' + 'kgnswojson' + 'kgallsl' + 'kgpoallsl' + 'kgdepallsl' + 'kgslall' + 'kgposlall' + 'kgdepslall' + 'kgallw' + 'kgpoallw' + 'kgdepallw' + 'kgsvcallw' + 'kgingallw' + 'kgcmallw' + 'kgsecallw' + 'kgnsallw' + 'kgwall' + 'kgpowall' + 'kgdepwall' + 'kgsvcwall' + 'kgingwall' + 'kgcmwall' + 'kgsecwall' + 'kgnswall' + 'kgslw' + 'ksysgslw' + 'kgposlw' + 'ksysgposlw' + 'kgdepslw' + 'ksysgdepslw' + 'kgwsl' + 'ksysgwsl' + 'kgpowsl' + 'ksysgpowsl' + 'kgdepwsl' + 'ksysgdepwsl' + 'kgallwoyaml' + 'kgpoallwoyaml' + 'kgdepallwoyaml' + 'kgsvcallwoyaml' + 'kgingallwoyaml' + 'kgcmallwoyaml' + 'kgsecallwoyaml' + 'kgnsallwoyaml' + 'kgwoyamlall' + 'kgpowoyamlall' + 'kgdepwoyamlall' + 'kgsvcwoyamlall' + 'kgingwoyamlall' + 'kgcmwoyamlall' + 'kgsecwoyamlall' + 'kgnswoyamlall' + 'kgwalloyaml' + 'kgpowalloyaml' + 'kgdepwalloyaml' + 'kgsvcwalloyaml' + 'kgingwalloyaml' + 'kgcmwalloyaml' + 'kgsecwalloyaml' + 'kgnswalloyaml' + 'kgowideallsl' + 'kgpoowideallsl' + 'kgdepowideallsl' + 'kgowideslall' + 'kgpoowideslall' + 'kgdepowideslall' + 'kgallowidesl' + 'kgpoallowidesl' + 'kgdepallowidesl' + 'kgallslowide' + 'kgpoallslowide' + 'kgdepallslowide' + 'kgslowideall' + 'kgposlowideall' + 'kgdepslowideall' + 'kgslallowide' + 'kgposlallowide' + 'kgdepslallowide' + 'kgallwowide' + 'kgpoallwowide' + 'kgdepallwowide' + 'kgsvcallwowide' + 'kgingallwowide' + 'kgcmallwowide' + 'kgsecallwowide' + 'kgnsallwowide' + 'kgwowideall' + 'kgpowowideall' + 'kgdepwowideall' + 'kgsvcwowideall' + 'kgingwowideall' + 'kgcmwowideall' + 'kgsecwowideall' + 'kgnswowideall' + 'kgwallowide' + 'kgpowallowide' + 'kgdepwallowide' + 'kgsvcwallowide' + 'kgingwallowide' + 'kgcmwallowide' + 'kgsecwallowide' + 'kgnswallowide' + 'kgslwowide' + 'ksysgslwowide' + 'kgposlwowide' + 'ksysgposlwowide' + 'kgdepslwowide' + 'ksysgdepslwowide' + 'kgwowidesl' + 'ksysgwowidesl' + 'kgpowowidesl' + 'ksysgpowowidesl' + 'kgdepwowidesl' + 'ksysgdepwowidesl' + 'kgwslowide' + 'ksysgwslowide' + 'kgpowslowide' + 'ksysgpowslowide' + 'kgdepwslowide' + 'ksysgdepwslowide' + 'kgallwojson' + 'kgpoallwojson' + 'kgdepallwojson' + 'kgsvcallwojson' + 'kgingallwojson' + 'kgcmallwojson' + 'kgsecallwojson' + 'kgnsallwojson' + 'kgwojsonall' + 'kgpowojsonall' + 'kgdepwojsonall' + 'kgsvcwojsonall' + 'kgingwojsonall' + 'kgcmwojsonall' + 'kgsecwojsonall' + 'kgnswojsonall' + 'kgwallojson' + 'kgpowallojson' + 'kgdepwallojson' + 'kgsvcwallojson' + 'kgingwallojson' + 'kgcmwallojson' + 'kgsecwallojson' + 'kgnswallojson' + 'kgallslw' + 'kgpoallslw' + 'kgdepallslw' + 'kgallwsl' + 'kgpoallwsl' + 'kgdepallwsl' + 'kgslallw' + 'kgposlallw' + 'kgdepslallw' + 'kgslwall' + 'kgposlwall' + 'kgdepslwall' + 'kgwallsl' + 'kgpowallsl' + 'kgdepwallsl' + 'kgwslall' + 'kgpowslall' + 'kgdepwslall' + 'kgallslwowide' + 'kgpoallslwowide' + 'kgdepallslwowide' + 'kgallwowidesl' + 'kgpoallwowidesl' + 'kgdepallwowidesl' + 'kgallwslowide' + 'kgpoallwslowide' + 'kgdepallwslowide' + 'kgslallwowide' + 'kgposlallwowide' + 'kgdepslallwowide' + 'kgslwowideall' + 'kgposlwowideall' + 'kgdepslwowideall' + 'kgslwallowide' + 'kgposlwallowide' + 'kgdepslwallowide' + 'kgwowideallsl' + 'kgpowowideallsl' + 'kgdepwowideallsl' + 'kgwowideslall' + 'kgpowowideslall' + 'kgdepwowideslall' + 'kgwallowidesl' + 'kgpowallowidesl' + 'kgdepwallowidesl' + 'kgwallslowide' + 'kgpowallslowide' + 'kgdepwallslowide' + 'kgwslowideall' + 'kgpowslowideall' + 'kgdepwslowideall' + 'kgwslallowide' + 'kgpowslallowide' + 'kgdepwslallowide' + 'kgf' + 'kdf' + 'krmf' + 'kgoyamlf' + 'kgowidef' + 'kgojsonf' + 'kgslf' + 'kgwf' + 'kgwoyamlf' + 'kgowideslf' + 'kgslowidef' + 'kgwowidef' + 'kgwojsonf' + 'kgslwf' + 'kgwslf' + 'kgslwowidef' + 'kgwowideslf' + 'kgwslowidef' + 'kgl' + 'ksysgl' + 'kdl' + 'ksysdl' + 'krml' + 'ksysrml' + 'kgpol' + 'ksysgpol' + 'kdpol' + 'ksysdpol' + 'krmpol' + 'ksysrmpol' + 'kgdepl' + 'ksysgdepl' + 'kddepl' + 'ksysddepl' + 'krmdepl' + 'ksysrmdepl' + 'kgsvcl' + 'ksysgsvcl' + 'kdsvcl' + 'ksysdsvcl' + 'krmsvcl' + 'ksysrmsvcl' + 'kgingl' + 'ksysgingl' + 'kdingl' + 'ksysdingl' + 'krmingl' + 'ksysrmingl' + 'kgcml' + 'ksysgcml' + 'kdcml' + 'ksysdcml' + 'krmcml' + 'ksysrmcml' + 'kgsecl' + 'ksysgsecl' + 'kdsecl' + 'ksysdsecl' + 'krmsecl' + 'ksysrmsecl' + 'kgnol' + 'kdnol' + 'kgnsl' + 'kdnsl' + 'krmnsl' + 'kgoyamll' + 'ksysgoyamll' + 'kgpooyamll' + 'ksysgpooyamll' + 'kgdepoyamll' + 'ksysgdepoyamll' + 'kgsvcoyamll' + 'ksysgsvcoyamll' + 'kgingoyamll' + 'ksysgingoyamll' + 'kgcmoyamll' + 'ksysgcmoyamll' + 'kgsecoyamll' + 'ksysgsecoyamll' + 'kgnooyamll' + 'kgnsoyamll' + 'kgowidel' + 'ksysgowidel' + 'kgpoowidel' + 'ksysgpoowidel' + 'kgdepowidel' + 'ksysgdepowidel' + 'kgsvcowidel' + 'ksysgsvcowidel' + 'kgingowidel' + 'ksysgingowidel' + 'kgcmowidel' + 'ksysgcmowidel' + 'kgsecowidel' + 'ksysgsecowidel' + 'kgnoowidel' + 'kgnsowidel' + 'kgojsonl' + 'ksysgojsonl' + 'kgpoojsonl' + 'ksysgpoojsonl' + 'kgdepojsonl' + 'ksysgdepojsonl' + 'kgsvcojsonl' + 'ksysgsvcojsonl' + 'kgingojsonl' + 'ksysgingojsonl' + 'kgcmojsonl' + 'ksysgcmojsonl' + 'kgsecojsonl' + 'ksysgsecojsonl' + 'kgnoojsonl' + 'kgnsojsonl' + 'kgsll' + 'ksysgsll' + 'kgposll' + 'ksysgposll' + 'kgdepsll' + 'ksysgdepsll' + 'kgwl' + 'ksysgwl' + 'kgpowl' + 'ksysgpowl' + 'kgdepwl' + 'ksysgdepwl' + 'kgsvcwl' + 'ksysgsvcwl' + 'kgingwl' + 'ksysgingwl' + 'kgcmwl' + 'ksysgcmwl' + 'kgsecwl' + 'ksysgsecwl' + 'kgnowl' + 'kgnswl' + 'kgwoyamll' + 'ksysgwoyamll' + 'kgpowoyamll' + 'ksysgpowoyamll' + 'kgdepwoyamll' + 'ksysgdepwoyamll' + 'kgsvcwoyamll' + 'ksysgsvcwoyamll' + 'kgingwoyamll' + 'ksysgingwoyamll' + 'kgcmwoyamll' + 'ksysgcmwoyamll' + 'kgsecwoyamll' + 'ksysgsecwoyamll' + 'kgnowoyamll' + 'kgnswoyamll' + 'kgowidesll' + 'ksysgowidesll' + 'kgpoowidesll' + 'ksysgpoowidesll' + 'kgdepowidesll' + 'ksysgdepowidesll' + 'kgslowidel' + 'ksysgslowidel' + 'kgposlowidel' + 'ksysgposlowidel' + 'kgdepslowidel' + 'ksysgdepslowidel' + 'kgwowidel' + 'ksysgwowidel' + 'kgpowowidel' + 'ksysgpowowidel' + 'kgdepwowidel' + 'ksysgdepwowidel' + 'kgsvcwowidel' + 'ksysgsvcwowidel' + 'kgingwowidel' + 'ksysgingwowidel' + 'kgcmwowidel' + 'ksysgcmwowidel' + 'kgsecwowidel' + 'ksysgsecwowidel' + 'kgnowowidel' + 'kgnswowidel' + 'kgwojsonl' + 'ksysgwojsonl' + 'kgpowojsonl' + 'ksysgpowojsonl' + 'kgdepwojsonl' + 'ksysgdepwojsonl' + 'kgsvcwojsonl' + 'ksysgsvcwojsonl' + 'kgingwojsonl' + 'ksysgingwojsonl' + 'kgcmwojsonl' + 'ksysgcmwojsonl' + 'kgsecwojsonl' + 'ksysgsecwojsonl' + 'kgnowojsonl' + 'kgnswojsonl' + 'kgslwl' + 'ksysgslwl' + 'kgposlwl' + 'ksysgposlwl' + 'kgdepslwl' + 'ksysgdepslwl' + 'kgwsll' + 'ksysgwsll' + 'kgpowsll' + 'ksysgpowsll' + 'kgdepwsll' + 'ksysgdepwsll' + 'kgslwowidel' + 'ksysgslwowidel' + 'kgposlwowidel' + 'ksysgposlwowidel' + 'kgdepslwowidel' + 'ksysgdepslwowidel' + 'kgwowidesll' + 'ksysgwowidesll' + 'kgpowowidesll' + 'ksysgpowowidesll' + 'kgdepwowidesll' + 'ksysgdepwowidesll' + 'kgwslowidel' + 'ksysgwslowidel' + 'kgpowslowidel' + 'ksysgpowslowidel' + 'kgdepwslowidel' + 'ksysgdepwslowidel' + 'kpfn' + 'kgn' + 'kdn' + 'krmn' + 'kgponr' + 'kgponrall' + 'kgpon' + 'kdpon' + 'krmponr' + 'krmpon' + 'kgdepn' + 'kddepn' + 'krmdepn' + 'kgsvcn' + 'kdsvcn' + 'krmsvcn' + 'kgingn' + 'kdingn' + 'krmingn' + 'kgcmn' + 'kdcmn' + 'krmcmn' + 'kgsecn' + 'kdsecn' + 'krmsecn' + 'kgoyamln' + 'kgpooyamln' + 'kgdepoyamln' + 'kgsvcoyamln' + 'kgingoyamln' + 'kgcmoyamln' + 'kgsecoyamln' + 'kgowiden' + 'kgpoowiden' + 'kgdepowiden' + 'kgsvcowiden' + 'kgingowiden' + 'kgcmowiden' + 'kgsecowiden' + 'kgojsonn' + 'kgpoojsonn' + 'kgdepojsonn' + 'kgsvcojsonn' + 'kgingojsonn' + 'kgcmojsonn' + 'kgsecojsonn' + 'kgsln' + 'kgposln' + 'kgdepsln' + 'kgwn' + 'kgpown' + 'kgdepwn' + 'kgsvcwn' + 'kgingwn' + 'kgcmwn' + 'kgsecwn' + 'kgwoyamln' + 'kgpowoyamln' + 'kgdepwoyamln' + 'kgsvcwoyamln' + 'kgingwoyamln' + 'kgcmwoyamln' + 'kgsecwoyamln' + 'kgowidesln' + 'kgpoowidesln' + 'kgdepowidesln' + 'kgslowiden' + 'kgposlowiden' + 'kgdepslowiden' + 'kgwowiden' + 'kgpowowiden' + 'kgdepwowiden' + 'kgsvcwowiden' + 'kgingwowiden' + 'kgcmwowiden' + 'kgsecwowiden' + 'kgwojsonn' + 'kgpowojsonn' + 'kgdepwojsonn' + 'kgsvcwojsonn' + 'kgingwojsonn' + 'kgcmwojsonn' + 'kgsecwojsonn' + 'kgslwn' + 'kgposlwn' + 'kgdepslwn' + 'kgwsln' + 'kgpowsln' + 'kgdepwsln' + 'kgslwowiden' + 'kgposlwowiden' + 'kgdepslwowiden' + 'kgwowidesln' + 'kgpowowidesln' + 'kgdepwowidesln' + 'kgwslowiden' + 'kgpowslowiden' + 'kgdepwslowiden' + ) + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = '*' + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @( + 'kv' + 'kvc' + 'kvs' + 'kcgctx' + 'kc' + 'kcuctx' + 'kcrmctx' + 'kcsctxcns' + 'kn' + 'kex' + 'kdbg' + 'klo' + 'kapishorts' + ) + + # DSC resources to export from this module + # DscResourcesToExport = @() + + # List of all modules packaged with this module + # ModuleList = @() + + # List of all files packaged with this module + # FileList = @() + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + LicenseUri = 'https://github.com/szymonos/ps-modules/blob/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/szymonos/ps-modules' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + Prerelease = 'beta' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + } # End of PrivateData hashtable + + # HelpInfo URI of this module + # HelpInfoURI = '' + + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' + +} diff --git a/modules/aliases-kubectl/aliases-kubectl.psm1 b/modules/aliases-kubectl/aliases-kubectl.psm1 new file mode 100644 index 00000000..66828c3d --- /dev/null +++ b/modules/aliases-kubectl/aliases-kubectl.psm1 @@ -0,0 +1,858 @@ +. $PSScriptRoot/Functions/alias.ps1 +. $PSScriptRoot/Functions/completers.ps1 +. $PSScriptRoot/Functions/helper.ps1 +. $PSScriptRoot/Functions/internal.ps1 +. $PSScriptRoot/Functions/pods.ps1 +. $PSScriptRoot/Functions/secrets.ps1 + +$exportModuleMemberParams = @{ + Function = @( + # completers + 'ArgK8sGetClusters' + 'ArgK8sGetContexts' + 'ArgK8sGetNamespaces' + 'ArgK8sGetPods' + 'ArgK8sGetPodContainers' + 'ArgK8sGetSecrets' + # helper + 'Get-KubectlVersion' + 'Get-KubectlClientVersion' + 'Get-KubectlServerVersion' + 'Set-KubectlLocal' + 'Get-KubectlContext' + 'Set-KubectlContext' + 'Remove-KubectlContext' + 'Get-KubectlSecretDecodedData' + 'Set-KubectlContextCurrentNamespace' + 'Set-KubensContextCurrentNamespace' + 'Connect-KubernetesContainer' + 'Debug-KubernetesPod' + 'Get-KubectlPodContainers' + 'Get-KubectlPodLogs' + 'Get-KubectlApiResourceShortNames' + # pods + 'kgpo' + 'kgpocntr' + 'kdpo' + 'ktno' + 'ktpo' + 'ktpocntr' + 'kgporsrc' + # alias + 'kinf' + 'kav' + 'kcv' + 'ksys' + 'ka' + 'kadryc' + 'kadrys' + 'ksysa' + 'kak' + 'kk' + 'krmk' + 'kre' + 'kre!' + 'kref' + 'kref!' + 'ksysex' + 'ksyslo' + 'ksyslop' + 'kp' + 'kpf' + 'kg' + 'ksysg' + 'kd' + 'ksysd' + 'krm' + 'ksysrm' + 'krun' + 'ksysrun' + 'ksysgpo' + 'ksysdpo' + 'krmpo' + 'ksysrmpo' + 'kgdep' + 'ksysgdep' + 'kddep' + 'ksysddep' + 'krmdep' + 'ksysrmdep' + 'kgsvc' + 'ksysgsvc' + 'kdsvc' + 'ksysdsvc' + 'krmsvc' + 'ksysrmsvc' + 'kging' + 'ksysging' + 'kding' + 'ksysding' + 'krming' + 'ksysrming' + 'kgcm' + 'ksysgcm' + 'kdcm' + 'ksysdcm' + 'krmcm' + 'ksysrmcm' + 'kgsec' + 'kgsecd' + 'ksysgsec' + 'kdsec' + 'ksysdsec' + 'krmsec' + 'ksysrmsec' + 'kgno' + 'kdno' + 'kgns' + 'kdns' + 'krmns' + 'kgoyaml' + 'ksysgoyaml' + 'kgpooyaml' + 'ksysgpooyaml' + 'kgdepoyaml' + 'ksysgdepoyaml' + 'kgsvcoyaml' + 'ksysgsvcoyaml' + 'kgingoyaml' + 'ksysgingoyaml' + 'kgcmoyaml' + 'ksysgcmoyaml' + 'kgsecoyaml' + 'ksysgsecoyaml' + 'kgnooyaml' + 'kgnsoyaml' + 'kgowide' + 'ksysgowide' + 'kgpoowide' + 'ksysgpoowide' + 'kgdepowide' + 'ksysgdepowide' + 'kgsvcowide' + 'ksysgsvcowide' + 'kgingowide' + 'ksysgingowide' + 'kgcmowide' + 'ksysgcmowide' + 'kgsecowide' + 'ksysgsecowide' + 'kgnoowide' + 'kgnsowide' + 'kgojson' + 'ksysgojson' + 'kgpoojson' + 'ksysgpoojson' + 'kgdepojson' + 'ksysgdepojson' + 'kgsvcojson' + 'ksysgsvcojson' + 'kgingojson' + 'ksysgingojson' + 'kgcmojson' + 'ksysgcmojson' + 'kgsecojson' + 'ksysgsecojson' + 'kgnoojson' + 'kgnsojson' + 'kga' + 'kgall' + 'kdall' + 'kgpoall' + 'kdpoall' + 'kgdepall' + 'kddepall' + 'kgsvcall' + 'kdsvcall' + 'kgingall' + 'kdingall' + 'kgcmall' + 'kdcmall' + 'kgsecall' + 'kdsecall' + 'kgnsall' + 'kdnsall' + 'kgsl' + 'ksysgsl' + 'kgposl' + 'ksysgposl' + 'kgdepsl' + 'ksysgdepsl' + 'krmall' + 'ksysrmall' + 'krmpoall' + 'ksysrmpoall' + 'krmdepall' + 'ksysrmdepall' + 'krmsvcall' + 'ksysrmsvcall' + 'krmingall' + 'ksysrmingall' + 'krmcmall' + 'ksysrmcmall' + 'krmsecall' + 'ksysrmsecall' + 'krmnsall' + 'kgw' + 'ksysgw' + 'kgpow' + 'ksysgpow' + 'kgdepw' + 'ksysgdepw' + 'kgsvcw' + 'ksysgsvcw' + 'kgingw' + 'ksysgingw' + 'kgcmw' + 'ksysgcmw' + 'kgsecw' + 'ksysgsecw' + 'kgnow' + 'kgnsw' + 'kgoyamlall' + 'kgpooyamlall' + 'kgdepoyamlall' + 'kgsvcoyamlall' + 'kgingoyamlall' + 'kgcmoyamlall' + 'kgsecoyamlall' + 'kgnsoyamlall' + 'kgalloyaml' + 'kgpoalloyaml' + 'kgdepalloyaml' + 'kgsvcalloyaml' + 'kgingalloyaml' + 'kgcmalloyaml' + 'kgsecalloyaml' + 'kgnsalloyaml' + 'kgwoyaml' + 'ksysgwoyaml' + 'kgpowoyaml' + 'ksysgpowoyaml' + 'kgdepwoyaml' + 'ksysgdepwoyaml' + 'kgsvcwoyaml' + 'ksysgsvcwoyaml' + 'kgingwoyaml' + 'ksysgingwoyaml' + 'kgcmwoyaml' + 'ksysgcmwoyaml' + 'kgsecwoyaml' + 'ksysgsecwoyaml' + 'kgnowoyaml' + 'kgnswoyaml' + 'kgowideall' + 'kgpoowideall' + 'kgdepowideall' + 'kgsvcowideall' + 'kgingowideall' + 'kgcmowideall' + 'kgsecowideall' + 'kgnsowideall' + 'kgallowide' + 'kgpoallowide' + 'kgdepallowide' + 'kgsvcallowide' + 'kgingallowide' + 'kgcmallowide' + 'kgsecallowide' + 'kgnsallowide' + 'kgowidesl' + 'ksysgowidesl' + 'kgpoowidesl' + 'ksysgpoowidesl' + 'kgdepowidesl' + 'ksysgdepowidesl' + 'kgslowide' + 'ksysgslowide' + 'kgposlowide' + 'ksysgposlowide' + 'kgdepslowide' + 'ksysgdepslowide' + 'kgwowide' + 'ksysgwowide' + 'kgpowowide' + 'ksysgpowowide' + 'kgdepwowide' + 'ksysgdepwowide' + 'kgsvcwowide' + 'ksysgsvcwowide' + 'kgingwowide' + 'ksysgingwowide' + 'kgcmwowide' + 'ksysgcmwowide' + 'kgsecwowide' + 'ksysgsecwowide' + 'kgnowowide' + 'kgnswowide' + 'kgojsonall' + 'kgpoojsonall' + 'kgdepojsonall' + 'kgsvcojsonall' + 'kgingojsonall' + 'kgcmojsonall' + 'kgsecojsonall' + 'kgnsojsonall' + 'kgallojson' + 'kgpoallojson' + 'kgdepallojson' + 'kgsvcallojson' + 'kgingallojson' + 'kgcmallojson' + 'kgsecallojson' + 'kgnsallojson' + 'kgwojson' + 'ksysgwojson' + 'kgpowojson' + 'ksysgpowojson' + 'kgdepwojson' + 'ksysgdepwojson' + 'kgsvcwojson' + 'ksysgsvcwojson' + 'kgingwojson' + 'ksysgingwojson' + 'kgcmwojson' + 'ksysgcmwojson' + 'kgsecwojson' + 'ksysgsecwojson' + 'kgnowojson' + 'kgnswojson' + 'kgallsl' + 'kgpoallsl' + 'kgdepallsl' + 'kgslall' + 'kgposlall' + 'kgdepslall' + 'kgallw' + 'kgpoallw' + 'kgdepallw' + 'kgsvcallw' + 'kgingallw' + 'kgcmallw' + 'kgsecallw' + 'kgnsallw' + 'kgwall' + 'kgpowall' + 'kgdepwall' + 'kgsvcwall' + 'kgingwall' + 'kgcmwall' + 'kgsecwall' + 'kgnswall' + 'kgslw' + 'ksysgslw' + 'kgposlw' + 'ksysgposlw' + 'kgdepslw' + 'ksysgdepslw' + 'kgwsl' + 'ksysgwsl' + 'kgpowsl' + 'ksysgpowsl' + 'kgdepwsl' + 'ksysgdepwsl' + 'kgallwoyaml' + 'kgpoallwoyaml' + 'kgdepallwoyaml' + 'kgsvcallwoyaml' + 'kgingallwoyaml' + 'kgcmallwoyaml' + 'kgsecallwoyaml' + 'kgnsallwoyaml' + 'kgwoyamlall' + 'kgpowoyamlall' + 'kgdepwoyamlall' + 'kgsvcwoyamlall' + 'kgingwoyamlall' + 'kgcmwoyamlall' + 'kgsecwoyamlall' + 'kgnswoyamlall' + 'kgwalloyaml' + 'kgpowalloyaml' + 'kgdepwalloyaml' + 'kgsvcwalloyaml' + 'kgingwalloyaml' + 'kgcmwalloyaml' + 'kgsecwalloyaml' + 'kgnswalloyaml' + 'kgowideallsl' + 'kgpoowideallsl' + 'kgdepowideallsl' + 'kgowideslall' + 'kgpoowideslall' + 'kgdepowideslall' + 'kgallowidesl' + 'kgpoallowidesl' + 'kgdepallowidesl' + 'kgallslowide' + 'kgpoallslowide' + 'kgdepallslowide' + 'kgslowideall' + 'kgposlowideall' + 'kgdepslowideall' + 'kgslallowide' + 'kgposlallowide' + 'kgdepslallowide' + 'kgallwowide' + 'kgpoallwowide' + 'kgdepallwowide' + 'kgsvcallwowide' + 'kgingallwowide' + 'kgcmallwowide' + 'kgsecallwowide' + 'kgnsallwowide' + 'kgwowideall' + 'kgpowowideall' + 'kgdepwowideall' + 'kgsvcwowideall' + 'kgingwowideall' + 'kgcmwowideall' + 'kgsecwowideall' + 'kgnswowideall' + 'kgwallowide' + 'kgpowallowide' + 'kgdepwallowide' + 'kgsvcwallowide' + 'kgingwallowide' + 'kgcmwallowide' + 'kgsecwallowide' + 'kgnswallowide' + 'kgslwowide' + 'ksysgslwowide' + 'kgposlwowide' + 'ksysgposlwowide' + 'kgdepslwowide' + 'ksysgdepslwowide' + 'kgwowidesl' + 'ksysgwowidesl' + 'kgpowowidesl' + 'ksysgpowowidesl' + 'kgdepwowidesl' + 'ksysgdepwowidesl' + 'kgwslowide' + 'ksysgwslowide' + 'kgpowslowide' + 'ksysgpowslowide' + 'kgdepwslowide' + 'ksysgdepwslowide' + 'kgallwojson' + 'kgpoallwojson' + 'kgdepallwojson' + 'kgsvcallwojson' + 'kgingallwojson' + 'kgcmallwojson' + 'kgsecallwojson' + 'kgnsallwojson' + 'kgwojsonall' + 'kgpowojsonall' + 'kgdepwojsonall' + 'kgsvcwojsonall' + 'kgingwojsonall' + 'kgcmwojsonall' + 'kgsecwojsonall' + 'kgnswojsonall' + 'kgwallojson' + 'kgpowallojson' + 'kgdepwallojson' + 'kgsvcwallojson' + 'kgingwallojson' + 'kgcmwallojson' + 'kgsecwallojson' + 'kgnswallojson' + 'kgallslw' + 'kgpoallslw' + 'kgdepallslw' + 'kgallwsl' + 'kgpoallwsl' + 'kgdepallwsl' + 'kgslallw' + 'kgposlallw' + 'kgdepslallw' + 'kgslwall' + 'kgposlwall' + 'kgdepslwall' + 'kgwallsl' + 'kgpowallsl' + 'kgdepwallsl' + 'kgwslall' + 'kgpowslall' + 'kgdepwslall' + 'kgallslwowide' + 'kgpoallslwowide' + 'kgdepallslwowide' + 'kgallwowidesl' + 'kgpoallwowidesl' + 'kgdepallwowidesl' + 'kgallwslowide' + 'kgpoallwslowide' + 'kgdepallwslowide' + 'kgslallwowide' + 'kgposlallwowide' + 'kgdepslallwowide' + 'kgslwowideall' + 'kgposlwowideall' + 'kgdepslwowideall' + 'kgslwallowide' + 'kgposlwallowide' + 'kgdepslwallowide' + 'kgwowideallsl' + 'kgpowowideallsl' + 'kgdepwowideallsl' + 'kgwowideslall' + 'kgpowowideslall' + 'kgdepwowideslall' + 'kgwallowidesl' + 'kgpowallowidesl' + 'kgdepwallowidesl' + 'kgwallslowide' + 'kgpowallslowide' + 'kgdepwallslowide' + 'kgwslowideall' + 'kgpowslowideall' + 'kgdepwslowideall' + 'kgwslallowide' + 'kgpowslallowide' + 'kgdepwslallowide' + 'kgf' + 'kdf' + 'krmf' + 'kgoyamlf' + 'kgowidef' + 'kgojsonf' + 'kgslf' + 'kgwf' + 'kgwoyamlf' + 'kgowideslf' + 'kgslowidef' + 'kgwowidef' + 'kgwojsonf' + 'kgslwf' + 'kgwslf' + 'kgslwowidef' + 'kgwowideslf' + 'kgwslowidef' + 'kgl' + 'ksysgl' + 'kdl' + 'ksysdl' + 'krml' + 'ksysrml' + 'kgpol' + 'ksysgpol' + 'kdpol' + 'ksysdpol' + 'krmpol' + 'ksysrmpol' + 'kgdepl' + 'ksysgdepl' + 'kddepl' + 'ksysddepl' + 'krmdepl' + 'ksysrmdepl' + 'kgsvcl' + 'ksysgsvcl' + 'kdsvcl' + 'ksysdsvcl' + 'krmsvcl' + 'ksysrmsvcl' + 'kgingl' + 'ksysgingl' + 'kdingl' + 'ksysdingl' + 'krmingl' + 'ksysrmingl' + 'kgcml' + 'ksysgcml' + 'kdcml' + 'ksysdcml' + 'krmcml' + 'ksysrmcml' + 'kgsecl' + 'ksysgsecl' + 'kdsecl' + 'ksysdsecl' + 'krmsecl' + 'ksysrmsecl' + 'kgnol' + 'kdnol' + 'kgnsl' + 'kdnsl' + 'krmnsl' + 'kgoyamll' + 'ksysgoyamll' + 'kgpooyamll' + 'ksysgpooyamll' + 'kgdepoyamll' + 'ksysgdepoyamll' + 'kgsvcoyamll' + 'ksysgsvcoyamll' + 'kgingoyamll' + 'ksysgingoyamll' + 'kgcmoyamll' + 'ksysgcmoyamll' + 'kgsecoyamll' + 'ksysgsecoyamll' + 'kgnooyamll' + 'kgnsoyamll' + 'kgowidel' + 'ksysgowidel' + 'kgpoowidel' + 'ksysgpoowidel' + 'kgdepowidel' + 'ksysgdepowidel' + 'kgsvcowidel' + 'ksysgsvcowidel' + 'kgingowidel' + 'ksysgingowidel' + 'kgcmowidel' + 'ksysgcmowidel' + 'kgsecowidel' + 'ksysgsecowidel' + 'kgnoowidel' + 'kgnsowidel' + 'kgojsonl' + 'ksysgojsonl' + 'kgpoojsonl' + 'ksysgpoojsonl' + 'kgdepojsonl' + 'ksysgdepojsonl' + 'kgsvcojsonl' + 'ksysgsvcojsonl' + 'kgingojsonl' + 'ksysgingojsonl' + 'kgcmojsonl' + 'ksysgcmojsonl' + 'kgsecojsonl' + 'ksysgsecojsonl' + 'kgnoojsonl' + 'kgnsojsonl' + 'kgsll' + 'ksysgsll' + 'kgposll' + 'ksysgposll' + 'kgdepsll' + 'ksysgdepsll' + 'kgwl' + 'ksysgwl' + 'kgpowl' + 'ksysgpowl' + 'kgdepwl' + 'ksysgdepwl' + 'kgsvcwl' + 'ksysgsvcwl' + 'kgingwl' + 'ksysgingwl' + 'kgcmwl' + 'ksysgcmwl' + 'kgsecwl' + 'ksysgsecwl' + 'kgnowl' + 'kgnswl' + 'kgwoyamll' + 'ksysgwoyamll' + 'kgpowoyamll' + 'ksysgpowoyamll' + 'kgdepwoyamll' + 'ksysgdepwoyamll' + 'kgsvcwoyamll' + 'ksysgsvcwoyamll' + 'kgingwoyamll' + 'ksysgingwoyamll' + 'kgcmwoyamll' + 'ksysgcmwoyamll' + 'kgsecwoyamll' + 'ksysgsecwoyamll' + 'kgnowoyamll' + 'kgnswoyamll' + 'kgowidesll' + 'ksysgowidesll' + 'kgpoowidesll' + 'ksysgpoowidesll' + 'kgdepowidesll' + 'ksysgdepowidesll' + 'kgslowidel' + 'ksysgslowidel' + 'kgposlowidel' + 'ksysgposlowidel' + 'kgdepslowidel' + 'ksysgdepslowidel' + 'kgwowidel' + 'ksysgwowidel' + 'kgpowowidel' + 'ksysgpowowidel' + 'kgdepwowidel' + 'ksysgdepwowidel' + 'kgsvcwowidel' + 'ksysgsvcwowidel' + 'kgingwowidel' + 'ksysgingwowidel' + 'kgcmwowidel' + 'ksysgcmwowidel' + 'kgsecwowidel' + 'ksysgsecwowidel' + 'kgnowowidel' + 'kgnswowidel' + 'kgwojsonl' + 'ksysgwojsonl' + 'kgpowojsonl' + 'ksysgpowojsonl' + 'kgdepwojsonl' + 'ksysgdepwojsonl' + 'kgsvcwojsonl' + 'ksysgsvcwojsonl' + 'kgingwojsonl' + 'ksysgingwojsonl' + 'kgcmwojsonl' + 'ksysgcmwojsonl' + 'kgsecwojsonl' + 'ksysgsecwojsonl' + 'kgnowojsonl' + 'kgnswojsonl' + 'kgslwl' + 'ksysgslwl' + 'kgposlwl' + 'ksysgposlwl' + 'kgdepslwl' + 'ksysgdepslwl' + 'kgwsll' + 'ksysgwsll' + 'kgpowsll' + 'ksysgpowsll' + 'kgdepwsll' + 'ksysgdepwsll' + 'kgslwowidel' + 'ksysgslwowidel' + 'kgposlwowidel' + 'ksysgposlwowidel' + 'kgdepslwowidel' + 'ksysgdepslwowidel' + 'kgwowidesll' + 'ksysgwowidesll' + 'kgpowowidesll' + 'ksysgpowowidesll' + 'kgdepwowidesll' + 'ksysgdepwowidesll' + 'kgwslowidel' + 'ksysgwslowidel' + 'kgpowslowidel' + 'ksysgpowslowidel' + 'kgdepwslowidel' + 'ksysgdepwslowidel' + 'kpfn' + 'kgn' + 'kdn' + 'krmn' + 'kgponr' + 'kgponrall' + 'kgpon' + 'kdpon' + 'krmponr' + 'krmpon' + 'kgdepn' + 'kddepn' + 'krmdepn' + 'kgsvcn' + 'kdsvcn' + 'krmsvcn' + 'kgingn' + 'kdingn' + 'krmingn' + 'kgcmn' + 'kdcmn' + 'krmcmn' + 'kgsecn' + 'kdsecn' + 'krmsecn' + 'kgoyamln' + 'kgpooyamln' + 'kgdepoyamln' + 'kgsvcoyamln' + 'kgingoyamln' + 'kgcmoyamln' + 'kgsecoyamln' + 'kgowiden' + 'kgpoowiden' + 'kgdepowiden' + 'kgsvcowiden' + 'kgingowiden' + 'kgcmowiden' + 'kgsecowiden' + 'kgojsonn' + 'kgpoojsonn' + 'kgdepojsonn' + 'kgsvcojsonn' + 'kgingojsonn' + 'kgcmojsonn' + 'kgsecojsonn' + 'kgsln' + 'kgposln' + 'kgdepsln' + 'kgwn' + 'kgpown' + 'kgdepwn' + 'kgsvcwn' + 'kgingwn' + 'kgcmwn' + 'kgsecwn' + 'kgwoyamln' + 'kgpowoyamln' + 'kgdepwoyamln' + 'kgsvcwoyamln' + 'kgingwoyamln' + 'kgcmwoyamln' + 'kgsecwoyamln' + 'kgowidesln' + 'kgpoowidesln' + 'kgdepowidesln' + 'kgslowiden' + 'kgposlowiden' + 'kgdepslowiden' + 'kgwowiden' + 'kgpowowiden' + 'kgdepwowiden' + 'kgsvcwowiden' + 'kgingwowiden' + 'kgcmwowiden' + 'kgsecwowiden' + 'kgwojsonn' + 'kgpowojsonn' + 'kgdepwojsonn' + 'kgsvcwojsonn' + 'kgingwojsonn' + 'kgcmwojsonn' + 'kgsecwojsonn' + 'kgslwn' + 'kgposlwn' + 'kgdepslwn' + 'kgwsln' + 'kgpowsln' + 'kgdepwsln' + 'kgslwowiden' + 'kgposlwowiden' + 'kgdepslwowiden' + 'kgwowidesln' + 'kgpowowidesln' + 'kgdepwowidesln' + 'kgwslowiden' + 'kgpowslowiden' + 'kgdepwslowiden' + ) + Variable = @() + Alias = @( + 'kv' + 'kvc' + 'kvs' + 'kcgctx' + 'kc' + 'kcuctx' + 'kcrmctx' + 'kcsctxcns' + 'kn' + 'kex' + 'kdbg' + 'klo' + 'kapishorts' + ) +} + +Export-ModuleMember @exportModuleMemberParams diff --git a/modules/do-az/Classes/do-az.ps1 b/modules/do-az/Classes/do-az.ps1 new file mode 100644 index 00000000..914fe19a --- /dev/null +++ b/modules/do-az/Classes/do-az.ps1 @@ -0,0 +1,279 @@ +<# +.SYNOPSIS +Class of AzGraph compatible Azure objects. +#> +class AzGraphSubscription { + [string]$id + [string]$name + [string]$type + [guid]$subscriptionId + [string]$subscription + [guid]$tenantId + [psobject]$properties + [string]$ResourceId + + # constructors + AzGraphSubscription () { } + + AzGraphSubscription ([PSCustomObject]$obj) { + $this.id = $obj.id + $this.name = $obj.name + $this.type = $obj.type + $this.subscriptionId = $obj.subscriptionId + $this.subscription = $this.name + $this.tenantId = $obj.tenantId + $this.properties = $obj.properties + $this.ResourceId = $this.id + } + + AzGraphSubscription ([string]$id) { + if ($id) { + $idSplit = $id.Split('/') + if ($idSplit.Count -eq 3 -and $idSplit[1] -eq 'subscriptions') { + $this.id = $id + $this.type = 'microsoft.resources/subscriptions' + $this.subscriptionId = $idSplit[2] + $this.ResourceId = $id + } else { + throw("Wrong ResourceId provided!`n$id") + } + } + } + + [string] ToString() { + return $this.ResourceId + } +} +# Specify AzGraphResource DefaultDisplayPropertySet +Update-TypeData -TypeName 'AzGraphSubscription' -DefaultDisplayPropertySet 'name', 'type', 'subscriptionId', 'id' -ErrorAction SilentlyContinue + + +class AzGraphResourceGroup : AzGraphSubscription { + [string]$location + [string]$resourceGroup + [string]$subscription + [psobject]$tags + + # constructors + AzGraphResourceGroup () { } + + AzGraphResourceGroup ([string]$id) { + if ($id) { + $idSplit = $id.Split('/') + if ($idSplit.Count -eq 5 -and $idSplit[1] -eq 'subscriptions' -and $idSplit[3] -eq 'resourceGroups') { + $this.id = $id + $this.name = $idSplit[4] + $this.resourceGroup = $this.name.ToLower() + $this.type = 'microsoft.resources/subscriptions/resourcegroups' + $this.subscriptionId = $idSplit[2] + $this.ResourceId = $this.id + } else { + throw("Wrong ResourceId provided!`n$id") + } + } + } + + AzGraphResourceGroup ([PSCustomObject]$obj) { + $this.id = $obj.id + $this.location = $obj.location + $this.name = $obj.name + $this.resourceGroup = $obj.resourceGroup + $this.type = $obj.type + $this.subscriptionId = $obj.subscriptionId + $this.subscription = $obj.subscription + $this.tenantId = $obj.tenantId + $this.properties = $obj.properties + $this.tags = $obj.tags + $this.ResourceId = $this.id + } + + [string] ToString() { + return $this.ResourceId + } +} +# Specify AzGraphResourceGroup DefaultDisplayPropertySet +Update-TypeData -TypeName 'AzGraphResourceGroup' -DefaultDisplayPropertySet 'name', 'type', 'subscriptionId', 'subscription', 'id' -ErrorAction SilentlyContinue + + +class AzGraphResource : AzGraphResourceGroup { + [string]$kind + [psobject]$sku + [psobject]$identity + + # constructors + AzGraphResource () { } + + AzGraphResource ([string]$id) { + if ($id) { + $idSplit = $id.Split('/') + if ($idSplit.Count -eq 9 -and $idSplit[1] -eq 'subscriptions' -and $idSplit[3] -eq 'resourceGroups' -and $idSplit[5] -eq 'providers') { + $this.id = $id + $this.name = $idSplit[8] + $this.resourceGroup = $idSplit[4] + $this.type = "$($idSplit[6])/$($idSplit[7])" + $this.subscriptionId = $idSplit[2] + $this.ResourceId = $this.id + } else { + throw("Wrong ResourceId provided!`n$id") + } + } + } + + AzGraphResource ([guid]$SubscriptionId, [string]$ResourceGroup, [string]$Type, [string]$Name) { + $this.id = "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroup/providers/$Type/$Name" + $this.name = $Name + $this.resourceGroup = $ResourceGroup + $this.type = $Type + $this.subscriptionId = $SubscriptionId + $this.ResourceId = $this.id + } + + AzGraphResource ([PSCustomObject]$obj) { + $this.id = $obj.id + $this.kind = $obj.kind + $this.location = $obj.location + $this.name = $obj.name + $this.resourceGroup = $obj.resourceGroup + $this.type = $obj.type + $this.subscriptionId = $obj.subscriptionId + $this.subscription = $obj.subscription + $this.tenantId = $obj.tenantId + $this.sku = $obj.sku + $this.properties = $obj.properties + $this.tags = $obj.tags + $this.identity = $obj.identity + $this.ResourceId = $this.id + } + + AzGraphResource ([AzGraphResource]$obj) { + $this.id = $obj.id + $this.kind = $obj.kind + $this.location = $obj.location + $this.name = $obj.name + $this.resourceGroup = $obj.resourceGroup + $this.type = $obj.type + $this.subscriptionId = $obj.subscriptionId + $this.subscription = $obj.subscription + $this.tenantId = $obj.tenantId + $this.sku = $obj.sku + $this.properties = $obj.properties + $this.tags = $obj.tags + $this.identity = $obj.identity + $this.ResourceId = $this.id + } + + [AzGraphResource] GetSubscriptionName () { + $this.subscription = (Get-AzGraphSubscription -SubscriptionId $this.subscriptionId).name + + return [AzGraphResource]::new($this) + } + + [string] ToString() { + return $this.ResourceId + } +} +# Specify AzGraphResource DefaultDisplayPropertySet +Update-TypeData -TypeName 'AzGraphResource' -DefaultDisplayPropertySet 'name', 'resourceGroup', 'type', 'subscriptionId', 'id' -ErrorAction SilentlyContinue + + +<# +.SYNOPSIS +Class of Az module compatible Azure object. +#> +class AzResource { + [string]$ResourceId + [string]$Id + [string]$Kind + [string]$Location + [string]$ResourceName + [string]$Name + [string]$ResourceGroupName + [string]$ResourceType + [string]$Type + [guid]$SubscriptionId + [string]$SubscriptionName + [psobject]$Sku + [psobject]$Properties + [psobject]$Tags + [psobject]$Identity + + # constructors + AzResource () { } + + AzResource ([string]$id) { + if ($id) { + $idSplit = $id.Split('/') + if ($idSplit.Count -eq 9 -and $idSplit[1] -eq 'subscriptions' -and $idSplit[3] -eq 'resourceGroups' -and $idSplit[5] -eq 'providers') { + $this.ResourceId = $id + $this.Id = $this.ResourceId + $this.ResourceName = $idSplit[8] + $this.Name = $this.ResourceName + $this.ResourceGroupName = $idSplit[4] + $this.ResourceType = "$($idSplit[6])/$($idSplit[7])" + $this.Type = $this.ResourceType + $this.SubscriptionId = $idSplit[2] + } else { + throw("Wrong ResourceId provided!`n$id") + } + } + } + + AzResource ([guid]$subscriptionId, [string]$resourceGroupName, [string]$resourceType, [string]$name) { + $this.ResourceId = "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/$resourceType/$name" + $this.Id = $this.ResourceId + $this.ResourceName = $name + $this.Name = $this.ResourceName + $this.ResourceGroupName = $resourceGroupName + $this.ResourceType = $resourceType + $this.Type = $this.ResourceType + $this.SubscriptionId = $subscriptionId + } + + AzResource ([AzGraphResource]$obj) { + $this.ResourceId = $obj.id + $this.Id = $this.ResourceId + $this.Kind = $obj.kind + $this.Location = $obj.location + $this.ResourceName = $obj.name + $this.Name = $this.ResourceName + $this.ResourceGroupName = $obj.resourceGroup + $this.ResourceType = $obj.type + $this.Type = $this.ResourceType + $this.SubscriptionId = $obj.subscriptionId + $this.SubscriptionName = $obj.subscription + $this.Sku = $obj.sku + $this.Properties = $obj.properties + $this.Tags = $obj.tags + $this.Identity = $obj.identity + } + + AzResource ([AzResource]$obj) { + $this.ResourceId = $obj.ResourceId + $this.Id = $this.ResourceId + $this.Kind = $obj.Kind + $this.Location = $obj.Location + $this.ResourceName = $obj.ResourceName + $this.Name = $this.ResourceName + $this.ResourceGroupName = $obj.ResourceGroupName + $this.ResourceType = $obj.ResourceType + $this.Type = $this.ResourceType + $this.SubscriptionId = $obj.SubscriptionId + $this.SubscriptionName = $obj.SubscriptionName + $this.Sku = $obj.Sku + $this.Properties = $obj.Properties + $this.Tags = $obj.Tags + $this.Identity = $obj.Identity + } + + [AzResource] GetSubscriptionName () { + $this.SubscriptionName = (Get-AzGraphSubscription -SubscriptionId $this.SubscriptionId).name + + return [AzResource]::new($this) + } + + [string] ToString() { + return $this.ResourceId + } +} +# Specify AzResource DefaultDisplayPropertySet +Update-TypeData -TypeName 'AzResource' -DefaultDisplayPropertySet 'Name', 'ResourceGroupName', 'ResourceType', 'SubscriptionId', 'ResourceId' -ErrorAction SilentlyContinue diff --git a/modules/do-az/Functions/az.ps1 b/modules/do-az/Functions/az.ps1 new file mode 100644 index 00000000..8c63797b --- /dev/null +++ b/modules/do-az/Functions/az.ps1 @@ -0,0 +1,1629 @@ +<# +.SYNOPSIS +Set Az Context and eventually connect to Azure. + +.PARAMETER Subscription +Subscription Name or ID. +.PARAMETER Tenant +Tenant Name or ID. +.PARAMETER AzureCli +Switch whether to connect using the current azure-cli context with user/password authentication. +#> +function Connect-AzContext { + [CmdletBinding()] + param ( + [Alias('s')] + [string]$Subscription, + + [Alias('t')] + [string]$Tenant, + + [Alias('cli')] + [switch]$AzureCli + ) + + begin { + if ($PSBoundParameters.AzureCli) { + try { + Get-Command az -CommandType Application -ErrorAction Stop | Out-Null + $account = az account show --out json | ConvertFrom-Json + if ($account) { + if ($account.user.type -eq 'user') { + while (Get-AzContext) { + Disconnect-AzAccount | Out-Null + } + $ctx = $null + } else { + Write-Warning 'Service principal login not supported.' + $abort = $true + return + } + } else { + $abort = $true + return + } + } catch { + Write-Warning 'Azure CLI not found.' + $abort = $true + return + } + } else { + $ctx = Get-AzContext + } + } + + process { + if ($abort) { + $ctx = $null + } else { + if ($ctx) { + if ($PSBoundParameters.Subscription -and $PSBoundParameters.Subscription -notin @($ctx.Subscription.Id, $ctx.Subscription.Name)) { + $ctx = Invoke-CommandRetry { + Set-AzContext -Subscription $Subscription -Tenant $ctx.Tenant.Id + } + } + } else { + $param = @{} + if ($PSBoundParameters.Subscription) { + $param.Subscription = $Subscription + } elseif ($PSBoundParameters.AzureCli) { + $param.Subscription = $account.id + } + if ($PSBoundParameters.Tenant) { + $param.Tenant = $Tenant + } elseif ($PSBoundParameters.AzureCli) { + $param.Tenant = $account.tenantId + } + + $ctx = Invoke-CommandRetry { + if ($PSBoundParameters.AzureCli) { + Update-AzConfig -DefaultSubscriptionForLogin $param.Subscription | Out-Null + $param.Credential = Get-Credential -UserName $account.user.name + $param.WarningAction = 'SilentlyContinue' + Connect-AzAccount @param | Select-Object -ExpandProperty Context + } else { + try { + $param.WarningAction = 'Stop' + Connect-AzAccount @param 3>$null | Select-Object -ExpandProperty Context + } catch [System.Management.Automation.ActionPreferenceStopException] { + $param.WarningAction = 'SilentlyContinue' + $param.UseDeviceAuthentication = $true + Connect-AzAccount @param | Select-Object -ExpandProperty Context + } catch { + Write-Verbose $_.Exception.GetType().FullName + Write-Error $_ + } + } + } + } + } + } + + end { + return $ctx + } +} + + +<# +.SYNOPSIS +Get Azure context properties. +.DESCRIPTION +Get Azure context properties for the current user or service principal. + +.PARAMETER AzureCli +Switch whether to get context properties for azure-cli. +#> +function Get-AzCtx { + [CmdletBinding()] + param ( + [Alias('cli')] + [switch]$AzureCli + ) + + begin { + # get current Azure context and store it in a dictionary + if ($PSBoundParameters.AzureCli) { + $ctx = az account show -o json | ConvertFrom-Json + $dict = [ordered]@{ + TenantId = $ctx.tenantId + SubscriptionId = $ctx.id + SubscriptionName = $ctx.name + UserType = $ctx.user.type + } + } else { + $ctx = Get-AzContext + $dict = [ordered]@{ + TenantId = $ctx.Tenant.Id + SubscriptionId = $ctx.Subscription.Id + SubscriptionName = $ctx.Subscription.Name + UserType = $ctx.Account.Type + } + } + } + + process { + # add user or service principal properties to the dictionary + if ($PSBoundParameters.AzureCli) { + if ($ctx.user.type -eq 'servicePrincipal') { + $dict.PrincipalName = Invoke-CommandRetry { + Get-AzADServicePrincipal -ApplicationId $ctx.user.name -ErrorAction Stop + } | Select-Object -ExpandProperty DisplayName + $dict.PrincipalId = $ctx.user.name + } else { + $dict.UserName = $ctx.user.name + } + } else { + if ($ctx.Account.Type -eq 'servicePrincipal') { + $dict.PrincipalName = Invoke-CommandRetry { + Get-AzADServicePrincipal -ApplicationId $ctx.Account.Id -ErrorAction Stop + } | Select-Object -ExpandProperty DisplayName + $dict.PrincipalId = $ctx.Account.Id + } else { + $dict.UserName = $ctx.Account.Id + $dict.UserId = ($ctx.Account.ExtendedProperties.HomeAccountId).Split('.')[0] + } + } + } + + end { + # return context dictionary + [PSCustomObject]$dict + } +} + + +<# +.SYNOPSIS +Retrieves the available API versions for Azure resource types. + +.DESCRIPTION +This function queries Azure to get a list of all available API versions for the specified Azure resource types. +It can be used to ensure that scripts or deployments target compatible API versions. + +.PARAMETER Type +Specifies the resource type to get the Azure REST API versions for. +.PARAMETER Id +Specifies the resource id to get the Azure REST API versions for. +.PARAMETER Option +Specifes the option to retrieve API versions: +- Def: : latest stable and if not found latest preview (default option) +- Latest : latest version +- Stable : latest stable version +- All : all versions + +.EXAMPLE +# :get api versions by resource type +$Type = 'Microsoft.MachineLearningServices/workspaces' +Get-AzResourceTypeApiVersions $Type +Get-AzResourceTypeApiVersions $Type -Option 'Latest' +Get-AzResourceTypeApiVersions $Type -Option 'Stable' +Get-AzResourceTypeApiVersions $Type -Option 'All' +# :get AIP versions by resource id +$Id = '/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics' +Get-AzResourceTypeApiVersions -Id $Id + +.NOTES +Requires the Azure PowerShell module to be installed and an active Azure subscription login. +#> +function Get-AzResourceTypeApiVersions { + [CmdletBinding(DefaultParameterSetName = 'ByType')] + param ( + [Parameter(Mandatory, Position = 0, ParameterSetName = 'ByType')] + [string]$Type, + + [Parameter(Mandatory, Position = 0, ParameterSetName = 'ById')] + [string]$Id, + + [ValidateSet('Def', 'Latest', 'Stable', 'All')] + [string]$Option = 'Def' + ) + + process { + # determina provider namespace and resource type + switch ($PSCmdlet.ParameterSetName) { + ById { + $split = $Id.Split('/') + $idx = [array]::IndexOf($split, 'providers') + if ($idx -ge 0 -and $split[$idx + 1] -match '^microsoft\.\w+$' -and $split[$idx + 2]) { + $namespace, $type = $split[($idx + 1)..($idx + 2)] + } else { + Write-Error "Cannot determine resource type. ResourceId is incorrect ($Id)." + } + } + ByType { + $split = $Type.Split('/') + if ($split.Count -eq 2 -and $split[0] -match '^microsoft\.\w+$') { + $namespace, $type = $split + } else { + Write-Error "Provider resource type is incorrect ($Type)." + } + } + } + + [string[]]$ApiVersions = Invoke-CommandRetry { + Get-AzResourceProvider -ProviderNamespace $namespace -ErrorAction 'Stop' ` + | Select-Object -ExpandProperty ResourceTypes ` + | Where-Object { $_.ResourceTypeName -eq $type } ` + | Select-Object -ExpandProperty ApiVersions + } + + if (-not $ApiVersions) { + Write-Warning "API version for `e[4m$namespace/$type`e[24m not found." + break + } elseif ($Option -in @('Stable', 'Def')) { + $stable = $ApiVersions -notmatch '-preview$' + } + } + + end { + switch ($Option) { + All { + $ApiVersions + continue + } + Latest { + $ApiVersions[0] + continue + } + Stable { + $stable[0] + continue + } + Def { + $stable.Count -gt 0 ? $stable[0] : $ApiVersions[0] + continue + } + } + } +} + + +<# +.SYNOPSIS +Get OAuth2 access token from login.microsoftonline.com for the current user or specified Service Principal. + +.PARAMETER ResourceTypeName +Optional resource type name, supported values: AadGraph, AnalysisServices, AppConfiguration, Arm, Attestation, Batch, DataLake, KeyVault, MSGraph, OperationalInsights, ResourceManager, Storage, Synapse. +Default value is Arm if not specified. +.PARAMETER ResourceUrl +Resource url for that you're requesting token, e.g. 'https://graph.microsoft.com/'. +.PARAMETER ClientId +Service Principal application id. +.PARAMETER ClientSecret +Service Principal credential. +.PARAMETER Credential +PSCredential object with username and password. +.PARAMETER AsPlainText +When set, the function will convert secret in secure string to the decrypted plaintext string as output. +#> +function Get-MsoToken { + [CmdletBinding(DefaultParameterSetName = 'ByType')] + param ( + [Alias('t')] + [Parameter(ParameterSetName = 'ByType')] + [ValidateSet('AadGraph', 'AnalysisServices', 'AppConfiguration', 'Arm', 'Attestation', 'Batch', 'DataLake', 'KeyVault', 'ManagedHsm', 'MSGraph', 'OperationalInsights', 'ResourceManager', 'Storage', 'Synapse')] + [string]$ResourceTypeName = 'Arm', + + [Alias('u')] + [Parameter(Mandatory, ParameterSetName = 'ByUrl')] + [string]$ResourceUrl, + + [Alias('i')] + [Parameter(Mandatory, ParameterSetName = 'ServicePrincipal')] + [Parameter(ParameterSetName = 'ByUrl')] + [guid]$ClientId, + + [Alias('s')] + [Parameter(Mandatory, ParameterSetName = 'ServicePrincipal')] + [Parameter(ParameterSetName = 'ByUrl')] + [string]$ClientSecret, + + [Alias('c')] + [Parameter(Mandatory, ParameterSetName = 'Credential')] + [Parameter(ParameterSetName = 'ByUrl')] + [System.Management.Automation.PSCredential]$Credential, + + [switch]$AsPlainText + ) + + begin { + # calculate variables based on PSBoundParameters + if ($PSBoundParameters.ResourceUrl) { + $ResourceUrl = $ResourceUrl -replace '(/\.default)?/?$' + } else { + $ResourceUrl = 'https://management.azure.com' + } + if ($PSBoundParameters.Credential) { + $ClientId = $Credential.GetNetworkCredential().UserName + $ClientSecret = $Credential.GetNetworkCredential().Password + } + } + + process { + $token = if ($PsCmdlet.ParameterSetName -eq 'ByType') { + # get token for the logged-in user by ResourceTypeName + Invoke-CommandRetry { + Get-AzAccessToken -ResourceTypeName $ResourceTypeName + } + } elseif ($ClientId) { + # get token for the specified Url and Client + $tenantId = (Get-AzContext).Tenant.Id + $params = @{ + Method = 'Post' + Uri = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" + ContentType = 'application/x-www-form-urlencoded' + Body = @{ + client_id = $ClientId + client_secret = $ClientSecret + grant_type = 'client_credentials' + scope = [System.IO.Path]::Join($ResourceUrl, '.default') + } + } + $oauth2Token = Invoke-CommandRetry { + Invoke-RestMethod @params + } + [PSCustomObject]@{ + Token = $oauth2Token.access_token | ConvertTo-SecureString -AsPlainText + ExpiresOn = [DateTime]::UtcNow.AddSeconds($oauth2Token.expires_in) + TenantId = $tenantId + UserId = $ClientId + Type = $oauth2Token.token_type + } + } else { + # get token for the logged-in user for the specified Url + Invoke-CommandRetry { + Get-AzAccessToken -ResourceUrl $ResourceUrl + } + } + + if ($AsPlainText) { + # convert token from secure string + $props = @( + @{ Name = 'Token'; Expression = { $_.Token | ConvertFrom-SecureString -AsPlainText } } + 'ExpiresOn' + 'TenantId' + 'UserId' + 'Type' + ) + $token = $token | Select-Object $props + } + } + + end { + return $token + } +} + + +<# +.SYNOPSIS +Set Azure KeyVault access policy using Azure REST API request + +.PARAMETER VaultId +Resource id of the Azure KeyVault +.PARAMETER VaultName +Azure KeyVault name. +.PARAMETER Operation +Operation to perform. Available options: add, replace, remove. +.PARAMETER ObjectId +ObjectId of the policy asignee, e.g. user, group, service principal. +It will assign policy to the current user if not specified +.PARAMETER PermissionsToKeys +List of Keys permissions. +.PARAMETER PermissionsToSecrets +List of Secrets permissions. +.PARAMETER PermissionsToCertificates +List of Certificates permissions. +.PARAMETER ApiVersion +KeyVault API version. +#> +function Set-AzKeyVaultAccessPolicyApi { + [CmdletBinding(DefaultParameterSetName = 'ById')] + param ( + [Parameter(Mandatory, Position = 0, ParameterSetName = 'ById')] + [string]$VaultId, + + [Parameter(Mandatory, Position = 0, ParameterSetName = 'ByName')] + [string]$VaultName, + + [ValidateSet('add', 'remove', 'replace')] + [string]$Operation = 'add', + + [guid]$ObjectId, + + [string[]]$PermissionsToKeys, + + [string[]]$PermissionsToSecrets, + + [string[]]$PermissionsToCertificates, + + [string]$ApiVersion = '2022-07-01' + ) + + # get VaultId for the API request if name provided + if ($VaultName) { + $VaultId = (Get-AzGraphResourceByName -ResourceName $VaultName -ResourceType 'microsoft.keyvault/vaults').id + if (-not $VaultId) { + Write-Warning "Key-Vault not found ($VaultName)." + return + } + } + + # get current user object id if non provided, to perform the access policy operation on + $ctx = Get-AzContext + if (-not $ObjectId) { + $ObjectId = Invoke-CommandRetry { + Get-AzADUser -UserPrincipalName $ctx.Account.Id | Select-Object -ExpandProperty Id + } + } + + # build KeyVault API request parameters + $apiParams = @{ + Method = 'Put' + Path = "$($VaultId)/accessPolicies/$Operation" + ApiVersion = $ApiVersion + Body = @{ + properties = @{ + accessPolicies = @( + @{ + tenantId = $ctx.Tenant.Id + objectId = $ObjectId + permissions = @{ + keys = $PermissionsToKeys ?? @() + secrets = $PermissionsToSecrets ?? @() + certificates = $PermissionsToCertificates ?? @() + } + } + ) + } + } + } + # run the KeyVault API request + Invoke-AzApiRequest @apiParams +} + + +<# +.SYNOPSIS +Gets a certificate from a key vault as X509Certificate2Collection. + +.PARAMETER VaultName +Specifies the name of the key vault to which the secret belongs. +.PARAMETER Name +Specifies the name of the secret to get. +.PARAMETER IncludeVersions +Indicates that this cmdlet gets all versions of a secret. The current version of a secret is the first one on the list. If you specify this parameter you must also specify the Name and VaultName parameters. +.PARAMETER Version +Specifies the secret version. +.PARAMETER AsCertificate +Switch to show the certificate in X509Certificate2Collection format. +#> +function Get-KeyVaultCertificate { + [CmdletBinding(DefaultParameterSetName = 'list')] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$VaultName, + + [Alias('SecretName')] + [Parameter(Mandatory, Position = 1, ParameterSetName = 'get')] + [string]$Name, + + [Parameter(ParameterSetName = 'get')] + [switch]$IncludeVersions, + + [Alias('SecretVersion')] + [Parameter(ParameterSetName = 'get')] + [string]$Version, + + [Parameter(ParameterSetName = 'get')] + [switch]$AsCertificate + ) + + begin { + # rewrite PSBoundParameters to internal variable + $param = @{} + $PSBoundParameters.GetEnumerator() | ForEach-Object { $param[$_.Key] = $_.Value } + $param.Add('ErrorAction', 'Stop') + if ($PSBoundParameters.AsCertificate) { + $param.Remove('AsCertificate') | Out-Null + if ($PSBoundParameters.IncludeVersions) { + Write-Warning 'IncludeVersions parameter is not supported with AsCertificate.' + $param.Remove('IncludeVersions') | Out-Null + } + } + # go into loop trying to get the KeyVault secret + for ($i = 0; $i -lt 5; $i++) { + try { + $certificate = if ($PSBoundParameters.AsCertificate) { + Invoke-CommandRetry { Get-AzKeyVaultSecret @param } + } else { + Invoke-CommandRetry { Get-AzKeyVaultCertificate @param } + } + } catch [Microsoft.Azure.KeyVault.Models.KeyVaultErrorException] { + if ($_.Exception.Message -match 'does not have .+ permission') { + if (-not $local:kvPolicy) { + # assign KeyVault policy to get secrets + Write-Verbose "Assigning `"$($PSCmdlet.ParameterSetName)`" $($PSBoundParameters.AsCertificate ? 'secrets' : 'certificates') policy on the key vault." + $paramPolicy = @{ + Operation = 'add' + VaultName = $VaultName + Verbose = $PSBoundParameters.Verbose ? $true : $false + } + if ($PSBoundParameters.AsCertificate) { + $paramPolicy.PermissionsToSecrets = $PSCmdlet.ParameterSetName + } else { + $paramPolicy.PermissionsToCertificates = $PSCmdlet.ParameterSetName + } + $kvPolicy = Set-AzKeyVaultAccessPolicyApi @paramPolicy + } else { + Write-Verbose 'Sleep 1 second to apply the policy.' + Start-Sleep 1 + } + } else { + Write-Error $_ + $noAccess = $true + break + } + } catch { + Write-Error $_ + $noAccess = $true + break + } + } + } + + process { + if (-not $certificate) { + Write-Warning "No certificate named `"$Name`" found in the `"$VaultName`" key-vault." + return + } elseif ($noAccess) { + return + } elseif ($PSBoundParameters.AsCertificate) { + if ($certificate.ContentType -notin @('application/x-pkcs12', 'application/x-pem-file')) { + Write-Warning "Secret `"$Name`" is not a certificate." + return + } else { + # decode certificates + $secretValue = $certificate.SecretValue | ConvertFrom-SecureString -AsPlainText + switch ($certificate.ContentType) { + 'application/x-pkcs12' { + # instantiate X509Certificate2Collection to store the certificate chain + $certs = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection + $certs.Import([Convert]::FromBase64String($secretValue)) + } + 'application/x-pem-file' { + $certs = $secretValue | ConvertFrom-PEM + } + } + } + } else { + $certs = $certificate + } + } + + end { + return $local:certs + } + + clean { + # remove assigned access policy + if ($local:kvPolicy) { + Write-Verbose "Removing $($PSCmdlet.ParameterSetName -eq 'get' ? 'secrets' : 'certificates') policy from the key vault." + $paramPolicy.Operation = 'remove' + Set-AzKeyVaultAccessPolicyApi @paramPolicy | Out-Null + } + } +} + + +<# +.SYNOPSIS +Gets the secrets in a key vault and assigning get policy if not set. + +.PARAMETER VaultName +Specifies the name of the key vault to which the secret belongs. +.PARAMETER Name +Specifies the name of the secret to get. +.PARAMETER AsPlainText +When set, the cmdlet will convert secret in secure string to the decrypted plaintext string as output. +.PARAMETER IncludeVersions +Indicates that this cmdlet gets all versions of a secret. The current version of a secret is the first one on the list. If you specify this parameter you must also specify the Name and VaultName parameters. +.PARAMETER Version +Specifies the secret version. +#> +function Get-KeyVaultSecret { + [CmdletBinding(DefaultParameterSetName = 'list')] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$VaultName, + + [Alias('SecretName')] + [Parameter(Mandatory, Position = 1, ParameterSetName = 'get')] + [string]$Name, + + [Parameter(ParameterSetName = 'get')] + [switch]$AsPlainText, + + [Parameter(ParameterSetName = 'get')] + [switch]$IncludeVersions, + + [Alias('SecretVersion')] + [Parameter(ParameterSetName = 'get')] + [string]$Version + ) + + begin { + # rewrite PSBoundParameters to internal variable + $param = $PSBoundParameters + $param.Add('ErrorAction', 'Stop') + } + + process { + # go into loop trying to get the KeyVault secret + for ($i = 0; $i -lt 5; $i++) { + try { + Invoke-CommandRetry { Get-AzKeyVaultSecret @param } + break + } catch [Microsoft.Azure.KeyVault.Models.KeyVaultErrorException] { + if ($_.Exception.Message -match 'does not have .+ permission') { + if (-not $local:kvPolicy) { + # assign KeyVault policy to get secrets + Write-Verbose "Assigning `"$($PSCmdlet.ParameterSetName)`" secrets policy on the key vault." + $paramPolicy = @{ + Operation = 'add' + VaultName = $VaultName + PermissionsToSecrets = $PSCmdlet.ParameterSetName + Verbose = $PSBoundParameters.Verbose ? $true : $false + } + $kvPolicy = Set-AzKeyVaultAccessPolicyApi @paramPolicy + } else { + Write-Verbose 'Sleep 1 second to apply the policy.' + Start-Sleep 1 + } + } else { + Write-Error $_ + break + } + } catch { + Write-Error $_ + break + } + } + } + + clean { + # remove assigned access policy + if ($local:kvPolicy) { + Write-Verbose 'Removing secrets policy from the key vault.' + $paramPolicy.Operation = 'remove' + Set-AzKeyVaultAccessPolicyApi @paramPolicy | Out-Null + } + } +} + + +<# +.SYNOPSIS +Creates or updates a secret in a key vault and assigning set policy if not set. + +.PARAMETER VaultName +Specifies the name of the key vault to which the secret belongs. +.PARAMETER Name +Specifies the name of the secret to set. +.PARAMETER SecretValue +Specifies the value for the secret as a SecureString object. To obtain a SecureString object, use the ConvertTo-SecureString cmdlet. +.PARAMETER Expires +Specifies the expiration time, as a DateTime object, for the secret that this cmdlet updates. This parameter uses Coordinated Universal Time (UTC). +.PARAMETER NotBefore +Specifies the time, as a DateTime object, before which the secret cannot be used. This parameter uses UTC. +.PARAMETER ContentType +Specifies the content type of a secret. To delete the existing content type, specify an empty string. +.PARAMETER Tag +Key-value pairs in the form of a hash table. For example: @{key0="value0";key1=$null;key2="value2"} +#> +function Set-KeyVaultSecret { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$VaultName, + + [Alias('SecretName')] + [Parameter(Mandatory, Position = 1)] + [string]$Name, + + [Parameter(Mandatory, Position = 2)] + [securestring]$SecretValue, + + [datetime]$Expires, + + [datetime]$NotBefore, + + [string]$ContentType, + + [hashtable]$Tag + ) + + begin { + # rewrite PSBoundParameters to internal variable + $param = $PSBoundParameters + $param.Add('ErrorAction', 'Stop') + } + + process { + # go into loop trying to get the KeyVault secret + for ($i = 0; $i -lt 5; $i++) { + try { + Invoke-CommandRetry { Set-AzKeyVaultSecret @param } + break + } catch [Microsoft.Azure.KeyVault.Models.KeyVaultErrorException] { + if ($_.Exception.Message -match 'does not have .+ permission') { + if (-not $local:kvPolicy) { + Write-Verbose "Assigning `"set`" secrets policy on the key vault." + $paramPolicy = @{ + Operation = 'add' + VaultName = $VaultName + PermissionsToSecrets = @('set') + Verbose = $PSBoundParameters.Verbose ? $true : $false + } + $kvPolicy = Set-AzKeyVaultAccessPolicyApi @paramPolicy + } else { + Write-Verbose 'Sleep 1 second to apply the policy.' + Start-Sleep 1 + } + } else { + Write-Error $_ + break + } + } catch { + Write-Error $_ + break + } + } + } + + clean { + # remove assigned access policy + if ($local:kvPolicy) { + Write-Verbose 'Removing secrets policy from the key vault.' + $paramPolicy.Operation = 'remove' + Set-AzKeyVaultAccessPolicyApi @paramPolicy | Out-Null + } + } +} + + +<# +.DESCRIPTION +Get virtual network details from AzGraph. + +.PARAMETER VirtualNetwork +Specifies the virtual network name(/subnet) or id. +.PARAMETER AzGraphResource +Switch to return just the AzGraphResource object from the provided id. + +.EXAMPLE +$VirtualNetwork = 'mlwmlopsaztest0' +$VirtualNetwork = 'mlwmlopsaztest0/privatelink' +Get-VirtualNetwork -n $VirtualNetwork -Verbose +# :get virtual network by id +$VirtualNetwork = '/subscriptions/73031a72-85cc-45bc-8485-8375031e8bf2/resourceGroups/AZ-RG-AIP-MLWMLOPSAZTEST0/providers/Microsoft.Network/virtualNetworks/mlwmlopsaztest0' +Get-VirtualNetwork -n $VirtualNetwork -AzGraphResource -Verbose +#> +function Get-VirtualNetwork { + [CmdletBinding()] + param ( + [Alias('n')] + [Parameter(Mandatory, Position = 0)] + [ValidateScript({ $_.Split('/').Count -in @(1, 2, 9) }, ErrorMessage = "'{0}' is not proper virtual network string.")] + [string]$VirtualNetwork, + + [switch]$AzGraphResource + ) + + begin { + $split = $VirtualNetwork.Split('/') + + # determine verbosity level + $isVerbose = $PSBoundParameters.Verbose ? $true : $false + } + + process { + Show-LogContext -Message 'getting virtual network details' -Level VERBOSE + $vnet = if ($split.Count -le 2) { + Get-AzGraphResource -ResourceName $split[0] -ResourceType 'microsoft.network/virtualnetworks' -Verbose:$isVerbose + } else { + try { + $resource = [AzGraphResource]$VirtualNetwork + if ($resource.type -eq 'Microsoft.Network/virtualNetworks') { + if ($AzGraphResource) { + $resource + } else { + Get-AzGraphResource -ResourceId $resource.id -Verbose:$isVerbose + } + } else { + Show-LogContext "non-virtualNetwork id provided ($VirtualNetwork)" -Level WARNING + return $null + } + } catch { + return $null + } + } + + if (-not $vnet) { + Show-LogContext "no virtual network found ($VirtualNetwork)" -Level WARNING + } + } + + end { + return $vnet + } +} + + +<# +.SYNOPSIS +Get Azure Private Endpoint by specifying the endpoint name, virtual network, IP or resource it connects to. + +.PARAMETER PrivateEndpoint +Private Endpoint id or name. +.PARAMETER VirtualNetwork +Virtual Network id or name of the private endpoint. +.PARAMETER IP +The IP of the private endpoint network interface. +.PARAMETER Resource +Id or name of the resource, private endpoint is connected to. +.PARAMETER GetIP +Switch to get private endpoint IP configurations. + +.EXAMPLE +# :by private endpoint name +$PrivateEndpoint = '' +Get-PrivateEndpoint -e $PrivateEndpoint | Tee-Object -Variable pe +Get-PrivateEndpoint -e $PrivateEndpoint -GetIP | Tee-Object -Variable pe +# :by vnet +$VirtualNetwork = '' +$pe = Get-PrivateEndpoint -n $VirtualNetwork +# get PE with the specified IP +$pe = Get-PrivateEndpoint -n $VirtualNetwork -GetIP +Get-PrivateEndpoint -n $VirtualNetwork -IP '10.99.0.4' | Tee-Object -Variable pe +# :by resource +$Resource = '' +$pe = Get-PrivateEndpoint -r $Resource +$pe = Get-PrivateEndpoint -r $Resource -GetIP +# :by connection +$VirtualNetwork = '' +$Resource = '' +Get-PrivateEndpoint -n $VirtualNetwork -r $Resource | Tee-Object -Variable pe +Get-PrivateEndpoint -n $VirtualNetwork -r $Resource -GetIP | Tee-Object -Variable pe +# :explore private endpoint result +# list private endpoints +$pe | Select-Object name, resourceGroup, subscription, @{ N = 'primaryIP'; E = { $_.properties.primaryIP } } +# write private endpoint IP configurations +$pe[0].properties.networkInterfaces.ipConfigurations +# explore all properties of the private endpoint as json +$pe[0] | json +#> +function Get-PrivateEndpoint { + [CmdletBinding()] + param ( + [Alias('e')] + [Parameter(Mandatory, Position = 0, ParameterSetName = 'ByEndpoint')] + [string]$PrivateEndpoint, + + [Alias('n')] + [Parameter(Mandatory, Position = 0, ParameterSetName = 'ByConnection')] + [Parameter(Mandatory, Position = 0, ParameterSetName = 'ByVNet')] + [string]$VirtualNetwork, + + [Parameter(ParameterSetName = 'ByVNet')] + [ValidateScript({ [System.Net.IPAddress]::TryParse($_, [ref]$null) }, ErrorMessage = 'Not a valid IP address.')] + [string]$IP, + + [Parameter(Mandatory, ParameterSetName = 'ByConnection')] + [Parameter(Mandatory, ParameterSetName = 'ByResource')] + [string]$Resource + ) + + begin { + # determine verbosity level + $isVerbose = $PSBoundParameters.Verbose ? $true : $false + + # reset vnet variable + $vnet = $null + + # get VNet and resource details based on the parameter set + Show-LogContext "ParameterSetName: $($PsCmdlet.ParameterSetName)" -Level VERBOSE + switch -Regex ($PsCmdlet.ParameterSetName) { + '^(ByConnection|ByVNet)$' { + # get the virtual network details + $split = $VirtualNetwork.Split('/') + $vnet = if ($split.Count -eq 2) { + Get-VirtualNetwork -VirtualNetwork $VirtualNetwork -Verbose:$isVerbose + } else { + Get-VirtualNetwork -VirtualNetwork $VirtualNetwork -AzGraphResource -Verbose:$isVerbose + } + # if more than one virtual network found with the specified name, prompt the user to select one + if ($vnet.Count -gt 1) { + $msg = "More than one virtual network found with the specified name ($VirtualNetwork)." + $idx = $vnet | Select-Object subscription, resourceGroup | Get-ArrayIndexMenu -Message $msg + $vnet = $vnet[$idx] + } elseif ($vnet.Count -eq 0) { + Show-LogContext "no virtual network found ($VirtualNetwork)" -Level ERROR + return + } + + if ($vnet) { + if ($split.Count -eq 2) { + $subnetId = ($vnet.properties.subnets).Where({ $_.name -eq $split[1] }).id + if (-not $subnetId) { + Write-Warning "Subnet `e[4m$($split[1])`e[24m doesn't exist in the `e[4m$($split[0])`e[24m VNet." + return + } + } + Show-LogContext "Found VNet: $($vnet.id)" -Level VERBOSE + } else { + Write-Warning "Virtual network doesn't exist ($VirtualNetwork)." + return + } + } + '^(ByConnection|ByResource)$' { + Show-LogContext 'looking for resource...' -Level VERBOSE + $targetId = try { + Get-AzGraphResource -ResourceId $Resource | Select-Object -ExpandProperty id + } catch { + $peParam = @{ + ResourceName = $Resource + ExcludeTypes = @( + 'microsoft.network/virtualnetworks' + 'microsoft.network/privateendpoints' + 'microsoft.network/privatednszones/virtualnetworklinks' + ) + } + Get-AzGraphResourceByName @peParam | Select-Object -ExpandProperty id + } + if ($targetId) { + Show-LogContext "Found resource: $targetId" -Level VERBOSE + } else { + Write-Warning "Resource doesn't exist ($Resource)." + return + } + } + } + + function Get-Query { + [CmdletBinding()] + param ( + [string]$PrivateEndpointId, + + [string]$PrivateEndpointName, + + [string]$TargetId, + + [string]$SubNetId, + + [string]$VNetId + ) + + # build the kusto query string to get private endpoints with nic properties + $builder = [System.Text.StringBuilder]::new() + $builder.AppendLine("Resources`n| where type =~ 'Microsoft.Network/privateEndpoints'") | Out-Null + if ($PrivateEndpointId) { + $builder.AppendLine("`tand id =~ '$PrivateEndpointId'") | Out-Null + } elseif ($PrivateEndpointName) { + $builder.AppendLine("`tand name =~ '$PrivateEndpointName'") | Out-Null + } elseif ($SubNetId) { + $builder.AppendLine("`tand properties.subnet.id =~ '$SubNetId'") | Out-Null + } elseif ($VNetId) { + $builder.AppendLine("`tand properties.subnet.id startswith '$VNetId/subnets/'") | Out-Null + } + if ($TargetId) { + $builder.AppendLine("`tand properties.privateLinkServiceConnections[0].properties.privateLinkServiceId =~ '$TargetId'") | Out-Null + } + $builder.AppendLine('| extend nicId = tolower(properties.networkInterfaces[0].id)') | Out-Null + $builder.AppendLine('| join kind=leftouter (') | Out-Null + $builder.AppendLine("`tResources`n`t| where type =~ 'Microsoft.Network/networkInterfaces'") | Out-Null + $builder.AppendLine("`t| project nicId = tolower(id), ipConfigurations = properties.ipConfigurations") | Out-Null + $builder.AppendLine(') on nicId') | Out-Null + $builder.AppendLine('| join kind=leftouter (') | Out-Null + $builder.AppendLine("`tResourceContainers`n`t| where type =~ 'microsoft.resources/subscriptions'") | Out-Null + $builder.AppendLine("`t| project subscription=name, subscriptionId") | Out-Null + $builder.AppendLine(') on subscriptionId') | Out-Null + $builder.Append('| project id, name, type, tenantId, kind, location, resourceGroup, subscriptionId, subscription, sku, identity, tags, properties, ipConfigurations') | Out-Null + + return $builder.ToString() + } + } + + process { + # get private endpoint(s) based on the parameter set + switch ($PsCmdlet.ParameterSetName) { + ByEndpoint { + Show-LogContext 'getting private endpoint by name/id...' -Level VERBOSE + $queryParam = if ($PrivateEndpoint -match '^\/subscriptions\/[0-9a-f-]+\/resourceGroups\/[\w-]+\/providers\/Microsoft\.Network\/privateEndpoints\/([\w-]+)$') { + @{ PrivateEndpointId = $PrivateEndpoint } + } else { + @{ PrivateEndpointName = $PrivateEndpoint } + } + } + ByConnection { + Show-LogContext 'getting private endpoint by connection...' -Level VERBOSE + if ($vnet -and $targetId) { + $queryParam = @{ TargetId = $targetId } + if ($subnetId) { + $queryParam.SubnetId = $subnetId + } else { + $queryParam.VNetId = $vnet.id + } + } else { + $null + } + break + } + ByVNet { + Show-LogContext 'getting private endpoint by VNet...' -Level VERBOSE + $queryParam = if ($vnet) { + if ($subnetId) { + @{ SubnetId = $subnetId } + } else { + @{ VNetId = $vnet.id } + } + } else { + $null + } + break + } + ByResource { + Show-LogContext 'getting private endpoint by resource...' -Level VERBOSE + $queryParam = if ($targetId) { + @{ TargetId = $targetId } + } else { + $null + } + break + } + } + $pe = if ($queryParam) { + $query = Get-Query @queryParam + $peParam = @{ + Query = $query + Verbose = $PSBoundParameters.Verbose ? $true : $false + } + if ($vnet) { + $peParam.SubscriptionId = $vnet.subscriptionId + } + Invoke-AzGraph @peParam | ForEach-Object { + $primaryIP = $_.ipConfigurations.properties.Where({ $_.primary }).privateIPAddress + $_ | Add-Member -NotePropertyName 'primaryIP' -NotePropertyValue $primaryIP -PassThru + } + } else { + $null + } + + # add ipConfigurations to the private endpoint networkInterfaces property + if ($pe -and ($PSBoundParameters.IP)) { + $pe = $pe.Where({ $IP -in $_.ipConfigurations.properties.privateIPAddress }) + } + } + + end { + Show-LogContext "Found $($pe.Count) private endpoints." -Level VERBOSE + return $pe + } +} + + +<# +.SYNOPSIS +Set subscription context from selection menu. + +.PARAMETER cli +Switch whether to set the context for azure-cli. +#> +function Set-SubscriptionMenu { + [CmdletBinding()] + param ( + [ArgumentCompleter({ ArgAzGetSubscriptions @args })] + [string]$Subscription, + + [switch]$Cli + ) + + begin { + $subscription = if ($PsBoundParameters.Subscription) { + $PsBoundParameters.Subscription + } else { + $query = [string]::Join(' | ', + 'ResourceContainers', + 'where type =~ "microsoft.resources/subscriptions"', + 'project subscriptionId, name' + ) + Invoke-AzGraph -Query $query | Get-ArrayIndexMenu -Value | Select-Object -ExpandProperty name + } + } + + process { + if ($subscription) { + $sub = if ($PsBoundParameters.Cli) { + az account set --subscription $subscription + az account show | ConvertFrom-Json | Select-Object name, id, tenantId, state + } else { + (Connect-AzContext $subscription).Subscription | Select-Object Name, Id, TenantId, State + } + } + } + + end { + return $sub + } +} + +Set-Alias -Name ssm -Value Set-SubscriptionMenu + + +<# +.SYNOPSIS +Send request to Azure REST API. + +.PARAMETER Endpoint +API endpoint. +.PARAMETER Path +Request path. +.PARAMETER ApiVersion +API version. +.PARAMETER Token +Azure ARM access token. +.PARAMETER Filter +Filter specified for the API request. +.PARAMETER Select +Select specific fields in the API request. +.PARAMETER Query +Additional query parameters for the API request. +.PARAMETER Method +Request method. Allowed values: Get, Patch, Post, Put, Delete. Default: Get. +.PARAMETER Body +Request payload provided as string or hashtable. +.PARAMETER InFile +Request payload provided as path to file. +.PARAMETER SkipPagination +Switch whether or not to retrieve paginated results. +.PARAMETER JsonOutput +Switch whether to return a response as json. +#> +function Invoke-AzApiRequest { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [ValidateNotNullOrEmpty()] + [string]$Endpoint = 'management.azure.com', + + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [string]$Path, + + [ValidateNotNullOrEmpty()] + [string]$ApiVersion, + + [securestring]$Token, + + [string]$Filter, + + [string[]]$Select, + + [string]$Query, + + [ValidateSet('Get', 'Patch', 'Post', 'Put', 'Delete')] + [string]$Method = 'Get', + + [Parameter(Mandatory, ParameterSetName = 'Payload:Body')] + [ValidateNotNullorEmpty()] + [object]$Body, + + [Alias('f')] + [Parameter(Mandatory, ParameterSetName = 'Payload:File')] + [ValidateScript({ Test-Path $_ -PathType 'Leaf' }, ErrorMessage = "'{0}' is not a valid path.")] + [string]$InFile, + + [switch]$SkipPagination, + + [switch]$JsonOutput + ) + + begin { + # get Azure ARM access token if not prvided + if (-not $Token) { + $Token = (Get-MsoToken).Token + } + # build Azure REST API request parameters for splatting + $params = @{ + Method = $Method + Authentication = 'Bearer' + Token = $Token + Headers = @{ 'Content-Type' = 'application/json' } + ErrorAction = 'Stop' + } + + # get the latest stable Azure REST API version for the specified Path provided + if (-not $ApiVersion -and $Endpoint -eq 'management.azure.com') { + $ApiVersion = Get-AzResourceTypeApiVersions -Id $Path + } + + # add payload + if ($Method -in @('Patch', 'Post', 'Put')) { + if ($Body) { + $params.Body = switch -Regex ($Body.GetType().Name) { + String { + $Body + } + 'Hashtable|OrderedDictionary' { + $Body | ConvertTo-Json -Depth 99 + } + default { + $null + } + } + } elseif ($InFile) { + $params.InFile = $InFile + } + } + + # build Query + $qryParts = [System.Collections.Generic.List[string]]::new() + if ($ApiVersion) { + $qryParts.Add("api-version=$ApiVersion") + } + if ($PSBoundParameters.Filter) { + $qryParts.Add("`$filter=$([System.Uri]::EscapeDataString($Filter))") + } + if ($PSBoundParameters.Select) { + $qryParts.Add("`$select=$([System.Uri]::EscapeDataString($Select -join ','))") + } + if ($PSBoundParameters.Query) { + $qryParts.Add($Query.Replace(' ', '%20')) + } + $qry = if ($qryParts.Count) { "?$($qryParts -join '&')" } else { '' } + + # initialize collection to store the response + $responseList = [System.Collections.Generic.List[PSCustomObject]]::new() + } + + process { + # calculate request Uri + $params.Uri = [System.UriBuilder]::new('https', $Endpoint, 443, $Path, $qry).Uri + # write verbose messages + Write-Verbose "$($params.Method.ToUpper()) $($params.Uri)" + if ($params.Body) { + Write-Verbose "Body`n$($params.Body)" + } elseif ($params.InFile) { + Write-Verbose "Body`n$(Get-Content $params.InFile | Join-String -Separator "`n")" -Verbose + } + do { + # send API request + $response = try { + Invoke-CommandRetry { + Invoke-RestMethod @params + } + } catch { + if ($PSBoundParameters.ErrorAction -eq 'SilentlyContinue') { + Write-Verbose $_ + } else { + Write-Verbose $_.Exception.GetType().FullName + Write-Error $_ + } + $null + } + # add response to response list + if ($null -ne $response.value) { + $response.value.ForEach({ $responseList.Add($_) }) + } elseif ($response) { + $response.ForEach({ $responseList.Add($_) }) + } + # check pagination + if ($response.nextLink) { + if ($SkipPagination) { + $response.nextLink = $null + } else { + $params.Uri = $response.nextLink + } + } + } while ($response.nextLink) + } + + end { + # return response + if ($JsonOutput) { + if (Get-Command jq -CommandType Application -ErrorAction SilentlyContinue) { + return $responseList | ConvertTo-Json -Depth 99 | jq + } else { + return $responseList | ConvertTo-Json -Depth 99 + } + } else { + return $responseList + } + } +} + + +<# +.SYNOPSIS +Get AKS credentials and set context. + +.PARAMETER AksName +Specifies the AKS cluster name. +.PARAMETER ContextName +Target context name. +.PARAMETER LoginMethod +Specifies the login method for kubelogin. Allowed values: devicecode, interactive, spn, ropc, msi, azurecli, azd, workloadidentity. + +.EXAMPLE +$AksName = 'aks-aif-mt-qa-9ea1' +$ContextName = 'aks-aif-mt-qa' +$LoginMethod = 'azurecli' + +Get-AksCredential -a $AksName -c $ContextName -l $LoginMethod +#> +function Get-AksCredential { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$AksName, + + [string]$ContextName, + + [Parameter(ParameterSetName = 'KubeLogin')] + [ValidateNotNullOrEmpty()] + [ArgumentCompletions('azurecli', 'azd', 'devicecode', 'interactive', 'msi', 'ropc', 'spn', 'workloadidentity')] + [string]$LoginMethod + ) + + begin { + $continue = try { + Get-Command kubectl -CommandType Application -ErrorAction Stop | Out-Null + $true + } catch { + Write-Warning 'kubetcl not found. Please install kubectl.' + $false + return + } + + Write-Verbose 'getting kubectl contexts...' + $ctx = kubectl config view -ojson | ConvertFrom-Json + if ($ContextName -in $ctx.contexts.name) { + Write-Warning "Context already exists. Please remove it first ($ContextName)." + $continue = $false + return + } elseif ($AksName -in $ctx.clusters.name) { + Write-Warning "Cluster is already added to the kube config ($AksName)." + $continue = $false + return + } + + # get AKS details + Write-Verbose 'getting AKS details...' + $prop = @{ + ResourceName = $AKSName + ResourceType = 'microsoft.containerservice/managedclusters' + } + Get-AzGraphResourceByName @prop | Tee-Object -Variable aks + + if (-not $aks) { + Write-Warning "AKS cluster not found ($AksName)." + $continue = $false + return + } + } + + process { + if ($continue) { + $env:KUBECONFIG = "$HOME/.kube/config" + # get credentials to specified AKS cluster + Write-Verbose 'getting AKS credentials...' + Connect-AzContext -Subscription $aks.subscriptionId | Out-Null + Invoke-CommandRetry { + Import-AzAksCredential -Id $aks.id -Force -ConfigPath $env:KUBECONFIG -ErrorAction Stop + } + + # rename context + if ($ContextName) { + kubectl config rename-context $AKSName $ContextName + } + + if ($LoginMethod) { + kubelogin convert-kubeconfig -l $LoginMethod + } + } + } +} + + +<# +.SYNOPSIS +Create federated credential for the service account in the current/specified AKS context. + +.PARAMETER Namespace +Kubernetes namespace to set workload identity federated credential for. + +.EXAMPLE +Set-AksFederatedCredential +# create federated credential for the service account in the current namespace + +.EXAMPLE +$Namespace = 'external-secrets' +Set-AksFederatedCredential $Namespace +# create federated credential for the service account in the specified namespace +#> +function Set-AksFederatedCredential { + [CmdletBinding()] + param ( + [Parameter(Position = 0)] + [ValidateNotNullOrEmpty()] + [string]$Namespace + ) + + begin { + # check if kubectl is installed + try { + Get-Command kubectl -CommandType Application -ErrorAction Stop | Out-Null + } catch { + Show-LogContext $_ + return + } + + # get-current kubectl context + $ctx = kubectl config view --minify --output 'jsonpath={.contexts..context}' | ConvertFrom-Json + # get current namespace from the context + if (-not $Namespace) { + $Namespace = $ctx.namespace + } + Show-LogContext "Searching for workload identity service accounts in the `e[94;1;4m$($ctx.cluster)::$Namespace`e[0m context." + + # get list of service accounts in the specified namespace + $serviceAccounts = (kubectl get serviceaccounts -n "$Namespace" -o=json | ConvertFrom-Json).items.Where( + { $_.metadata.labels.'azure.workload.identity/use' -eq 'true' } + ) + # get service accounts configured for the workload identity + Show-LogContext 'Getting Service Principals details.' + $wi = foreach ($sa in $serviceAccounts) { + $clientId = $sa.metadata.annotations.'azure.workload.identity/client-id' + if ($clientId) { + try { + $sp = Invoke-CommandRetry { + Get-AzADServicePrincipal -ApplicationId $clientId -ErrorAction Stop + } + if ($sp) { + [PSCustomObject]@{ + ServiceAccount = $sa.metadata.name + Namespace = $sa.metadata.namespace + ClientId = $sp.AppId + ClientName = $sp.DisplayName + Type = $sp.ServicePrincipalType + } + } else { + Show-LogContext "Service principal with client ID `"$clientId`" not found." -Level WARNING + } + } catch { + Show-LogContext "Failed to get service principal for `e[4m$($sa.metadata.name)`e[24m serviceaccount." -Level ERROR -ErrorStackTrace $_.ScriptStackTrace + Write-Host "$_".Replace('. ', ".`n") -ForegroundColor Red + } + } else { + Show-LogContext "Service account `"$($sa.metadata.name)`" doesn't have a client-id configured." -Level WARNING + } + } + if ($wi.Count -gt 1) { + # select service account if more than one found + $idx = $wi | Get-ArrayIndexMenu -Message 'Select service account to create federated credential for' + $wi = $wi[$idx] + } elseif (-not $wi) { + Show-LogContext "Workload identity service account in the namespace `"$Namespace`" not found." -Level WARNING + return + } + Write-Host "`nSetting federated credential on the `e[96;1;4m$($wi.ClientName)`e[0m uami for `e[96;1;4m$($wi.ServiceAccount)`e[0m service account.`n" + } + + process { + if ($wi) { + # get AKS detauls + $param = @{ + ResourceName = kubectl config view --minify --output 'jsonpath={.clusters..name}' + ResourceType = 'microsoft.containerservice/managedclusters' + } + Show-LogContext 'getting AKS cluster details...' + $aks = Get-AzGraphResourceByName @param + if (-not $aks) { + Show-LogContext "AKS cluster not found ($($ctx.cluster))." -Level WARNING + return + } + + if ($wi.Type -eq 'ManagedIdentity') { + $param = @{ + Condition = "properties.clientId == '$($wi.ClientId)'" + ResourceType = 'microsoft.managedidentity/userassignedidentities' + } + Show-LogContext 'getting user assigned managed identity details...' + $uami = Get-AzGraphResource @param + if ($uami) { + # check if the federated credential exists + $param = @{ + IdentityName = $uami.name + ResourceGroupName = $uami.resourceGroup + SubscriptionId = $uami.subscriptionId + WarningAction = 'SilentlyContinue' + ErrorAction = 'Stop' + } + Show-LogContext 'getting federated identity credential details...' + try { + $fc = Invoke-CommandRetry { + Get-AzFederatedIdentityCredential @param | Where-Object { + $_.Issuer -eq $aks.properties.oidcIssuerProfile.issuerURL -and + $_.Subject -eq "system:serviceaccount:$($wi.Namespace):$($wi.ServiceAccount)" + } + } + } catch { + Show-LogContext "Error getting federated credential ($_)" -Level WARNING + } + } else { + Show-LogContext "User assigned managed identity not found ($($wi.ClientName))." -Level WARNING + return + } + } elseif ($wi.Type -eq 'Application') { + $app = Invoke-CommandRetry { + Get-AzADApplication -ApplicationId $wi.ClientId -ErrorAction Stop + } + if ($app) { + $param = @{ + ApplicationObjectId = $app.Id + WarningAction = 'SilentlyContinue' + ErrorAction = 'Stop' + } + try { + $fc = Invoke-CommandRetry { + Get-MgAppFederatedCredential @param -ApiVersion 'beta' | Where-Object { + $_.Issuer -eq $aks.properties.oidcIssuerProfile.issuerURL -and + $_.Subject -eq "system:serviceaccount:$($wi.Namespace):$($wi.ServiceAccount)" + } + } + } catch { + Show-LogContext "Error getting federated credential ($_)" -Level WARNING + } + } else { + Show-LogContext "Azure AD application not found for client ID ($($wi.ClientId))." -Level WARNING + return + } + } else { + Write-Warning 'Workload identity type is not supported. Only ManagedIdentity and Application types are supported.' + return + } + if ($fc) { + Show-LogContext 'Federated credential already exists for the service account.' -Level WARNING + return + } + + # create federated credential + $fcName = "$($aks.name)-$($wi.Namespace)-$($wi.ServiceAccount)" + $param.Name = $fcName.Length -gt 120 ? $fcName.Substring(0, 120) : $fcName + $param.Issuer = $aks.properties.oidcIssuerProfile.issuerURL + $param.Subject = "system:serviceaccount:$($wi.Namespace):$($wi.ServiceAccount)" + $param.Audience = 'api://AzureADTokenExchange' + Show-LogContext 'creating federated credential...' + try { + $fc = if ($wi.Type -eq 'ManagedIdentity') { + Invoke-CommandRetry { + New-AzFederatedIdentityCredentials @param + } + } elseif ($wi.Type -eq 'Application') { + Invoke-CommandRetry { + New-AzADAppFederatedCredential @param + } + } + } catch { + Show-LogContext $_ + } + } + } + + end { + if ($fc) { + return $fc | Select-Object Name, ResourceGroupName, Subject, Issuer, Audience + } + } +} + +Set-Alias -Name setfcaks -Value Set-AksFederatedCredential diff --git a/modules/do-az/Functions/azgraph.ps1 b/modules/do-az/Functions/azgraph.ps1 new file mode 100644 index 00000000..caed79f7 --- /dev/null +++ b/modules/do-az/Functions/azgraph.ps1 @@ -0,0 +1,479 @@ +<# +.SYNOPSIS +Azure Resource Graph functions. +.LINK +https://learn.microsoft.com/en-gb/azure/governance/resource-graph/reference/supported-tables-resources +#> + + +<# +.SYNOPSIS +Generic Search-AzGraph request. + +.PARAMETER Query +Kusto query. +.PARAMETER SubscriptionId +Optional SubscriptionId to run query against. +.PARAMETER ManagementGroup +Optional ManagementGroup to run query against. +#> +function Invoke-AzGraph { + [CmdletBinding(DefaultParametersetName = 'Default')] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$Query, + + [Parameter(Mandatory, ParameterSetName = 'InSubscription')] + [guid]$SubscriptionId, + + [Parameter(Mandatory, ParameterSetName = 'InMngmtGroup')] + [guid]$ManagementGroup, + + [int]$PageSize = 1000, + + [switch]$SkipPagination, + + [switch]$JsonOutput + ) + + begin { + $param = @{ + Query = $Query + First = $PageSize + } + if ($PSBoundParameters.SubscriptionId) { + $param.Subscription = $SubscriptionId + } elseif ($PSBoundParameters.ManagementGroup) { + $param.ManagementGroup = $ManagementGroup + } else { + $param.ManagementGroup = (Connect-AzContext).Tenant.Id + } + + $result = [Collections.Generic.List[PSCustomObject]]::new() + } + + process { + Write-Verbose "Query`n`n$($param.Query)`n" + $response = $null + do { + $response = Invoke-CommandRetry { + Search-AzGraph @param -SkipToken $response.SkipToken + } + if ($SkipPagination) { + $response.SkipToken = $null + } + $response.ForEach({ $result.Add($_) }) + } while ($response.SkipToken) + } + + end { + # return response + if ($JsonOutput) { + if (Get-Command jq -CommandType Application -ErrorAction SilentlyContinue) { + return $result | ConvertTo-Json -Depth 99 | jq + } else { + return $result | ConvertTo-Json -Depth 99 + } + } else { + return $result + } + } +} + + +<# +.SYNOPSIS +Get Azure Subscriptions using AzGraph. + +.PARAMETER SubscriptionId +Specifies the ID of the subscription to get. +.PARAMETER SubscriptionName +Specifies the name of the subscription to get. +.PARAMETER ManagementGroup +Specifies the ID of the ManagementGroup that contains subscriptions to get. +.PARAMETER Condition +Optional query condition. +#> +function Get-AzGraphSubscription { + [CmdletBinding(DefaultParameterSetName = 'Default')] + [OutputType([AzGraphSubscription[]])] + param ( + [Alias('m')] + [Parameter(Mandatory, ParameterSetName = 'InMngmtGroup')] + [guid]$ManagementGroup, + + [Alias('i')] + [Parameter(Mandatory, ParameterSetName = 'InSubscription')] + [guid]$SubscriptionId, + + [Alias('n')] + [Parameter(Mandatory, ParameterSetName = 'ByName')] + [Parameter(ParameterSetName = 'InMngmtGroup')] + [string]$SubscriptionName, + + [Alias('c')] + [Parameter(Mandatory, ParameterSetName = 'ByCondition')] + [Parameter(ParameterSetName = 'InMngmtGroup')] + [ValidateScript({ $_ -notmatch '\s*where\b' }, ErrorMessage = "`e[4mWHERE`e[24m keyword is not allowed.")] + [string]$Condition, + + [int]$PageSize = 1000, + + [switch]$SkipPagination + ) + + begin { + # build filter + $filter = if ($PSBoundParameters.SubscriptionName) { + " and name =~ '$($PSBoundParameters.SubscriptionName)'" + } elseif ($PSBoundParameters.Condition) { + " and $($PSBoundParameters.Condition)" + } + # calculate query + $query = [string]::Join("`n", + 'ResourceContainers', + "| where type == 'microsoft.resources/subscriptions'$filter", + '| project id, name, type, tenantId, subscriptionId, properties' + ) + + # add PSBoundParameters for the Invoke-AzGraph function + $PSBoundParameters.Add('Query', $query) + # remove unused PSBoundParameters in the Invoke-AzGraph function + $PSBoundParameters.Remove('SubscriptionName') | Out-Null + $PSBoundParameters.Remove('Condition') | Out-Null + } + + process { + $response = Invoke-AzGraph @PSBoundParameters + } + + end { + return [AzGraphSubscription[]]$response + } +} + + +<# +.SYNOPSIS +Get resources group(s) in specified subscription. + +.PARAMETER ResourceId +ID of the resource group to be retrieved. +.PARAMETER SubscriptionId +Specifies the ID of the subscription that contains resource groups to get. +.PARAMETER ManagementGroup +Specifies the ID of the ManagementGroup that contains resource groups to get. +.PARAMETER ResourceGroupName +Specifies the name of the resource group to get. +.PARAMETER Condition +Optional query condition. +#> +function Get-AzGraphResourceGroup { + [CmdletBinding(DefaultParameterSetName = 'Default')] + [OutputType([AzGraphResourceGroup[]])] + param ( + [Alias('i')] + [Parameter(Mandatory, Position = 0, ParameterSetName = 'Id')] + [string]$ResourceId, + + [Alias('n')] + [Parameter(Mandatory, ParameterSetName = 'ByName')] + [Parameter(ParameterSetName = 'InSubscription')] + [Parameter(ParameterSetName = 'InMngmtGroup')] + [string]$ResourceGroupName, + + [Alias('c')] + [Parameter(Mandatory, ParameterSetName = 'ByCondition')] + [Parameter(ParameterSetName = 'InSubscription')] + [Parameter(ParameterSetName = 'InMngmtGroup')] + [ValidateScript({ $_ -notmatch '\s*where\b' }, ErrorMessage = "`e[4mWHERE`e[24m keyword is not allowed.")] + [string]$Condition, + + [Alias('s')] + [Parameter(Mandatory, ParameterSetName = 'InSubscription')] + [guid]$SubscriptionId, + + [Alias('m')] + [Parameter(Mandatory, ParameterSetName = 'InMngmtGroup')] + [guid]$ManagementGroup, + + [int]$PageSize = 1000, + + [switch]$SkipPagination + ) + + begin { + # build filter + if ($PSBoundParameters.ResourceId) { + $filter = "id =~ '$ResourceId'" + $PSBoundParameters.TryAdd('SubscriptionId', ([AzGraphResourceGroup]$PSBoundParameters.ResourceId).SubscriptionId) | Out-Null + $PSBoundParameters.TryAdd('PageSize', 10) | Out-Null + $PSBoundParameters.Remove('ResourceId') | Out-Null + } else { + $filter = "type == 'microsoft.resources/subscriptions/resourcegroups'" + $filter += if ($PSBoundParameters.ResourceGroupName) { + " and name =~ '$($PSBoundParameters.ResourceGroupName)'" + } elseif ($PSBoundParameters.Condition) { + " and $($PSBoundParameters.Condition)" + } + } + # calculate query + $query = [string]::Join("`n", + 'ResourceContainers', + "| where $filter", + '| join kind=leftouter (', + ' ResourceContainers', + ' | where type =~ "microsoft.resources/subscriptions"', + ' | project subscription=name, subscriptionId', + ' ) on subscriptionId', + '| project id, name, type, tenantId, location, resourceGroup, subscriptionId, subscription, properties, tags' + ) + + # add PSBoundParameters for the Invoke-AzGraph function + $PSBoundParameters.Add('Query', $query) + # remove unused PSBoundParameters in the Invoke-AzGraph function + $PSBoundParameters.Remove('ResourceGroupName') | Out-Null + $PSBoundParameters.Remove('Condition') | Out-Null + } + + process { + $response = Invoke-AzGraph @PSBoundParameters + } + + end { + return [AzGraphResourceGroup[]]$response + } +} + + +<# +.SYNOPSIS +Get Azure resource group by name. + +.PARAMETER ResourceGroupName +Resource group name. +.PARAMETER SubscriptionId +Optional SubscriptionId to run query against. +.PARAMETER ManagementGroup +Optional ManagementGroup to run query against. +#> +function Get-AzGraphResourceGroupByName { + [CmdletBinding(DefaultParameterSetName = 'ByName')] + [OutputType([AzGraphResourceGroup[]])] + param ( + [Alias('n')] + [Parameter(Mandatory, Position = 0)] + [string]$ResourceGroupName, + + [Alias('s')] + [Parameter(Mandatory, ParameterSetName = 'InSubscription')] + [guid]$SubscriptionId, + + [Alias('m')] + [Parameter(Mandatory, ParameterSetName = 'InMngmtGroup')] + [guid]$ManagementGroup + ) + + process { + $rg = Get-AzGraphResourceGroup @PSBoundParameters -PageSize 100 | Sort-Object subscription + # select resource if query returned more than one result + if ($rg.Count -gt 1) { + Write-Warning 'Found more than one resource group matching the criteria!' + $i = Get-ArrayIndexMenu -Array $rg.subscription -Message 'Select subscription of the resource group' + $rg = $rg[$i] + } + } + + end { + return $rg + } +} + + +<# +.SYNOPSIS +Get resources using AzGraph. + +.PARAMETER ResourceId +ID of the resource to be retrieved. +.PARAMETER SubscriptionId +Specifies the ID of the subscription that contains resources to get. +.PARAMETER ManagementGroup +Specifies the ID of the ManagementGroup that contains resources groups to get. +.PARAMETER ResourceGroupName +The resource group the resource that is retrieved belongs in. +.PARAMETER ResourceType +The resource type of the resource to be retrieved. +.PARAMETER ResourceName +The name of the resource to be retrieved. +.PARAMETER Condition +Optional query condition. +#> +function Get-AzGraphResource { + [CmdletBinding(DefaultParameterSetName = 'Id')] + [OutputType([AzGraphResource[]])] + param ( + [Alias('i')] + [Parameter(Mandatory, Position = 0, ParameterSetName = 'Id')] + [string]$ResourceId, + + [Alias('g')] + [Parameter(Mandatory, ParameterSetName = 'Group')] + [Parameter(ParameterSetName = 'InSubscription')] + [Parameter(ParameterSetName = 'InMngmtGroup')] + [string]$ResourceGroupName, + + [Alias('t')] + [Parameter(Mandatory, ParameterSetName = 'Type')] + [Parameter(ParameterSetName = 'Group')] + [Parameter(ParameterSetName = 'InSubscription')] + [Parameter(ParameterSetName = 'InMngmtGroup')] + [ValidateScript({ $_ -match '\w+\.\w+/\w+' }, ErrorMessage = "`e[4m{0}`e[24m is not valid type.")] + [string]$ResourceType, + + [Alias('n')] + [Parameter(Mandatory, ParameterSetName = 'ByName')] + [Parameter(ParameterSetName = 'Group')] + [Parameter(ParameterSetName = 'Type')] + [Parameter(ParameterSetName = 'Condition')] + [Parameter(ParameterSetName = 'InSubscription')] + [Parameter(ParameterSetName = 'InMngmtGroup')] + [string]$ResourceName, + + [Alias('c')] + [Parameter(Mandatory, ParameterSetName = 'Condition')] + [Parameter(ParameterSetName = 'Group')] + [Parameter(ParameterSetName = 'Type')] + [Parameter(ParameterSetName = 'InSubscription')] + [Parameter(ParameterSetName = 'InMngmtGroup')] + [ValidateScript({ $_ -notmatch '\s*where\b' }, ErrorMessage = "`e[4mWHERE`e[24m keyword is not allowed.")] + [string]$Condition, + + [Alias('s')] + [Parameter(Mandatory, ParameterSetName = 'InSubscription')] + [guid]$SubscriptionId, + + [Alias('m')] + [Parameter(Mandatory, ParameterSetName = 'InMngmtGroup')] + [guid]$ManagementGroup, + + [int]$PageSize = 1000, + + [switch]$SkipPagination + ) + + begin { + Write-Debug "ParameterSetName: $($PSCmdlet.ParameterSetName)" + # build filter + if ($PSBoundParameters.ResourceId) { + $filter = "id =~ '$ResourceId'" + $PSBoundParameters.TryAdd('SubscriptionId', ([AzResource]$PSBoundParameters.ResourceId).SubscriptionId) | Out-Null + $PSBoundParameters.TryAdd('PageSize', 10) | Out-Null + $PSBoundParameters.Remove('ResourceId') | Out-Null + } else { + $filter = $PSBoundParameters.ResourceGroupName ? "resourceGroup =~ '$($PSBoundParameters.ResourceGroupName)'" : '' + $filter += $PSBoundParameters.ResourceType ? ($filter ? ' and ' : '') + "type =~ '$($PSBoundParameters.ResourceType)'" : '' + $filter += $PSBoundParameters.ResourceName ? ($filter ? ' and ' : '') + "name =~ '$($PSBoundParameters.ResourceName)'" : '' + $filter += $PSBoundParameters.Condition ? ($filter ? ' and ' : '') + $PSBoundParameters.Condition : '' + } + # calculate query + $query = [string]::Join("`n", + 'Resources', + "| where $filter", + '| join kind=leftouter (', + ' ResourceContainers', + ' | where type =~ "microsoft.resources/subscriptions"', + ' | project subscription=name, subscriptionId', + ' ) on subscriptionId', + '| project id, name, type, tenantId, kind, location, resourceGroup, subscriptionId, subscription, sku, properties, tags, identity' + ) + + # add PSBoundParameters for the Invoke-AzGraph function + $PSBoundParameters.Add('Query', $query) + # remove unused PSBoundParameters in the Invoke-AzGraph function + $PSBoundParameters.Remove('ResourceGroupName') | Out-Null + $PSBoundParameters.Remove('ResourceType') | Out-Null + $PSBoundParameters.Remove('ResourceName') | Out-Null + $PSBoundParameters.Remove('Condition') | Out-Null + } + + process { + $response = Invoke-AzGraph @PSBoundParameters + } + + end { + return [AzGraphResource[]]$response + } +} + + +<# +.SYNOPSIS +Get Azure resource object by name and type. + +.PARAMETER ResourceName +The name of the resource to be retrieved. +.PARAMETER ResourceType +The resource type of the resource to be retrieved. +.PARAMETER ExcludeTypes +Resource types to be excluded when retrieving the resource object. +.PARAMETER SubscriptionId +Optional SubscriptionId to run query against. +.PARAMETER ManagementGroup +Optional ManagementGroup to run query against. +#> +function Get-AzGraphResourceByName { + [CmdletBinding(DefaultParameterSetName = 'ByName')] + [OutputType([AzGraphResource[]])] + param ( + [Alias('n')] + [Parameter(Mandatory, Position = 0)] + [string]$ResourceName, + + [Alias('t')] + [Parameter(Mandatory, ParameterSetName = 'ByType')] + [Parameter(ParameterSetName = 'InSubscription')] + [Parameter(ParameterSetName = 'InMngmtGroup')] + [string]$ResourceType, + + [Alias('e')] + [ValidateScript({ $false -notin $_.ForEach{ $_ -match '\w+\.\w+/\w+' } }, ErrorMessage = "`e[4m{0}`e[24m is not valid type.")] + [string[]]$ExcludeTypes, + + [Alias('s')] + [Parameter(Mandatory, ParameterSetName = 'InSubscription')] + [guid]$SubscriptionId, + + [Alias('m')] + [Parameter(Mandatory, ParameterSetName = 'InMngmtGroup')] + [guid]$ManagementGroup + ) + + begin { + # add PSBoundParameters for the Get-AzGraphResource function + if ($PSBoundParameters.ExcludeTypes) { + $typesList = $PSBoundParameters.ExcludeTypes | Join-String -Separator ', ' -DoubleQuote + $PSBoundParameters.Add('Condition', "type !in~ ($typesList)") + $PSBoundParameters.Remove('ExcludeTypes') | Out-Null + } + } + + process { + $resource = Get-AzGraphResource @PSBoundParameters -PageSize 100 | Sort-Object subscription, resourceGroup, type + # select resource if query returned more than one result + if ($resource.Count -gt 1) { + Write-Warning 'Found more than one resource matching the criteria!' + $array = if ($ResourceType) { + $resource | Select-Object resourceGroup, subscription + } else { + $resource | Select-Object type, resourceGroup, subscription + } + $i = Get-ArrayIndexMenu -Array $array -Message 'Select resource' + $resource = $resource[$i] + } + } + + end { + return $resource + } +} diff --git a/modules/do-az/Functions/completers.ps1 b/modules/do-az/Functions/completers.ps1 new file mode 100644 index 00000000..7ebac40e --- /dev/null +++ b/modules/do-az/Functions/completers.ps1 @@ -0,0 +1,20 @@ +<# +.SYNOPSIS +Get list of Azure Subscriptions for the function ArgumentCompleter attribute. +#> +function ArgAzGetSubscriptions { + param ( + $commandName, + $parameterName, + $wordToComplete, + $commandAst, + $fakeBoundParameters + ) + + # generate and set the ValidateSet + $query = "ResourceContainers | where type =~ 'microsoft.resources/subscriptions' | project name" + [string[]]$possibleValues = Invoke-AzGraph -Query $query | Select-Object -ExpandProperty name + + # return matching branches + $possibleValues.Where({ $_ -like "$wordToComplete*" }).ForEach({ $_ }) +} diff --git a/modules/do-az/Functions/msgraph.ps1 b/modules/do-az/Functions/msgraph.ps1 new file mode 100644 index 00000000..cb3220e9 --- /dev/null +++ b/modules/do-az/Functions/msgraph.ps1 @@ -0,0 +1,199 @@ +<# +.SYNOPSIS +Send request to Microsoft Graph API. + +.PARAMETER Path +Request path. +.PARAMETER ApiVersion +API version. +.PARAMETER Token +Microsoft Graph access token. +.PARAMETER Filter +Filter specified for the API request. +.PARAMETER Select +Select specific fields in the API request. +.PARAMETER Method +Request method. Allowed values: Get, Patch, Post, Put, Delete. Default: Get. +.PARAMETER Body +Request payload provided as string or hashtable. +.PARAMETER InFile +Request payload provided as path to file. +.PARAMETER SkipPagination +Switch whether or not to retrieve paginated results. +.PARAMETER JsonOutput +Switch whether to return a response as json. +#> +function Invoke-MgApiRequest { + [CmdletBinding(DefaultParameterSetName = 'Default')] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [string]$Path, + + [ValidateScript({ $_ -match '^(v\d+\.\d+)|(beta)$' }, ErrorMessage = 'API version should be in the v0.0 format.')] + [ValidateNotNullOrEmpty()] + [string]$ApiVersion = 'v1.0', + + [securestring]$Token, + + [string]$Filter, + + [string[]]$Select, + + [ValidateSet('Get', 'Patch', 'Post', 'Put', 'Delete')] + [string]$Method = 'Get', + + [Parameter(Mandatory, ParameterSetName = 'Payload:Body')] + [ValidateNotNullorEmpty()] + [object]$Body, + + [Alias('f')] + [Parameter(Mandatory, ParameterSetName = 'Payload:File')] + [ValidateScript({ Test-Path $_ -PathType 'Leaf' }, ErrorMessage = "'{0}' is not a valid path.")] + [string]$InFile, + + [switch]$SkipPagination, + + [switch]$JsonOutput + ) + + begin { + # get Azure ARM access token if not prvided + if (-not $Token) { + $Token = (Get-MsoToken -ResourceUrl 'https://graph.microsoft.com/').Token + } + # build Azure REST API request parameters for splatting + $params = @{ + Method = $Method + Authentication = 'Bearer' + Token = $Token + Headers = @{ 'Content-Type' = 'application/json' } + ErrorAction = 'Stop' + } + + # add payload + if ($Method -in @('Patch', 'Post', 'Put')) { + if ($Body) { + $params.Body = switch -Regex ($Body.GetType().Name) { + String { + $Body + } + 'Hashtable|OrderedDictionary' { + $Body | ConvertTo-Json -Depth 99 + } + default { + $null + } + } + } elseif ($InFile) { + $params.InFile = $InFile + } + } + + # build Query + if ($PSBoundParameters.Filter -or $PSBoundParameters.Select) { + $Query = '?' + if ($PSBoundParameters.Filter) { + $Query += "`$filter=$($Filter.Replace(' ', '%20').Replace("'", '%27'))" + } + if ($PSBoundParameters.Select) { + if ($PSBoundParameters.Filter) { + $Query += '&' + } + $Query += "`$select=$($Select.Trim() | Join-String -Separator ',')" + } + } + + # initialize variables + $response = $null + $responseList = [System.Collections.Generic.List[PSCustomObject]]::new() + } + + process { + # calculate request Uri + $params.Uri = [System.UriBuilder]::new( + 'https', + 'graph.microsoft.com', + 443, + "${ApiVersion}/${Path}", + $Query + ).Uri + # write verbose messages + Write-Verbose "$($params.Method.ToUpper()) $($params.Uri)" + if ($params.Body) { + Write-Verbose "Body`n$($params.Body)" + } + do { + # send API request + try { + $response = Invoke-CommandRetry { + Invoke-RestMethod @params + } + } catch { + if ($PSBoundParameters.ErrorAction -eq 'SilentlyContinue') { + Write-Verbose $_ + } else { + Write-Verbose $_.Exception.GetType().FullName + Write-Error $_ + } + } + # add response to response list + if ($response.value) { + $response.value.ForEach({ $responseList.Add($_) }) + } else { + $response.ForEach({ $responseList.Add($_) }) + } + # check pagination + if ($response.'@odata.nextLink') { + if ($SkipPagination) { + $response.'@odata.nextLink' = $null + } else { + $params.Uri = $response.'@odata.nextLink' + } + } + } while ($response.'@odata.nextLink') + } + + end { + # return response + if ($JsonOutput) { + if (Get-Command jq -CommandType Application -ErrorAction SilentlyContinue) { + return $responseList | ConvertTo-Json -Depth 99 | jq + } else { + return $responseList | ConvertTo-Json -Depth 99 + } + } else { + return $responseList + } + } +} + +<# +.SYNOPSIS +Get federated credentials for an Azure AD application. +.PARAMETER ApplicationObjectId +The object ID of the Azure AD application. +.PARAMETER ApiVersion +API version of the Microsoft Graph. +#> +function Get-MgAppFederatedCredential { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0)] + [ValidateNotNullOrEmpty()] + [string]$ApplicationObjectId, + + [ValidateScript({ $_ -match '^(v\d+\.\d+)|(beta)$' }, ErrorMessage = 'API version should be in the v0.0 format.')] + [ValidateNotNullOrEmpty()] + [string]$ApiVersion + ) + + begin { + # update PSBoundParameters + $PSBoundParameters['Path'] = "applications/$ApplicationObjectId/federatedIdentityCredentials" + $PSBoundParameters.Remove('ApplicationObjectId') | Out-Null + } + + process { + return Invoke-MgApiRequest @PSBoundParameters + } +} diff --git a/modules/do-az/do-az.psd1 b/modules/do-az/do-az.psd1 new file mode 100644 index 00000000..bac45dcc --- /dev/null +++ b/modules/do-az/do-az.psd1 @@ -0,0 +1,107 @@ +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'do-az.psm1' + + # Version number of this module. + ModuleVersion = '1.22.5' + + # Supported PSEditions + CompatiblePSEditions = @('Core') + + # ID used to uniquely identify this module + GUID = 'e6489e60-2302-441c-a1ed-25ab5d2b52d5' + + # Author of this module + Author = 'Szymon Osiecki' + + # Copyright statement for this module + Copyright = '(c) Szymon Osiecki. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'This module is intended to streamline work with Azure.' + + # Minimum version of the PowerShell engine required by this module + PowerShellVersion = '7.0' + + # Modules that must be imported into the global environment prior to importing this module + RequiredModules = @( + 'do-common' + 'Az.Accounts' + 'Az.ResourceGraph' + ) + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + ScriptsToProcess = @( + 'Classes/do-az.ps1' + ) + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @( + # az + 'Connect-AzContext' + 'Get-AzCtx' + 'Get-AzResourceTypeApiVersions' + 'Get-MsoToken' + 'Set-AzKeyVaultAccessPolicyApi' + 'Get-KeyVaultCertificate' + 'Get-KeyVaultSecret' + 'Set-KeyVaultSecret' + 'Get-VirtualNetwork' + 'Get-PrivateEndpoint' + 'Set-SubscriptionMenu' + 'Invoke-AzApiRequest' + 'Get-AksCredential' + # azgraph + 'Invoke-AzGraph' + 'Get-AzGraphSubscription' + 'Get-AzGraphResourceGroup' + 'Get-AzGraphResourceGroupByName' + 'Get-AzGraphResource' + 'Get-AzGraphResourceByName' + # completers + 'ArgAzGetSubscriptions' + # aks + 'Set-AksFederatedCredential' + # msgraph + 'Invoke-MgApiRequest' + 'Get-MgAppFederatedCredential' + ) + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = '*' + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @( + 'ssm' + 'setfcaks' + ) + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + LicenseUri = 'https://github.com/szymonos/ps-modules/blob/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/szymonos/ps-modules' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + # Prerelease = 'beta' + + } # End of PSData hashtable + + } # End of PrivateData hashtable + +} diff --git a/modules/do-az/do-az.psm1 b/modules/do-az/do-az.psm1 new file mode 100644 index 00000000..f53ace92 --- /dev/null +++ b/modules/do-az/do-az.psm1 @@ -0,0 +1,46 @@ +$ErrorActionPreference = 'Stop' +# functions +. $PSScriptRoot/Functions/az.ps1 +. $PSScriptRoot/Functions/azgraph.ps1 +. $PSScriptRoot/Functions/completers.ps1 +. $PSScriptRoot/Functions/msgraph.ps1 + +$exportModuleMemberParams = @{ + Function = @( + # az + 'Connect-AzContext' + 'Get-AzCtx' + 'Get-AzResourceTypeApiVersions' + 'Get-MsoToken' + 'Set-AzKeyVaultAccessPolicyApi' + 'Get-KeyVaultCertificate' + 'Get-KeyVaultSecret' + 'Set-KeyVaultSecret' + 'Get-VirtualNetwork' + 'Get-PrivateEndpoint' + 'Set-SubscriptionMenu' + 'Invoke-AzApiRequest' + 'Get-AksCredential' + # azgraph + 'Invoke-AzGraph' + 'Get-AzGraphSubscription' + 'Get-AzGraphResourceGroup' + 'Get-AzGraphResourceGroupByName' + 'Get-AzGraphResource' + 'Get-AzGraphResourceByName' + # completers + 'ArgAzGetSubscriptions' + # aks + 'Set-AksFederatedCredential' + # msgraph + 'Invoke-MgApiRequest' + 'Get-MgAppFederatedCredential' + ) + Variable = @() + Alias = @( + 'ssm' + 'setfcaks' + ) +} + +Export-ModuleMember @exportModuleMemberParams diff --git a/modules/do-common/Functions/certs.ps1 b/modules/do-common/Functions/certs.ps1 new file mode 100644 index 00000000..0dad96af --- /dev/null +++ b/modules/do-common/Functions/certs.ps1 @@ -0,0 +1,539 @@ +<# +.SYNOPSIS +Add CommonName, SubjectAlternativeName, SubjectKeyIdentifier and AuthorityKeyIdentifier properties to X509 certificate. + +.PARAMETER Certificate +X509Certificate2 certificate. +#> +function Add-CertificateProperties { + [CmdletBinding()] + [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2[]])] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [System.Security.Cryptography.X509Certificates.X509Certificate2]$Certificate + ) + + begin { + # instantiate list for storing X509 certificates + $certs = [System.Collections.Generic.List[System.Security.Cryptography.X509Certificates.X509Certificate2]]::new() + } + + process { + # Common Name + $cn = [regex]::Match($Certificate.Subject, '(?<=CN=)(.)+?(?=,|$)') + if ($cn) { + $cn = $cn.Value.Trim().Trim('"') + $Certificate | Add-Member -MemberType NoteProperty -Name 'CommonName' -Value $cn -PassThru ` + | Add-Member -MemberType AliasProperty -Name 'CN' -Value CommonName + } + # Subject Alternative Name + $san = $Certificate.Extensions.Where({ $_.Oid.FriendlyName -match 'Subject Alternative Name' }) + if ($san) { + $san = $san.Format(1).Trim() + $Certificate ` + | Add-Member -MemberType NoteProperty -Name 'SubjectAlternativeName' -Value $san -PassThru ` + | Add-Member -MemberType AliasProperty -Name 'SAN' -Value SubjectAlternativeName + } + # Subject Key Identifier + $ski = $Certificate.Extensions.Where({ $_.Oid.FriendlyName -match 'Subject Key Identifier' }) + if ($ski) { + $ski = $ski.Format(1).Trim().Replace(':', '').ToUpper() + $Certificate ` + | Add-Member -MemberType NoteProperty -Name 'SubjectKeyIdentifier' -Value $ski -PassThru ` + | Add-Member -MemberType AliasProperty -Name 'SKI' -Value SubjectKeyIdentifier + } + # Authority Key Identifier + $aki = $Certificate.Extensions.Where({ $_.Oid.FriendlyName -match 'Authority Key Identifier' }) + if ($aki) { + $aki = $aki.Format(1).Trim().Replace(':', '').Replace('KeyID=', '').ToUpper() + $Certificate ` + | Add-Member -MemberType NoteProperty -Name 'AuthorityKeyIdentifier' -Value $aki -PassThru ` + | Add-Member -MemberType AliasProperty -Name 'AKI' -Value AuthorityKeyIdentifier + } + $certs.Add($Certificate) + } + + end { + return $certs + } +} + + +<# +.SYNOPSIS +Create X509Certificate2 object(s) from PEM encoded certificate(s). + +.PARAMETER InputObject +String with PEM encoded certificate. +.PARAMETER Path +Path to PEM encoded certificate file. +#> +function ConvertFrom-PEM { + [CmdletBinding()] + [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2[]])] + param ( + [Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'FromString')] + [string]$InputObject, + + [Parameter(Mandatory, Position = 0, ParameterSetName = 'FromPath')] + [ValidateScript({ Test-Path $_ -PathType 'Leaf' }, ErrorMessage = "'{0}' is not a valid file path.")] + [string]$Path + ) + + begin { + # list to store input certificate strings + $pemTxt = [System.Collections.Generic.List[string]]::new() + # hashset for storing parsed pem certificates + $pemSplit = [System.Collections.Generic.HashSet[string]]::new() + # list to store decoded certificates + $x509Certs = [System.Collections.Generic.List[Security.Cryptography.X509Certificates.X509Certificate2]]::new() + } + + process { + switch ($PsCmdlet.ParameterSetName) { + FromPath { + # read certificate file + Resolve-Path $Path | ForEach-Object { + $pemTxt.Add([IO.File]::ReadAllText($_)) + } + continue + } + FromString { + $InputObject.ForEach({ $pemTxt.Add($_) }) + continue + } + } + } + + end { + # parse certificate string + [regex]::Matches( + [string]::Join("`n", $pemTxt).Replace("`r`n", "`n"), + '(?<=-{5}BEGIN[\w ]+CERTIFICATE-{5}\n)[\S\n]+(?=\n-{5}END[\w ]+CERTIFICATE-{5})' + ).Value.ForEach({ $pemSplit.Add($_) | Out-Null }) + # convert PEM encoded certificates to X509 certificate objects + foreach ($pem in $pemSplit) { + $decCrt = [Security.Cryptography.X509Certificates.X509Certificate2]::new([Convert]::FromBase64String($pem)) + $x509Certs.Add($decCrt) + } + + return $x509Certs + } +} + + +<# +.SYNOPSIS +Create PEM encoded certificate from X509Certificate2 object. + +.PARAMETER Certificate +X509Certificate2 certificate. +.PARAMETER AddHeader +Add certificate header with Issuer, Subject, Label, Serial and Fingerprint info. +#> +function ConvertTo-PEM { + [CmdletBinding()] + [OutputType([System.Collections.Generic.List[string]])] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [System.Security.Cryptography.X509Certificates.X509Certificate2]$Certificate, + + [switch]$AddHeader + ) + + begin { + # instantiate list for storing PEM encoded certificates + $pems = [System.Collections.Generic.List[string]]::new() + } + + process { + # convert certificate to base64 + $base64 = [System.Convert]::ToBase64String($Certificate.RawData) + # build PEM encoded X.509 certificate + $builder = [System.Text.StringBuilder]::new() + if ($AddHeader) { + $builder.AppendLine("# Issuer: $($Certificate.Issuer)") | Out-Null + $builder.AppendLine("# Subject: $($Certificate.Subject)") | Out-Null + $builder.AppendLine("# Label: $([regex]::Match($Certificate.Subject, '(?<=CN=)(.)+?(?=,|$)').Value)") | Out-Null + $builder.AppendLine("# Serial: $($Certificate.SerialNumber)") | Out-Null + $builder.AppendLine("# SHA1 Fingerprint: $($Certificate.Thumbprint)") | Out-Null + } + $builder.AppendLine('-----BEGIN CERTIFICATE-----') | Out-Null + for ($i = 0; $i -lt $base64.Length; $i += 64) { + $length = [System.Math]::Min(64, $base64.Length - $i) + $builder.AppendLine($base64.Substring($i, $length)) | Out-Null + } + $builder.AppendLine('-----END CERTIFICATE-----') | Out-Null + # create object with parsed common name and PEM encoded certificate + $pems.Add($builder.ToString().Replace("`r`n", "`n")) + } + + end { + return $pems + } +} + + +<# +.SYNOPSIS +Get certificate(s) from specified Uri. + +.PARAMETER Uri +Uri used for intercepting certificate. +.PARAMETER BuildChain +Switch whether to build full certificate chain. +.PARAMETER IgnoreValidation +Ignore validation errors for getting certificate/building chain. +#> +function Get-Certificate { + [CmdletBinding()] + [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2[]])] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$Uri, + + [switch]$BuildChain, + + [switch]$IgnoreValidation + ) + + begin { + $tcpClient = [System.Net.Sockets.TcpClient]::new($Uri, 443) + if ($BuildChain) { + $chain = [System.Security.Cryptography.X509Certificates.X509Chain]::new() + } + if ($IgnoreValidation) { + $sslStream = [System.Net.Security.SslStream]::new($tcpClient.GetStream(), $false, { $true }) + if ($BuildChain) { + $chain.ChainPolicy.VerificationFlags = [System.Security.Cryptography.X509Certificates.X509VerificationFlags]::AllFlags + } + } else { + $sslStream = [System.Net.Security.SslStream]::new($tcpClient.GetStream()) + } + } + + process { + try { + $sslStream.AuthenticateAsClient($Uri) + $certificate = $sslStream.RemoteCertificate + } finally { + $sslStream.Close() + } + + if ($BuildChain) { + $isChainValid = $chain.Build($certificate) + if ($isChainValid) { + $certificate = $chain.ChainElements.Certificate + } else { + Write-Warning 'SSL certificate chain validation failed.' + } + } + } + + end { + return $certificate + } +} + + +<# +.SYNOPSIS +Get certificate(s) from specified Uri using OpenSSL application. + +.PARAMETER Uri +Uri used for intercepting certificate. +.PARAMETER BuildChain +Switch whether to build full certificate chain. +#> +function Get-CertificateOpenSSL { + [CmdletBinding()] + [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2[]])] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$Uri, + + [switch]$BuildChain + ) + + begin { + # check if OpenSSL is installed + if (-not (Get-Command openssl -CommandType Application -ErrorAction SilentlyContinue)) { + Throw 'OpenSSL not found. Script execution halted.' + } + + # build the OpenSSL argument list + [System.Collections.Generic.List[string]]$cmdArgs = @('s_client') + $cmdArgs.Add('-connect') + $cmdArgs.Add("${Uri}:443") + if ($BuildChain) { + $cmdArgs.Add('-showcerts') + } + } + + process { + try { + # Use the call operator (&) to execute OpenSSL with arguments + $opensslOutput = Out-Null | & openssl @cmdArgs 2>$null + } catch { + Throw "Error executing OpenSSL: $_" + } + + if (-not $opensslOutput) { + Throw "No output from OpenSSL. Possibly an unknown host: `"$Uri`"." + } + + # Normalize the output: join array into one string and standardize line breaks + $outputText = ($opensslOutput -join "`n") -replace "`r`n", "`n" + + # Define a regex pattern to match PEM encoded certificates + $pemPattern = '(?<=-----BEGIN CERTIFICATE-----\n)[\S\n]+?(?=\n-----END CERTIFICATE-----)' + $reMatches = [regex]::Matches($outputText, $pemPattern) + + if ($reMatches.Count -eq 0) { + Throw "No certificates found in OpenSSL output for `"$Uri`"." + } + + # Convert each PEM block to an X509Certificate2 object + foreach ($match in $reMatches) { + try { + $certBytes = [Convert]::FromBase64String($match.Value) + [Security.Cryptography.X509Certificates.X509Certificate2]::new($certBytes) + } catch { + Write-Warning 'Failed to convert a certificate block to X509Certificate2.' + } + } + } +} + + +<# +.SYNOPSIS +Get root TLS certificates in the system. +#> +function Get-RootCertificates { + if ($IsWindows) { + Get-ChildItem Cert:\LocalMachine\Root + } elseif ($IsLinux) { + $sysId = (Select-String '(?<=^ID.+)(alpine|arch|fedora|debian|ubuntu|opensuse)' -List /etc/os-release).Matches.Value + $certPath = $sysId -eq 'opensuse' ? '/etc/ssl/ca-bundle.pem' : '/etc/ssl/certs/ca-certificates.crt' + ConvertFrom-PEM -Path $certPath + } +} + + +<# +.SYNOPSIS +Show certificate chain for a specified Uri. + +.PARAMETER Uri +Uri used for intercepting certificate chain. +.PARAMETER InputObject +Object from pipeline to show certificate properties. +.PARAMETER BuildChain +Build chain for certificate obtained from Uri. +.PARAMETER Extended +Switch, whether to show extended certificate properties. +.PARAMETER Strip +Switch, whether to show non-null certificate properties. +.PARAMETER All +Switch, whether to show all certificate properties. +.PARAMETER OpenSSL +Use OpenSSL to retrieve certificate chain. +#> +function Show-Certificate { + [CmdletBinding(DefaultParameterSetName = 'Compact')] + [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2[]])] + param ( + [Parameter(Mandatory, Position = 0, ParameterSetName = 'FromUri')] + [string]$Uri, + + [Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'FromPipeline')] + [System.Security.Cryptography.X509Certificates.X509Certificate2[]]$InputObject, + + [Parameter(ParameterSetName = 'FromUri')] + [switch]$BuildChain, + + [switch]$Extended, + + [switch]$Strip, + + [switch]$All, + + [switch]$OpenSSL + ) + + begin { + $WarningPreference = 'Stop' + + # build properties for Show-Object function + $showCertProp = if ($All) { + @{ } + } elseif ($Strip) { + @{ Strip = $true } + } elseif ($Extended) { + @{ + TypeName = @('System.Boolean', 'System.DateTime', 'System.Int32', 'System.String') + MemberType = @('AliasProperty', 'Property') + Strip = $true + } + } else { + @{ + TypeName = @('System.DateTime', 'System.String') + MemberType = @('AliasProperty', 'Property') + Strip = $true + } + } + + # instantiate generic list for storing certificates, so all certs from pipeline are processed + $cert = [System.Collections.Generic.List[System.Security.Cryptography.X509Certificates.X509Certificate2]]::new() + + # clean PSBoundParameters for Get-Certificate function + @('Extended', 'Strip', 'All').ForEach({ $PSBoundParameters.Remove($_) | Out-Null }) + } + + process { + switch ($PsCmdlet.ParameterSetName) { + FromUri { + $cert = if ($PSBoundParameters.OpenSSL) { + $PSBoundParameters.Remove('OpenSSL') | Out-Null + Get-CertificateOpenSSL @PSBoundParameters | Add-CertificateProperties + } else { + Get-Certificate @PSBoundParameters | Add-CertificateProperties + } + } + FromPipeline { + $crt = $InputObject | Add-CertificateProperties + $cert.Add($crt) + } + } + } + + end { + $cert | Show-Object @showCertProp + } +} + + +<# +.SYNOPSIS +Show certificate chain for a specified Uri. + +.PARAMETER Uri +Uri used for intercepting certificate chain. +.PARAMETER Extended +Switch, whether to show extended certificate properties. +.PARAMETER Strip +Switch, whether to show non-null certificate properties. +.PARAMETER All +Switch, whether to show all certificate properties. +.PARAMETER OpenSSL +Use OpenSSL to retrieve certificate chain. +#> +function Show-CertificateChain { + [CmdletBinding(DefaultParameterSetName = 'Compact')] + [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2[]])] + param ( + [Parameter(Mandatory, Position = 0)] + [string]$Uri, + + [Parameter(Mandatory, ParameterSetName = 'Extended')] + [switch]$Extended, + + [Parameter(Mandatory, ParameterSetName = 'Strip')] + [switch]$Strip, + + [Parameter(Mandatory, ParameterSetName = 'All')] + [switch]$All, + + [switch]$OpenSSL + ) + + begin { + $PSBoundParameters.Add('BuildChain', $true) + } + + process { + Show-Certificate @PSBoundParameters + } +} + + +<# +.SYNOPSIS +Decode PEM certificate(s) and show their properties. + +.PARAMETER InputObject +String with PEM encoded certificate(s). +.PARAMETER Path +Path to PEM encoded certificate file(s). +.PARAMETER Extended +Switch, whether to show extended certificate properties. +.PARAMETER Strip +Switch, whether to show non-null certificate properties. +.PARAMETER All +Switch, whether to show all certificate properties. +.PARAMETER OpenSSL +Use OpenSSL to retrieve certificate chain. +#> +function Show-ConvertedPem { + [OutputType([System.Security.Cryptography.X509Certificates.X509Certificate2[]])] + param ( + # FromString sets + [Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'FromString')] + [string]$InputObject, + + # FromPath sets + [Parameter(Mandatory, Position = 0, ParameterSetName = 'FromPath')] + [ValidateScript({ Test-Path $_ -PathType 'Leaf' }, ErrorMessage = "'{0}' is not a valid file path.")] + [string]$Path, + + # Extended switch for each set + [switch]$Extended, + + # Strip switch for each set + [switch]$Strip, + + # All switch for each set + [switch]$All, + + [switch]$OpenSSL + ) + + begin { + # check that at most one of -Extended, -Strip, -All is specified + if ($PSBoundParameters.Keys.ForEach({ $_ -in @('Extended', 'Strip', 'All') }).Where(({ $_ })).Count -le 1) { + $x509Certs = [System.Collections.Generic.List[Security.Cryptography.X509Certificates.X509Certificate2]]::new() + $continue = $true + } else { + Write-Warning 'Only one of -Extended, -Strip, or -All parameters can be specified.' + $continue = $false + return + } + } + + process { + if ($continue) { + if ($PSBoundParameters.Path) { + ConvertFrom-PEM -Path $PSBoundParameters.Path | ForEach-Object { + $x509Certs.Add($_) + } + } elseif ($PSBoundParameters.InputObject) { + ConvertFrom-PEM -InputObject $PSBoundParameters.InputObject | ForEach-Object { + $x509Certs.Add($_) + } + } else { + Throw 'Either InputObject or Path parameter must be specified.' + } + } + } + + end { + if ($continue) { + # return the list of X509 certificates + @('InputObject', 'Path').ForEach({ $PSBoundParameters.Remove($_) | Out-Null }) + $x509Certs | Show-Certificate @PSBoundParameters + } + } +} + +Set-Alias -Name pemdec -Value Show-ConvertedPem diff --git a/modules/do-common/Functions/cli.ps1 b/modules/do-common/Functions/cli.ps1 new file mode 100644 index 00000000..8af17d98 --- /dev/null +++ b/modules/do-common/Functions/cli.ps1 @@ -0,0 +1,131 @@ +<# +.SYNOPSIS +Module providing a cli command wrappers. +#> + + +<# +.SYNOPSIS +Executes dig command and colorizes output for better readability. + +.DESCRIPTION +Runs dig with provided arguments, captures all output, and applies color formatting +to hostnames and responses. Each unique host gets assigned a distinct color code. + +.PARAMETER ArgumentList +Arguments to pass to dig command. Accepts multiple arguments. + +.EXAMPLE +Invoke-DigColored example.com +# Runs dig for example.com and colorizes the output. + +.EXAMPLE +Invoke-DigColored example.com -StripRawOutput +# Runs dig for example.com and colorizes the output, without printing raw output. + +.EXAMPLE +Invoke-DigColored @('google.com', 'ANY') +# Runs dig with multiple arguments and colorizes the output. +#> +function Invoke-DigColored { + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromRemainingArguments)] + [string[]]$ArgumentList, + + [Alias('s')] + [switch]$StripRawOutput + ) + + begin { + $ErrorActionPreference = 'Stop' + + # verify dig is available + if (-not (Get-Command dig -ErrorAction SilentlyContinue)) { + throw 'dig command not found. Please install dig (dnsutils package).' + } + } + + process { + try { + # execute dig and capture all output + $digOutput = & dig @ArgumentList 2>&1 + if ($?) { + $allLines = $digOutput.Trim().Where( { -not [string]::IsNullOrWhiteSpace($_) } ) + } else { + Show-LogContext 'dig command failed to execute.' -Level ERROR + return + } + + if ($allLines.Count -eq 0) { + Show-LogContext 'No output from dig command.' -Level WARNING + return + } + + $hosts = [System.Collections.Generic.Dictionary[string, int]]::new() + $uniqueHostCount = 0 + + # calculate max host length for alignment + $maxHostLength = 0 + foreach ($line in $allLines) { + if ($line -match '^\s*$' -or $line -match '^;') { continue } + $parts = $line -split '\s+', 0, 'RegexMatch' + foreach ($part in $parts) { + if ($part.Length -gt $maxHostLength) { + $maxHostLength = $part.Length + } + } + } + + if ($PSBoundParameters.ContainsKey('StripRawOutput')) { + # write initial new line + Write-Host '' + } else { + # print raw output in dim text + Write-Host "`e[2m$($allLines -join "`n")`e[0m`n" + } + + # process and colorize DNS records + foreach ($line in $allLines) { + # skip empty lines and comments + if ($line -match '^\s*$' -or $line -match '^;') { continue } + + # parse DNS record: host, ttl, class, type, value + if ($line -match '^(\S+)\s+([0-9]+)\s+(\S+)\s+(\S+)\s+(.+)$') { + $hostname = $Matches[1] + $ttl = $Matches[2] + $class = $Matches[3] + $type = $Matches[4] + $value = $Matches[5] + + # assign color to host if not seen before (starting at color 91) + if (-not $hosts.ContainsKey($hostname)) { + $hosts[$hostname] = 91 + $uniqueHostCount++ + } + + # assign color to value if not seen before + if (-not $hosts.ContainsKey($value)) { + $hosts[$value] = 91 + $uniqueHostCount++ + } + + # format and print colorized output + $hostColor = $hosts[$hostname] + $valueColor = $hosts[$value] + + Write-Host ("`e[1;{0}m{1,-$maxHostLength}`e[0m {2,5} {3} {4,-5} `e[1;{5}m{6}`e[0m" -f ` + $hostColor, $hostname, $ttl, $class, $type, $valueColor, $value) + } + } + } catch { + Show-LogContext $_ + throw + } + } + end { + # write final new line + Write-Host '' + } +} + +# create alias for convenience +Set-Alias -Name digc -Value Invoke-DigColored -Scope Global -Option AllScope -Force diff --git a/modules/do-common/Functions/common.ps1 b/modules/do-common/Functions/common.ps1 new file mode 100644 index 00000000..2d78d194 --- /dev/null +++ b/modules/do-common/Functions/common.ps1 @@ -0,0 +1,1035 @@ +<# +.SYNOPSIS +Convert text from base64 string. + +.PARAMETER InputObject +Base64 encoded string to be converted. +#> +function ConvertFrom-Base64 { + [CmdletBinding()] + [OutputType([string])] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [string]$InputObject + ) + + process { + return [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($InputObject)) + } +} + + +<# +.SYNOPSIS +Convert text to base64 string. + +.PARAMETER InputObject +Text to be converted to base64 string. +$InputObject = (Get-AzAccessToken -ResourceUrl 'https://cognitiveservices.azure.com').Token | ConvertFrom-SecureString -AsPlainText +#> +function ConvertTo-Base64 { + [CmdletBinding()] + [OutputType([string])] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [string]$InputObject + ) + + process { + return [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($InputObject)) + } +} + + +<# +.SYNOPSIS +Convert text from base64url encoded string. + +.PARAMETER InputObject +Base64url encoded string to be converted. +#> +function ConvertFrom-Base64Url { + [CmdletBinding()] + [OutputType([string])] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [string]$InputObject + ) + + process { + $base64 = $InputObject.Replace('-', '+').Replace('_', '/') + switch ($base64.Length % 4) { + 2 { $base64 += '==' } + 3 { $base64 += '=' } + 0 { } + default { throw 'Invalid base64url string length' } + } + return [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($base64)) + } +} + + +<# +.SYNOPSIS +Decode JWT token. + +.PARAMETER InputObject +JWT token string to be converted. +#> +function ConvertFrom-JWT { + [CmdletBinding()] + [OutputType([string])] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [string]$InputObject + ) + + process { + # get JWT header and payload + $header, $payload = $InputObject.Split('.')[0..1].ForEach({ + try { $_ | ConvertFrom-Base64Url | ConvertFrom-Json -AsHashtable } catch { @{} } + } + ) + + # convert iat, nbf, exp to DateTime + if ($payload.iat) { + $payload.iat = [DateTimeOffset]::FromUnixTimeSeconds($payload.iat).DateTime + } + if ($payload.nbf) { + $payload.nbf = [DateTimeOffset]::FromUnixTimeSeconds($payload.nbf).DateTime + } + if ($payload.exp) { + $payload.exp = [DateTimeOffset]::FromUnixTimeSeconds($payload.exp).DateTime + } + + # merge header and payload into a single ordered dictionary + $merged = [ordered]@{} + $header.GetEnumerator().ForEach({ $merged[$_.Key] = $_.Value }) + $payload.GetEnumerator().ForEach({ $merged[$_.Key] = $_.Value }) + } + + end { + # return merged JWT claims + return [PSCustomObject]$merged + } +} + + +<# +.SYNOPSIS +Converts configuration file to an ordered dictionary. + +.PARAMETER Path +Path to the configuration file. +.PARAMETER InputObject +Configuration file content passed to the cmdlet through pipeline. +#> +function ConvertFrom-Cfg { + [CmdletBinding()] + [OutputType([System.Collections.Specialized.OrderedDictionary])] + param ( + [Parameter(Mandatory, Position = 0, ParameterSetName = 'FromFile')] + [ValidateScript({ Test-Path $_ -PathType Leaf }, ErrorMessage = "'{0}' is not a valid file path.")] + [string]$Path, + + [Parameter(Mandatory, ValueFromPipeline, ParameterSetName = 'FromPipeline')] + [object]$InputObject + ) + + begin { + # instantiate generic list for the configuration content + $cfgList = [System.Collections.Generic.List[string]]::new() + } + + process { + switch ($PsCmdlet.ParameterSetName) { + FromFile { + $content = [System.IO.File]::ReadAllLines((Resolve-Path $Path)) + $content.ForEach({ $cfgList.Add($_) }) + } + FromPipeline { + if ($InputObject) { + $cfgList.Add( $InputObject ) + } + } + } + } + + end { + # build an ordered dictionary from cfg object + $cfg = [ordered]@{} + $header = @() + $section = $null + $CommentCount = 0 + + foreach ($line in $cfgList) { + if (-not $section -and $line -match '^\s*\[(.+)\]') { + # first section encountered; store section header + $section = $matches[1] + $cfg[$section] = [ordered]@{} + continue + } + if (-not $section) { + # before any section header, preserve header comments (only if they are comments) + if ($line -match '^\s*[#;].*') { + $header += $line + } + continue + } + if ($line -match '^\s*\[(.+)\]') { + # new section header encountered + $section = $matches[1] + $cfg[$section] = [ordered]@{} + $CommentCount = 0 + continue + } + elseif ($line -match '^\s*([#;].*)') { + # Comment within section + $CommentCount++ + $name = "Comment$CommentCount" + $cfg[$section][$name] = $matches[1] + continue + } + elseif ($line -match '^\s*(\w+)\s*=(.*)') { + # Key value pair + $name, $value = $matches[1..2] + $cfg[$section][$name] = $value.Trim() + continue + } + } + # store header in special key if any header comments were collected + if ($header.Count -gt 0) { + $cfg['__header__'] = $header -join "`n" + } + return $cfg + } +} + + +<# +.SYNOPSIS +Converts ordered dictionary to a configuration file/string. + +.PARAMETER OrderedDict +Input hashtable consisting a content to be converted to a configuration file. +.PARAMETER Path +Path to the configuration file to save the content to. +Without providing the parameter, prints the configuration string. +.PARAMETER LineFeed +Output the configuration file using LF EOF. +.PARAMETER Force +Force overwrite the destination file. +#> +function ConvertTo-Cfg { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [System.Collections.IDictionary]$OrderedDict, + + [string]$Path, + + [switch]$LineFeed, + + [switch]$Force + ) + + $ErrorActionPreference = 'Stop' + + if (-not $Force -and (Test-Path $Path)) { + Write-Error "$Path destination already exists." + } + + $builder = [System.Text.StringBuilder]::new() + # Restore header comments at the beginning if they exist + if ($OrderedDict.Contains("__header__")) { + $builder.AppendLine($OrderedDict['__header__']) | Out-Null + } + foreach ($enum in $OrderedDict.GetEnumerator()) { + if ($enum.Key -eq '__header__') { continue } + $section = $enum.Key + $builder.AppendLine("`n[$section]") | Out-Null + foreach ($cfg in $enum.Value.GetEnumerator()) { + if ($cfg.Key -like 'Comment*') { + $builder.AppendLine($cfg.Value) | Out-Null + } else { + $builder.AppendLine([string]::Join(' = ', $cfg.Key, $cfg.Value)) | Out-Null + } + } + } + + $content = $builder.ToString().Trim() + if ($LineFeed) { + $content = $content.Replace("`r`n", "`n") + } + if ($Path) { + Set-Content -Value $content -Path $Path + } else { + $content + } +} + + +<# +.SYNOPSIS +Convert all files in a directory to UTF8 and change EOLs from CRLF to LF. + +.PARAMETER Path +Directory to convert all files from. +#> +function ConvertTo-UTF8LF { + [CmdletBinding()] + [OutputType([System.Void])] + param ( + [Parameter(Position = 0, ValueFromPipeline)] + [ValidateScript({ Test-Path $_ -PathType 'Container' }, ErrorMessage = "'{0}' is not a valid folder path.")] + [string]$Path = '.' + ) + + begin { + $encoding = [System.Text.UTF8Encoding]::new($false) + $fileCnt = 0 + } + + process { + # get list of files to process, excluding .git subdirectory + $files = (Get-ChildItem $Path -File -Force -Recurse).Where({ $_.DirectoryName -notmatch '(/|\\)\.git\b' }) + # convert files + foreach ($file in $files) { + $content = [System.IO.File]::ReadAllText($file).Replace("`r`n", "`n") + [System.IO.File]::WriteAllText($file, $content, $encoding) + } + $fileCnt += $files.Count + } + + end { + Write-Host "Converted $fileCnt file(s)." + } +} + + +<# +.SYNOPSIS +Obfuscate input string by shifting letters in string by 13 positions. +To "decode" obfuscated text you should just run the function again as there are 26 base letters. + +.PARAMETER Text +Input string to be obfuscated. +#> +function Convert-ROT13 { + [CmdletBinding()] + [OutputType([string])] + param ( + [Parameter(Mandatory)] + [ValidateNotNullOrEmpty()] + [string]$Text + ) + + begin { + $strLen = $Text.Length + $rot13 = [char[]]::new($strLen) + } + + process { + for ($i = 0; $i -lt $strLen; $i++) { + [char]$c = $Text[$i] + $rot13[$i] = if ([char]::IsLetter($c)) { + [char]$base = [char]::IsUpper($c) ? 'A' : 'a' + [char](($c - $base + 13) % 26 + $base) + } else { + $c + } + } + } + + end { + return [string]::Join('', $rot13) + } +} + + +<# +.SYNOPSIS +Converts PowerShell object to json and prints it formatted if jq is available. + +.PARAMETER InputObject +Input object to be converted to json. +#> +function ConvertTo-JsonFormatted { + [CmdletBinding()] + param ( + [Parameter(Mandatory, ValueFromPipeline)] + [object]$InputObject + ) + + begin { + $jq = (Get-Command 'jq' -CommandType Application -ErrorAction SilentlyContinue) ? $true : $false + } + + process { + if ($jq) { + $InputObject | ConvertTo-Json -Depth 99 | jq + } else { + $InputObject | ConvertTo-Json -Depth 99 + } + } +} + +Set-Alias -Name json -Value ConvertTo-JsonFormatted + + +<# +.SYNOPSIS +Get item index(es) or value(s) of the provided array from selection menu. + +.PARAMETER Array +Array of strings to get the selection menu. +.PARAMETER Message +Optional menu header to display. +.PARAMETER Value +Flag to return value(s) instead of index(es). +.PARAMETER List +Flag to choose from selection list instead of single value. +.PARAMETER AllowNoSelection +Allow empty selection, otherwise keep prompting for input. +#> +function Get-ArrayIndexMenu { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0, ValueFromPipeline)] + [object[]]$Array, + + [Parameter(Position = 1)] + [string]$Message, + + [switch]$Value, + + [switch]$List, + + [switch]$AllowNoSelection + ) + begin { + # instantiate generic list to store the input array + $lst = [System.Collections.Generic.List[object]]::new() + } + + process { + # determine if the input array has multiple properties + if (-not $arrayType) { + $arrayType = ($Array | Select-Object * | Get-Member -MemberType NoteProperty).Count -gt 1 ? 'object' : 'string' + } + # add input array items to the generic list + $Array.ForEach({ $lst.Add($_) }) + } + + end { + # return if the input array has less then 2 items + if ($lst.Count -eq 0) { + return + } elseif ($lst.Count -eq 1) { + $indexes = [System.Collections.Generic.HashSet[int]]::new([int[]]0) + } else { + # create selection menu + $menu = switch ($arrayType) { + object { + $i = 0 + $lst ` + | Select-Object @{ N = '#'; E = { $lst.IndexOf($_) } }, @{ N = ' '; E = { '-' } }, * ` + | Format-Table -AutoSize ` + | Out-String -Stream ` + | ForEach-Object { $i -lt 3 ? "`e[1;92m$_`e[0m" : $_; $i++ } ` + | Out-String + continue + } + string { + $lst.ToArray().ForEach({ [PSCustomObject]@{ '#' = $lst.IndexOf($_); ' ' = '-'; 'V' = $_ } }) ` + | Format-Table -AutoSize -HideTableHeaders ` + | Out-String + continue + } + } + + # create prompt message + if (-not $Message) { + $Message = $List ? 'Enter comma/space separated selection list' : 'Enter selection' + } + $msg = "`n`e[4m$Message`e[0m:`n$menu" + + # read and validate input + do { + # instantiate indexes collection + $indexes = [System.Collections.Generic.HashSet[int]]::new() + # prompt for a selection from the input array + (Read-Host -Prompt $msg).Split([char[]]@(' ', ','), [StringSplitOptions]::RemoveEmptyEntries).ForEach({ + try { $indexes.Add($_) | Out-Null } catch { } + } + ) + # calculate stats for returned indexes + $stat = $indexes | Measure-Object -Minimum -Maximum + # evaluate if the Read-Host input is valid + $continue = if ($stat.Count -eq 0) { + $AllowNoSelection + } elseif ($stat.Count -eq 1 -or ($List -and $stat.Count -gt 0)) { + $stat.Minimum -ge 0 -and $stat.Maximum -lt $lst.Count + } else { + $false + } + } until ($continue) + } + + # return result + return $Value ? $indexes.ForEach({ $lst[$_] }) : [int[]]$indexes.ForEach({ $_ }) + } +} + + +<# +.SYNOPSIS +Get the aliases for any cmdlet. + +.PARAMETER CmdletName +Name of the cmdlet to get aliases for. +#> +function Get-CmdletAlias { + [CmdletBinding()] + param ( + [string]$CmdletName + ) + + Get-Alias | ` + Where-Object -FilterScript { $_.Definition -match $CmdletName } | ` + Sort-Object -Property Definition, Name | ` + Select-Object -Property Definition, Name +} + +Set-Alias -Name alias -Value Get-CmdletAlias + + +<# +.SYNOPSIS +Get environment variables from env file. + +.PARAMETER Path +Path to the env file. +#> +function Get-DotEnv { + [CmdletBinding()] + param ( + [Parameter(Position = 0)] + [string]$Path = '.env' + ) + + begin { + # load content of the env file + try { + $envContent = Get-Content -Path $Path -ErrorAction Stop + } catch [System.Management.Automation.ItemNotFoundException] { + Write-Warning "File does not exist ($Path)." + return + } catch { + Write-Verbose $_.Exception.GetType().FullName + Write-Error $_ + } + # instantiate hashtable to store variables + $envHash = [ordered]@{} + } + + process { + $envContent | ForEach-Object { + if ($_ -match '^([a-zA-Z_]+[a-zA-Z0-9_]*)=(.+)$') { + $envHash[$matches[1]] = $matches[2].Trim().Trim("'|`"") + } + } + } + + end { + return $envHash + } +} + + +<# +.SYNOPSIS +Set environment variables from env file. + +.PARAMETER Path +Path to the env file. +#> +function Set-DotEnv { + [CmdletBinding()] + param ( + [Parameter(Position = 0)] + [string]$Path = '.env' + ) + + $envHash = Get-DotEnv $Path + + foreach ($key in $envHash.Keys) { + [Environment]::SetEnvironmentVariable($key, $envHash[$key]) + } + + if ($envHash) { + Write-Verbose "Environmet variables set: $($envHash.Keys | Join-String -Separator ', ')" + } +} + +Set-Alias -Name src -Value Set-DotEnv + + +<# +.SYNOPSIS +Formats log message. + +.PARAMETER Message +Log message text to be printed. +.PARAMETER Level +Log level. +#> +function Get-LogMessage { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0)] + [ValidateNotNullOrEmpty()] + [string]$Message, + + [ValidateSet('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL')] + [string]$Level = 'INFO' + ) + + # calculate message color + $msgColor = switch ($Level) { + DEBUG { "`e[36m" } + INFO { "`e[34m" } + WARNING { "`e[33m" } + ERROR { "`e[31m" } + CRITICAL { "`e[91m" } + } + # calculate message information + $position = "$(Split-Path $MyInvocation.ScriptName -Leaf):$($MyInvocation.ScriptLineNumber)" + $ts = (Get-Date).ToString('s').Replace('T', ' ') + + # print log message + $msg = "`e[32m{0}`e[0m|`e[30m{1}`e[0m|{2} - $msgColor{3}`e[0m" -f $ts, $Level.ToUpper(), $position, $Message + Write-Host $msg +} + + +<# +.SYNOPSIS +Get PSReadLine history. + +.PARAMETER Pattern +Regex pattern to filter history entries. +.PARAMETER Last +Number of last matching entries to return. Default is 30. +.PARAMETER First +Number of first matching entries to return. +.PARAMETER Unique +Return sorted, unique matching entries. + +.EXAMPLE +Get-PSReadLineHistory -Pattern 'Connect-Az.*' -Last 10 +# get last 10 PSReadLine history entries matching 'Connect-Az.*' pattern + +.EXAMPLE +Get-PSReadLineHistory 'Connect-Az.*' 10 +# omit parameters as Pattern is mandatory and Last is default + +.EXAMPLE +Get-PSReadLineHistory -Pattern 'git' -First 5 +# get first 5 PSReadLine history entries matching 'git' pattern +#> +function Get-PSReadLineHistory { + [CmdletBinding(DefaultParameterSetName = 'last')] + param ( + [Parameter(ValueFromPipeline, Position = 0)] + [string]$Pattern, + + [Parameter(Position = 1, ParameterSetName = 'last')] + [int]$Last = 30, + + [Parameter(ParameterSetName = 'first')] + [int]$First, + + [switch]$Unique + ) + + begin { + # determine limit for the matching results + $limit = $First ? $First : $Last + + # get PSReadLine history file path + $historyPath = (Get-PSReadLineOption).HistorySavePath + + # read and optionally reverse history using LINQ for efficiency + if ($First) { + $history = [System.IO.File]::ReadLines($historyPath) + } else { + $history = [System.Linq.Enumerable]::Reverse( + [System.IO.File]::ReadLines($historyPath) + ) + } + } + + process { + # filter matches + $results = $history -match "(? +function Format-Duration { + [CmdletBinding()] + param ( + [timespan]$TimeSpan + ) + + switch ($TimeSpan) { + { $_.TotalMilliseconds -gt 0 -and $_.TotalMilliseconds -lt 10 } { '{0:N2}ms' -f $_.TotalMilliseconds; continue } + { $_.TotalMilliseconds -ge 10 -and $_.TotalMilliseconds -lt 100 } { '{0:N1}ms' -f $_.TotalMilliseconds; continue } + { $_.TotalMilliseconds -ge 100 -and $_.TotalMilliseconds -lt 1000 } { '{0:N0}ms' -f $_.TotalMilliseconds; continue } + { $_.TotalSeconds -ge 1 -and $_.TotalSeconds -lt 10 } { '{0:N3}s' -f $_.TotalSeconds; continue } + { $_.TotalSeconds -ge 10 -and $_.TotalSeconds -lt 100 } { '{0:N2}s' -f $_.TotalSeconds; continue } + { $_.TotalSeconds -ge 100 -and $_.TotalHours -le 1 } { $_.ToString('mm\:ss\.ff'); continue } + { $_.TotalHours -ge 1 -and $_.TotalDays -le 1 } { $_.ToString('hh\:mm\:ss'); continue } + { $_.TotalDays -ge 1 } { "$($_.Days * 24 + $_.Hours):$($_.ToString('mm\:ss'))"; continue } + default { '0ms' } + } +} + + +<# +.SYNOPSIS +Retry executing command if fails on HttpRequestException. +.PARAMETER Command +Script block of commands to execute. +.PARAMETER MaxRetries +Maximum number of retries to rerun the script block. +#> +function Invoke-CommandRetry { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0, HelpMessage = 'The command to be invoked.')] + [scriptblock]$Command, + + [Parameter(HelpMessage = 'The number of retries the command should be invoked.')] + [int]$MaxRetries = 10 + ) + + Set-Variable -Name retryCount -Value 0 + do { + try { + Invoke-Command -ScriptBlock $Command + $exit = $true + } catch [System.IO.IOException], [System.Net.Http.HttpRequestException] { + if ($_.Exception.TargetSite.Name -eq 'MoveNext') { + if ($_.ErrorDetails) { + Write-Verbose $_.ErrorDetails.Message + } else { + Write-Verbose $_.Exception.Message + } + Write-Host "`nRetrying..." + } else { + Write-Verbose $_.Exception.GetType().FullName + Write-Error $_ + } + } catch [System.AggregateException] { + if ($_.Exception.InnerException.GetType().Name -eq 'HttpRequestException') { + Write-Verbose $_.Exception.InnerException.Message + Write-Host "`nRetrying..." + } else { + Write-Verbose $_.Exception.InnerException.GetType().FullName + Write-Error $_ + } + } catch { + Write-Verbose $_.Exception.GetType().FullName + Write-Error $_ + } + $retryCount++ + if ($retryCount -eq $MaxRetries) { + $exit = $true + } + } until ($exit) +} + + +<# +.SYNOPSIS +Save examples from PowerShell, Python, shell scripts to the console folder. +Function ignores script_examples_save.ps1 script that can be used to invoke it +and lines containing ExampleScriptSave keyword. + +.PARAMETER Path +Path to the file/folder to save the examples from. +.PARAMETER ExtensionFilter +Scripts extension filter. +.PARAMETER Exclude +List of file relative or full paths to be excluded from processing. +.PARAMETER FolderFromBase +Save example script in the folder of the base script. +.PARAMETER Force +Force ovewriting target file if exists. +.PARAMETER WriteOutput +Write output to the success [1] stream instead of the information [6] one. + +.EXAMPLE +# :save example scripts from scripts in the current folder +Invoke-ExampleScriptSave +Invoke-ExampleScriptSave -Force +Invoke-ExampleScriptSave -FolderFromBase +# :save example script from scripts in the specified path +$Path = 'path_to_script_or_folder' +Invoke-ExampleScriptSave $Path +Invoke-ExampleScriptSave $Path -Force +Invoke-ExampleScriptSave $Path -WriteOutput +Invoke-ExampleScriptSave $Path -FolderFromBase +#> +function Invoke-ExampleScriptSave { + [CmdletBinding()] + param ( + [Parameter(Position = 0)] + [ValidateScript({ Test-Path $_ }, ErrorMessage = "'{0}' is not a valid path.")] + [string]$Path = '.', + + [ValidateScript({ $_.ForEach({ $_ -in @('.ps1', '.py', '.sh') }) -notcontains $false }, + ErrorMessage = 'Wrong extensions provided. Valid values: .ps1, .py, .sh')] + [string[]]$ExtensionFilter = @('.ps1', '.py', '.sh'), + + [ValidateNotNullOrEmpty()] + [string[]]$Exclude = '.', + + [switch]$FolderFromBase, + + [switch]$Force, + + [switch]$WriteOutput + ) + + begin { + # get list of scripts in the specified directory + $scripts = Get-ChildItem $Path -File -Force | Where-Object { + $_.Extension -in $ExtensionFilter -and $_.FullName -notin (Resolve-Path $Exclude -ErrorAction SilentlyContinue).Path + } + # instantiate generic list to store example script(s) name(s) + $lst = [Collections.Generic.List[hashtable]]::new() + if ($scripts) { + # get git root + $gitRoot = git rev-parse --show-toplevel + # add the console folder to .gitignored if necessary + if (-not (Select-String '\bconsole\b' "$gitRoot/.gitignore" -Quiet)) { + [IO.File]::AppendAllLines("$gitRoot/.gitignore", [string[]]'/console/') + } + # determine and create example folder to put example scripts in + $exampleDir = if ($PSBoundParameters.FolderFromBase) { + [IO.Path]::Combine($gitRoot, 'console', $scripts[0].Directory.Name) + } else { + [IO.Path]::Combine($gitRoot, 'console') + } + # create example dir if not exists + if (-not (Test-Path $exampleDir -PathType Container)) { + New-Item $exampleDir -ItemType Directory | Out-Null + } + # script's initial comment regex pattern + $pattern = @{ + '.ps1' = '(?s)(?<=\n\.EXAMPLE\n).*?(?=(\n#>|\n\.[A-Z]))' + '.sh' = "(?s)(?<=\n: '\n).*?(?=\n'\n)" + '.py' = '(?<=^(#.*?\n)?"""\n)((?!""")[\s\S])*?(?=\n("""|# \:save))' + } + } else { + return + } + } + + process { + foreach ($script in $scripts) { + $content = [IO.File]::ReadAllText($script) + # get script examples + $example = [regex]::Matches($content, $pattern[$script.Extension]).Value + if ($example) { + # get PowerShell parameters descriptions + if ($script.Extension -eq '.ps1') { + $synopsis = [regex]::Matches($content, '(?s)(?<=\n)\.SYNOPSIS\n(.*?)(?=(\n\.[A-Z]+( \w+)?\n|#>))').Value + $param = [regex]::Matches($content, '(?s)(?<=\n)\.PARAMETER \w+\n(.*?)(?=(\n\.[A-Z]+\n|#>))').Value + } else { + # quote sentences and links + $example = $example ` + -replace '(^|\n)([A-Z].*\.)(\n|$)', '$1# $2$3' ` + -replace '(^|\n)(http.*)(\n|$)', '$1# $2$3' + # clean param variable + $synopsis = $null + $param = $null + } + # calculate example file path + $fileName = $script.Extension -eq '.py' ? "$($script.BaseName)_py.ps1" : $script.Name + # create hashtable that will store the example script path and information if it was saved + $lstItem = @{ path = [IO.Path]::Combine($exampleDir, $fileName) } + # build content string + $builder = [System.Text.StringBuilder]::new() + if ($synopsis -or $param) { + $builder.AppendLine('<#') | Out-Null + if ($synopsis) { $builder.AppendLine($synopsis.Trim()) | Out-Null } + if ($param) { $builder.AppendLine($synopsis ? "`n$($param.Trim())" : $param.Trim()) | Out-Null } + $builder.AppendLine('#>') | Out-Null + if ($example) { $builder.AppendLine('') | Out-Null } + } + if ($example) { + $example.Trim().Split("`n") | Select-String -NotMatch 'ExampleScriptSave' | ForEach-Object { + $builder.AppendLine($_) | Out-Null + } + } + if (-not $PSBoundParameters.Force -and (Test-Path $lstItem.path)) { + $lstItem.saved = $false + } else { + # save the example script + [IO.File]::WriteAllText($lstItem.path, $builder.ToString()) + $lstItem.saved = $true + } + # add item to the list + $lst.Add($lstItem) + } + } + } + + end { + # print list of saved file paths + foreach ($item in $lst) { + if ($WriteOutput) { + return $item.path + } else { + $relPath = ($item.path).Replace($HOME, '~') + if ($item.saved) { + Write-Host "`e[4;94m$relPath`e[0m" + } else { + Write-Host "`e[4;96m$relPath`e[0m" + } + } + } + } +} + +Set-Alias -Name egsave -Value Invoke-ExampleScriptSave + + +<# +.SYNOPSIS +Generate a random string. + +.PARAMETER Length +Length of the password to be generated. +.PARAMETER Complexity +Set of characters to use for generating password: +- U: upper case characters +- L: lower case characters +- N: numbers +- S: symbols +.PARAMETER Exclude +List of characters to be excluded. +#> +function New-Password { + [CmdletBinding()] + [OutputType([string])] + param ( + [Int]$Length = 8, + + [Char[]]$Complexity = 'ULNS', + + [Char[]]$Exclude + ) + $AllTokens = @(); + $Chars = @(); + $TokenSets = @{ + UpperCase = [Char[]]'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + LowerCase = [Char[]]'abcdefghijklmnopqrstuvwxyz' + Numbers = [Char[]]'0123456789' + Symbols = [Char[]]'!#%&*+-<>@^_|~' + } + $TokenSets.Keys | Where-Object { $Complexity -contains $_[0] } | ForEach-Object { + $TokenSet = $TokenSets.$_ | Where-Object { $Exclude -cnotcontains $_ } | ForEach-Object { $_ } + if ($_[0] -cle 'Z') { + $Chars += $TokenSet | Get-Random + } + $AllTokens += $TokenSet + } + while ($Chars.Count -lt $Length) { + $Chars += $AllTokens | Get-Random + } -join ($Chars | Sort-Object { Get-Random }) +} + + +<# +.SYNOPSIS +Show specified properties of the object. + +.PARAMETER Object +Object to be showed. +.PARAMETER TypeName +Array of properties system types to be shown (System.String, System.Datetime, ...). +.PARAMETER MemberType +Array of properties member types to be shown (Property, AliasProperty, ...). +.PARAMETER Strip +Switch whether to strip properties without value. +#> +function Show-Object { + [CmdletBinding()] + [OutputType([System.Collections.Generic.List[object]])] + param ( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + [object]$Object, + + [string[]]$TypeName, + + [string[]]$MemberType, + + [switch]$Strip + ) + + process { + [string[]]$prop = $Object.PSObject.Properties.Where({ + ($TypeName ? $_.TypeNameOfValue -in $TypeName : $true) -and + ($MemberType ? $_.MemberType -in $MemberType : $true) -and + ($Strip ? -not [string]::IsNullOrEmpty($_.Value) : $true) + } + ).Name + $Object | Select-Object $prop + } +} + + +<# +.SYNOPSIS +Check if PowerShell runs elevated. +#> +function Test-IsAdmin { + [CmdletBinding()] + [OutputType([bool])] + param () + + process { + $isAdmin = if ($IsWindows) { + ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator') + } else { + ((id -u) -eq 0) ? $true : $false + } + } + + end { + return $isAdmin + } +} diff --git a/modules/do-common/Functions/dotnet.ps1 b/modules/do-common/Functions/dotnet.ps1 new file mode 100644 index 00000000..e93f0d17 --- /dev/null +++ b/modules/do-common/Functions/dotnet.ps1 @@ -0,0 +1,38 @@ +<# +.SYNOPSIS +Get dotnet current directory. +#> +function Get-DotnetCurrentDirectory { + Resolve-Path $([IO.Path]::GetFullPath('.')) +} + +Set-Alias -Name swd -Value Get-DotnetCurrentDirectory + + +<# +.SYNOPSIS +Set dotnet current directory to specified location. +#> +function Set-DotnetCurrentDirectory { + [CmdletBinding()] + param ( + [Parameter(Position = 0)] + [ValidateScript({ Test-Path $_ -PathType 'Container' }, ErrorMessage = "'{0}' is not a valid folder path.")] + [string]$Path = $PWD + ) + + [IO.Directory]::SetCurrentDirectory($Path) +} + +Set-Alias -Name sswd -Value Set-DotnetCurrentDirectory + + +<# +.SYNOPSIS +Set location to dotnet current directory. +#> +function Set-DotnetLocation { + Set-Location $(Get-DotnetCurrentDirectory) +} + +Set-Alias -Name cds -Value Set-DotnetLocation diff --git a/modules/SetupUtils/Functions/logs.ps1 b/modules/do-common/Functions/logs.ps1 similarity index 60% rename from modules/SetupUtils/Functions/logs.ps1 rename to modules/do-common/Functions/logs.ps1 index b45ed3a7..8a846023 100644 --- a/modules/SetupUtils/Functions/logs.ps1 +++ b/modules/do-common/Functions/logs.ps1 @@ -1,3 +1,39 @@ +<# +.SYNOPSIS +Function to set the log file and return the path. + +.PARAMETER Path +The path to the log file. +.PARAMETER Append +Switch, whether to append to the existing log file. +#> +function Set-LogFile { + [CmdletBinding()] + [OutputType([string])] + param ( + [ValidateScript({ $_ -match '\.log$' }, ErrorMessage = 'Specified file should have .log extension.')] + [string]$Path = "logs/$(Get-Date -Format 'yyyyMMddTHHmmss').log", + + [switch]$Append + ) + + # *ensure that the log file exists + if (-not (Test-Path $Path -PathType Leaf)) { + $parent = Split-Path $Path -Parent + if ($parent -and -not (Test-Path $parent -PathType Container)) { + New-Item -Path $parent -ItemType Directory -Force -ErrorAction Stop | Out-Null + } + New-Item -Path $Path -ItemType File -Force -ErrorAction Stop | Out-Null + } elseif (-not $Append) { + # clean the existing logfile if it exists + Set-Content -Path $Path -Value $null + } + + # return PowerShell provider path + return Convert-Path $Path +} + + <# .SYNOPSIS Function to get the log context from the caller. @@ -113,7 +149,7 @@ function Get-LogLine { # build the log line to show [string]::Join('|', - "`e[36m$($LogContext.TimeStamp.ToString('yyyy-MM-dd HH:mm:ss'))`e[0m", + "`e[32m$($LogContext.TimeStamp.ToString('yyyy-MM-dd HH:mm:ss'))`e[0m", "${lvlColor}${Level}`e[0m", "`e[90m$($LogContext.Invocation)`e[0m", "`e[90m$($LogContext.Function)`e[0m: $Message" @@ -218,3 +254,108 @@ function Show-LogContext { } } } + + +<# +.SYNOPSIS +Function to log messages to a log file. + +.PARAMETER Path +The path to the log file. +.PARAMETER Message +The message to log. +.PARAMETER Level +The level of the log message. +.PARAMETER ErrorStackTrace +The error stack trace. +.PARAMETER ShowLog +Switch, whether to show the log message in the console. +#> +function Write-LogContext { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0, ParameterSetName = 'Message')] + [string]$Message, + + [Parameter(Mandatory, Position = 0, ParameterSetName = 'ErrorRecord')] + [System.Management.Automation.ErrorRecord]$ErrorRecord, + + [ValidateSet('INFO', 'ERROR', 'WARNING', 'VERBOSE', 'DEBUG')] + [string]$Level = 'INFO', + + [string]$ErrorStackTrace, + + [ValidateScript({ $_ -match '\.log$' }, ErrorMessage = 'Specified file should have .log extension.')] + [string]$Path, + + [switch]$ShowLog, + + [switch]$FailOnError + ) + + begin { + # check if error record was passed + if ($PSCmdlet.ParameterSetName -eq 'ErrorRecord') { + $Level = 'ERROR' + $Message = "$ErrorRecord" + } + + + # *fail on error if specified + if ($Level -eq 'ERROR' -and $PSBoundParameters.FailOnError) { + throw $Message + } else { + # *capitalize the Type + $Level = $Level.ToUpper() + # *remove new lines from the message + $Message = $Message -replace "`r?`n", ' ' + + # *create the log file if it doesn't exist + if (-not (Test-Path $Path -PathType Leaf)) { + Set-LogFile -Path $Path | Out-Null + } + + # *get the function caller context + $callerParam = @{ + Caller = (Get-PSCallStack)[1] + } + if ($Level -eq 'ERROR') { + if ($PSCmdlet.ParameterSetName -eq 'ErrorRecord') { + $callerParam.ErrorStackTrace = $ErrorRecord.ScriptStackTrace + } elseif ($PSBoundParameters.ErrorStackTrace -match '\sline\s(\d+)') { + $callerParam.ErrorStackTrace = $PSBoundParameters.ErrorStackTrace + } + } + $ctx = Get-LogContext @callerParam + + # *determine Debug/Verbose preference + if ($ShowLog) { + $isVerbose = $ctx.isVerbose -or $VerbosePreference -ge 'Continue' + $isDebug = $ctx.isDebug -or $DebugPreference -ge 'Continue' + # calculate if the message should be displayed + if (($Level -eq 'VERBOSE' -and -not $isVerbose) -or ($Level -eq 'DEBUG' -and -not $isDebug)) { + $ShowLog = $false + } + } + } + } + + process { + # get the log line to write + [string[]]$writeLine = Get-LogLine -LogContext $ctx -Message $Message -Level $Level -LineType 'Write' + + if ($ShowLog) { + # get the log line to show + $showLine = Get-LogLine -LogContext $ctx -Message $Message -Level $Level -LineType 'Show' + } + } + + end { + # write the log line to the log file + [System.IO.File]::AppendAllLines($Path, $writeLine) + # show the log line in the console + if ($ShowLog) { + Write-Host $showLine + } + } +} diff --git a/modules/do-common/Functions/net.ps1 b/modules/do-common/Functions/net.ps1 new file mode 100644 index 00000000..a7234dcc --- /dev/null +++ b/modules/do-common/Functions/net.ps1 @@ -0,0 +1,116 @@ +<# +.SYNOPSIS +Function resolving CIDR notation range. + +.PARAMETER InputObject +Input string to be converted from CIDR range. +#> +function ConvertFrom-CIDR { + [CmdletBinding()] + [OutputType([Collections.Generic.List[PSCustomObject]])] + param ( + [Parameter(Mandatory, ValueFromPipeline, Position = 0)] + [string[]]${InputObject} + ) + + begin { + $ranges = [Collections.Generic.List[PSCustomObject]]::new() + } + + process { + foreach ($cidr in $InputObject) { + $addr, $maskLength = $cidr -split '/' + [int]$maskLen = 0 + if (-not [int32]::TryParse($maskLength, [ref] $maskLen)) { + throw "Cannot parse CIDR mask length string: '$maskLength'" + } + if (0 -gt $maskLen -or $maskLen -gt 32) { + throw 'CIDR mask length must be between 0 and 32' + } + $ipAddr = [Net.IPAddress]::Parse($addr) + if ($ipAddr -eq $null) { + throw "Cannot parse IP address: $addr" + } + if ($ipAddr.AddressFamily -ne [Net.Sockets.AddressFamily]::InterNetwork) { + throw 'Can only process CIDR for IPv4' + } + + $shiftCnt = 32 - $maskLen + $mask = -bnot ((1 -shl $shiftCnt) - 1) + $ipNum = [Net.IPAddress]::NetworkToHostOrder([BitConverter]::ToInt32($ipAddr.GetAddressBytes(), 0)) + $ipStart = ($ipNum -band $mask) + $ipEnd = ($ipNum -bor (-bnot $mask)) + + # return as tuple of strings: + $ranges.Add([PSCustomObject]@{ + CidrRange = $cidr + StartIP = [BitConverter]::GetBytes([Net.IPAddress]::HostToNetworkOrder($ipStart)) -join '.' + EndIP = [BitConverter]::GetBytes([Net.IPAddress]::HostToNetworkOrder($ipEnd)) -join '.' + TotalHosts = $ipEnd - $ipStart + 1 + } + ) + } + } + + end { + return $ranges + } +} + + +<# +.SYNOPSIS +Download file from the specified Uri + +.PARAMETER Uri +Uri to download the file from. +.PARAMETER Destination +Destination folder do save the file to +#> +function Invoke-DownloadFile { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [string]$Uri, + + [ValidateScript( { Test-Path $_ -PathType 'Container' }, ErrorMessage = "'{0}' is not a valid folder path.")] + [string]$Destination = '.' + ) + + $client = [Net.Http.HttpClient]::new() + try { + $client.DefaultRequestHeaders.UserAgent.ParseAdd('PowerShell') + + $response = $client.GetAsync($Uri).Result + try { + if ($response.IsSuccessStatusCode) { + $contentDisposition = $response.Content.Headers.ContentDisposition + $fileName = if ($null -ne $contentDisposition) { + $contentDisposition.FileName + } else { + [IO.Path]::GetFileName($Uri) + } + } else { + throw "Failed to download file. Status code: $($response.StatusCode)" + } + + $folderPath = [IO.Path]::GetFullPath($Destination) + $destinationPath = [IO.Path]::Combine($folderPath, $fileName) + + $stream = [IO.FileStream]::new($destinationPath, [IO.FileMode]::Create) + try { + $response.Content.CopyToAsync($stream).Wait() + } finally { + $stream.Dispose() + } + } finally { + $response.Dispose() + } + } finally { + $client.Dispose() + } + + Write-Host "File downloaded to: $destinationPath" +} + +Set-Alias -Name idf -Value Invoke-DownloadFile diff --git a/modules/do-common/Functions/python.ps1 b/modules/do-common/Functions/python.ps1 new file mode 100644 index 00000000..acdc07d1 --- /dev/null +++ b/modules/do-common/Functions/python.ps1 @@ -0,0 +1,934 @@ +<# +.SYNOPSIS +Add certificates from SSL chain to the certifi file. +#> +function Invoke-CertifiFixFromChain { + [CmdletBinding()] + param () + begin { + $ErrorActionPreference = 'Stop' + + $cacertPaths = [System.Collections.Generic.HashSet[string]]::new() + # get certifi/cacert.pem file path + foreach ($package in @('certifi', 'pip')) { + if (Get-Command 'uv' -CommandType Application -ErrorAction SilentlyContinue) { + [string[]]$showFiles = uv pip show -f $package 2>$null + } + if (-not $showFiles) { + [string[]]$showFiles = pip show -f $package 2>$null + } + if ($location = ($showFiles | Select-String '(?<=^Location: ).+$').Matches.Value) { + if ($cacert = ($showFiles | Select-String '\S*\bcacert\.pem$').Matches.Value) { + $cacert.ForEach({ $cacertPaths.Add(([IO.Path]::Combine($location, $_))) | Out-Null }) + } + } + } + } + + process { + if ($cacertPaths) { + # get intermediate and root certificates + $chain = Invoke-CommandRetry { + Get-Certificate 'www.python.org' -BuildChain | Select-Object -Skip 1 + } + # check if root certificate from chain is installed in the system + $rootCrts = Get-RootCertificates + if ($chain[-1].Thumbprint -in $rootCrts.Thumbprint) { + foreach ($path in $cacertPaths) { + Write-Verbose $path.Replace($HOME, '~') + $certifiCerts = ConvertFrom-PEM $path + # check if certs already added to cacert.pem + if ($certsToAdd = $chain.ForEach({ $_.Where({ $_.Thumbprint -notin $certifiCerts.Thumbprint }) })) { + # add certificates from chain to the certifi/cacert.pem + foreach ($cert in $certsToAdd) { + $msg = [string]::Join("`n", + "`e[1;92mThumbprint :`e[0m $($cert.Thumbprint)", + "`e[1;92mSubject :`e[0m $($cert.Subject)", + "`e[1;92mIssuer :`e[0m $($cert.Issuer)`n" + ) + Write-Host $msg + $pem = "`n$(ConvertTo-PEM $cert -AddHeader)" + if ($IsLinux -and (Get-ChildItem $path).User -eq 'root') { + sudo pwsh -nop -noni -c "[IO.File]::AppendAllText('$path', '$pem')" + } else { + [IO.File]::AppendAllText($path, $pem) + } + } + } else { + Write-Verbose 'All certificates from TLS chain already added to the file.' + } + } + } else { + Write-Error "Root certificate from TLS chain is not trusted ($($chain[-1].Subject))." + } + } else { + Write-Verbose 'Certifi not found in the environment.' + return + } + } +} + +Set-Alias -Name fxcertpy -Value Invoke-CertifiFixFromChain +Set-Alias -Name fixcertpy -Value Invoke-CertifiFixFromChain + + +<# +.SYNOPSIS +Manage conda environments. +.PARAMETER Option +Select script action. +.PARAMETER YamlFile +Specify conda file to use. +#> +function Invoke-CondaSetup { + [CmdletBinding()] + param ( + [Parameter(Position = 0)] + [ArgumentCompletions('activate', 'clean', 'create', 'deactivate', 'envs', 'fix', 'info', 'list', 'remove', 'setup', 'update')] + [string]$Option, + + [Alias('f')] + [ValidateNotNullorEmpty()] + [string]$YamlFile = './conda.yaml', + + [switch]$CertificateFix + ) + + dynamicparam { + if (@('activate', 'create', 'remove') -match "^$Option" -and -not $PSBoundParameters.YamlFile) { + $paramDict = [System.Management.Automation.RuntimeDefinedParameterDictionary]::new() + + $attributeCollection = [System.Collections.ObjectModel.Collection[System.Attribute]]::new() + $attributeCollection.Add([System.Management.Automation.ParameterAttribute]@{ Position = 1 }) + $argCompleter = [ScriptBlock]::Create({ (Get-CondaEnvironment).Name }) + $attributeCollection.Add([System.Management.Automation.ArgumentCompleterAttribute]::new($argCompleter)) + $dynParam = [System.Management.Automation.RuntimeDefinedParameter]::new( + 'Environment', [string], $attributeCollection + ) + $paramDict.Add('Environment', $dynParam) + + if ('create' -match "^$Option" -and $Option.Length -ge 2) { + # dependencies dynamic parameter + $attributeCollection = [System.Collections.ObjectModel.Collection[System.Attribute]]::new() + $attributeCollection.Add([System.Management.Automation.ParameterAttribute]@{ Position = 2 }) + $dynParam = [System.Management.Automation.RuntimeDefinedParameter]::new( + 'Dependencies', [string[]], $attributeCollection + ) + $paramDict.Add('Dependencies', $dynParam) + } + + return $paramDict + } + } + + begin { + try { + Get-Item Env:/CONDA_EXE -ErrorAction Stop | Out-Null + } catch { + if (Test-Path $HOME/miniconda3/bin/conda) { + Write-Warning "Conda not initialized.`n" + [Console]::WriteLine( + [string]::Join("`n", + 'Run the below command to add conda initialization to Powershell for the current user:', + "`e[1m& `"`$HOME/miniconda3/$($IsWindows ? 'Scripts/conda.exe' : 'bin/conda')`" init powershell`e[0m" + ) + ) + return + } else { + Write-Warning "Conda not installed.`n" + [Console]::WriteLine('Run the below command(s) to install miniconda:') + if ($IsWindows) { + [Console]::WriteLine("`e[1mwinget install --id Anaconda.Miniconda3`e[0m") + } elseif ($IsLinux) { + [Console]::WriteLine( + [string]::Join("`n", + "`e[1mcurl -fsSLO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh", + "sh ./Miniconda3-latest-Linux-x86_64.sh -b -p `$HOME/miniconda3 && rm -f ./Miniconda3-latest-Linux-x86_64.sh`e[0m" + ) + ) + } elseif ($IsMacOS) { + [Console]::WriteLine( + [string]::Join("`n", + "`e[1mcurl -fsSLO https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh", + "sh ./Miniconda3-latest-MacOSX-x86_64.sh -b -p `$HOME/miniconda3 && rm -f ./Miniconda3-latest-MacOSX-x86_64.sh`e[0m" + ) + ) + } + return + } + } + if (-not $Option) { + [Console]::WriteLine( + [string]::Join("`n", + "Invoke-CondaSetup function manages conda environments.`n", + "usage: Invoke-CondaSetup [-Option] [-YamlFile ] [-CertificateFix] [[-Environment] ] [[-Dependencies] ]`n", + 'The following Options are available:', + " `e[1;97mactivate`e[0m Activate environment", + " `e[1;97mclean`e[0m Clean conda environment", + " `e[1;97mcreate`e[0m Create conda environment", + " `e[1;97mdeactivate`e[0m Deactivate environment", + " `e[1;97menvs`e[0m List environments", + " `e[1;97mfix`e[0m Fix self-signed certificates", + " `e[1;97minfo`e[0m Display current conda install info", + " `e[1;97mlist`e[0m List packages", + " `e[1;97mremove`e[0m Remove environment", + " `e[1;97msetup`e[0m Create/update environment", + " `e[1;97mupdate`e[0m Update conda`n" + ) + ) + return + } + # evaluate Option parameter abbreviations + $optSet = @( + 'activate' + 'clean' + 'create' + 'deactivate' + 'envs' + 'fix' + 'info' + 'list' + 'remove' + 'setup' + 'update' + ) + $opt = $optSet -match "^$Option" + if ($opt.Count -eq 0) { + Write-Warning "Option parameter name '$Option' is invalid. Valid Option values are:`n`t $($optSet -join ', ')" + break + } elseif ($opt.Count -gt 1) { + Write-Warning "Option parameter name '$Option' is ambiguous. Possible matches include: $($opt -join ', ')." + break + } + + # check for conda file + if ($opt -in @('activate', 'envs', 'remove', 'setup')) { + $envs = Get-CondaEnvironment + if ($opt -in @('activate', 'remove', 'setup')) { + if ($PSBoundParameters.Environment) { + $envName = $PSBoundParameters.Environment + $envExists = $envName -in $envs.Name + } elseif (Test-Path $YamlFile -PathType Leaf) { + # get environment name + $envName = (Select-String -Pattern '^name: +(\S+)' -Path $YamlFile).Matches.Groups.Where({ $_.Name -eq '1' }).Value + $envExists = $envName -in $envs.Name + } else { + Write-Warning "File `e[4m$YamlFile`e[24m not found" + break + } + if ($env:CONDA_DEFAULT_ENV) { + # exit environment before proceeding + Exit-CondaEnvironment + } + } + } + } + + # *Execute option + process { + if ($CertificateFix -and $opt -in @('create', 'setup')) { + $opt = $opt + 'fix' + } + switch ($opt) { + activate { + # *Activate environment + if ($envExists) { + Enter-CondaEnvironment $envName + } else { + Write-Host "`e[1;4m$envName`e[22;24m environment doesn't exist!" + } + break + } + + clean { + # *Clean conda + Invoke-Conda clean -y --all + break + } + + create { + # *Create conda environment + # build conda arguments + [System.Collections.Generic.List[string]]$condaArgs = @('create') + $condaArgs.Add('--name') + $condaArgs.Add($PSBoundParameters.Environment) + $condaArgs.Add('--yes') + $PSBoundParameters.Dependencies.ForEach({ $condaArgs.Add($_) }) + # create environment + if ($PSBoundParameters.Verbose) { Write-Verbose "conda $condaArgs" } + & Invoke-Conda @condaArgs + # activate environment + Enter-CondaEnvironment $PSBoundParameters.Environment + } + + deactivate { + # *Clean conda + Exit-CondaEnvironment + break + } + + envs { + # *List environments + return $envs + } + + info { + # *Display current conda install information + conda info | ForEach-Object { + if ($_ -match '\w : ') { + $header, $val = $_.Split(' : ') + Write-Host "`e[1;92m${header} : `e[0m${val}" + } else { + Write-Host $_ + } + } + break + } + + list { + # *List packages + Invoke-Conda list + break + } + + remove { + # *Remove environment + if ($envName -eq 'base') { + Write-Host "Cannot remove `e[1;4mbase`e[22;24m environment!" + } elseif ($envExists) { + Write-Host "Removing `e[1;4m$envName`e[22;24m environment." + Invoke-Conda env remove --name $envName --yes + } else { + Write-Host "`e[1;4m$envName`e[22;24m environment doesn't exist!" + } + break + } + + setup { + # build conda arguments + [System.Collections.Generic.List[string]]$condaArgs = @('env') + # build conda arguments + if ($envExists) { + # *Create environment + Write-Host "`nEnvironment `e[1;4m$envName`e[22;24m already exist. Updating..." + $condaArgs.Add('update') + $condaArgs.Add('--prune') + } else { + # *Update environment + Write-Host "Creating `e[1;4m$envName`e[22;24m environment." + $condaArgs.Add('create') + } + $condaArgs.Add('--file') + $condaArgs.Add($YamlFile) + if ($PSBoundParameters.Verbose) { Write-Verbose "conda $condaArgs" } + # run conda command + & Invoke-Conda @condaArgs + # activate environment + Enter-CondaEnvironment $envName + } + + fix { + # *Fix certificates + Invoke-CertifiFixFromChain + break + } + + update { + # *Update conda + Invoke-Conda update --name base --channel defaults conda --yes --update-all + break + } + } + } +} + +Set-Alias -Name ics -Value Invoke-CondaSetup + + +<# +.SYNOPSIS +Activate python virtual environment. + +.PARAMETER GetPath +Return activate script path. +#> +function Invoke-VenvActivate { + [CmdletBinding()] + param ( + [Parameter(Position = 0)] + [ValidateNotNullorEmpty()] + [ValidateScript({ Test-Path $_ -PathType Container }, ErrorMessage = "'{0}' is not a valid directory.")] + [string]$Path = '.', + + [switch]$GetPath + ) + + Push-Location $Path -StackName 'Venv' + # calculate venv directory with activate scripts + $activateDir = [IO.Path]::Combine('.venv', ($IsWindows ? 'Scripts' : 'bin')) + # check if virtual environment exists + if (Test-Path $activateDir -PathType Container) { + # get activate script path + $activateScript = (Get-ChildItem -Path $activateDir -Filter 'activate.ps1').FullName + if ($activateScript) { + if ($GetPath) { + $activateScript + } else { + . $activateScript + return + } + } else { + Write-Warning "Activate script not found in $activateDir." + } + } elseif (-not $GetPath) { + Write-Host 'venv: environment not found' + } + Pop-Location -StackName 'Venv' +} + +Set-Alias -Name iva -Value Invoke-VenvActivate + + +<# +.SYNOPSIS +Deactivate python virtual environment. +#> +function Invoke-VenvDeactivate { + [CmdletBinding()] + param ( + [switch]$Quiet + ) + + try { + Get-Item Function:deactivate -ErrorAction Stop | Out-Null + deactivate + } catch { + if (-not $Quiet) { + Write-Host 'venv: environment not activated' + } + } +} + +Set-Alias -Name ivd -Value Invoke-VenvDeactivate + +<# +.SYNOPSIS +Setup Python virtual environment in the project and much more... +.PARAMETER Option +Select script action. +.PARAMETER AppPath +Specify application path to be added by pypath. +#> +function Invoke-PySetup { + [CmdletBinding()] + param ( + [Parameter(Position = 0)] + [ArgumentCompletions('clean', 'getenv', 'install', 'list', 'purge', 'remove', 'setenv', 'sshkey', 'ssltrust', 'update', 'venv')] + [string]$Option, + + [Alias('p')] + [ValidateScript({ Test-Path $_ -PathType 'Container' }, ErrorMessage = "'{0}' is not a valid folder path.")] + [string]$AppPath + ) + + begin { + if (-not $Option) { + [Console]::WriteLine( + [string]::Join("`n", + "Invoke-PySetup function manages Python virtual environments.`n", + "usage: Invoke-PySetup [-Option] [-AppPath ]`n", + 'The following options are available:', + " `e[1;97mclean`e[0m Delete all cache folders", + " `e[1;97mgetenv`e[0m Get environment variables", + " `e[1;97minstall`e[0m Install requirements", + " `e[1;97mlist`e[0m List installed modules", + " `e[1;97mpurge`e[0m Purge pip cache", + " `e[1;97mremove`e[0m Remove python virtual environment", + " `e[1;97msetenv`e[0m Set environment variables", + " `e[1;97msshkey`e[0m Generate key pairs for SSH", + " `e[1;97mssltrust`e[0m Trust SSL connection to pypi.org", + " `e[1;97mupdate`e[0m Update installed python modules", + " `e[1;97mvenv`e[0m Setup python virtual environment`n" + ) + ) + return + } + # evaluate Option parameter abbreviations + $optSet = @( + 'clean' + 'getenv' + 'install' + 'list' + 'purge' + 'remove' + 'setenv' + 'sshkey' + 'ssltrust' + 'update' + 'venv' + ) + $opt = $optSet -match "^$Option" + if ($opt.Count -eq 0) { + Write-Warning "Option parameter name '$Option' is invalid. Valid Option values are:`n`t $($optSet -join ', ')" + break + } elseif ($opt.Count -gt 1) { + Write-Warning "Option parameter name '$Option' is ambiguous. Possible matches include: $($opt -join ', ')." + break + } + + # constants + $VENV_DIR = '.venv' + $GITIGNORE = 'https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore' + + # calculate script variables + $req_files = [Collections.Generic.List[string]]::new([string[]]@('requirements.txt')) + if ($AppPath) { + $appReq = [IO.Path]::Combine($AppPath, 'requirements.txt') + if (Test-Path $appReq) { + $req_files.Add($appReq) + } + $localSettings = [IO.Path]::Combine($AppPath, 'local.settings.json') + } + $req = @{ + name = $req_files[0] + value = "ipykernel`nnotebook`npypath-magic`n" + } + $activateScript = Invoke-VenvActivate -GetPath + $venvCreated = $activateScript ? $true : $false + + # get environment variables from local.settings.json file + if ($opt -in @('setenv', 'getenv')) { + if (Test-Path $localSettings) { + Write-Host "`e[96mUsing variables configured in local.settings.json.`e[0m" + $envVars = (Get-Content ([IO.Path]::Combine($AppPath, 'local.settings.json')) | ConvertFrom-Json).Values + } else { + Write-Warning "File `e[3mlocal.settings.json`e[23m do not exist." + break + } + } + } + + process { + switch ($opt) { + # *Delete python virtual environment. + remove { + if (Get-ChildItem Function:deactivate -ErrorAction SilentlyContinue) { + if ($PSBoundParameters.Verbose) { Write-Verbose 'deactivate' } + deactivate + } + if (Test-Path $VENV_DIR) { + Write-Host "`e[96mDelete virtual environment.`e[0m" + Remove-Item $VENV_DIR -Recurse -Force + } else { + Write-Host "`e[96mVirtual environment not exists.`e[0m" + } + break + } + + # *Delete all cache folders + clean { + $dirs = Get-ChildItem -Directory -Exclude '.venv' + foreach ($dir in $dirs) { + if ($dir.Name -match '_cache$|__pycache__') { + Remove-Item "$dir" -Recurse -Force + } else { + @('*_cache', '__pycache__') | ForEach-Object { + [IO.Directory]::GetDirectories($dir.FullName, $_, 1) | Remove-Item -Recurse -Force + } + } + } + break + } + + # *Purge pip cache. + purge { + Write-Host "`e[96mDelete virtual environment.`e[0m" + if ($PSBoundParameters.Verbose) { Write-Verbose 'pip cache purge' } + & pip cache purge + break + } + + # *Generate key pairs for SSH authentication in remote repository. + sshkey { + if ($IsLinux) { + if (!(Test-Path '~/.ssh/id_rsa.pub')) { + # create new authentication key pairs for SSH if not exist + sh -c "ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ''" + } + Write-Host "`e[95mAdd below key to the repository's SSH keys:`e[0m" + Get-Content '~/.ssh/id_rsa.pub' + } elseif ($IsWindows) { + Write-Host "`e[96mYou don't need to crete key for SSH, use HTTPS.`e[0m`n" + } + break + } + + # *Trust SSL connection to pypi.org. + ssltrust { + if ($IsWindows) { + $pipLocation = "$env:APPDATA\pip\pip.ini" + } elseif ($IsLinux -or $IsMacOS) { + $pipLocation = "$env:HOME/.config/pip/pip.conf" + } + $pipConfDir = [IO.Path]::GetDirectoryName($pipLocation) + if (!(Test-Path $pipConfDir)) { New-Item $pipConfDir -ItemType Directory | Out-Null } + Set-Content $pipLocation -Value "[global]`ntrusted-host = pypi.org`n`tpypi.python.org`n`tfiles.pythonhosted.org" + break + } + + # *Set project environment variables. + setenv { + # set environment targed depending on host system + foreach ($prop in $envVars.PSObject.Properties) { + if ($IsWindows) { + [Environment]::SetEnvironmentVariable($prop.Name, $prop.Value, 'User') + # refresh environment + try { + RefreshEnv.cmd + } catch { + taskkill.exe /F /IM explorer.exe; Start-Process explorer.exe + } + } else { + if (!([Environment]::GetEnvironmentVariable($prop.Name))) { + "export $($prop.Name)=""$($prop.Value)""" >> ~/.profile + } + } + } + break + } + + # *Get project environment variables. + getenv { + foreach ($prop in $envVars.PSObject.Properties) { + [PSCustomObject]@{ + Variable = $prop.Name + Value = [Environment]::GetEnvironmentVariable($prop.Value) + } + } + break + } + + # *List installed modules. + list { + python3 -m pip list --format=json | ConvertFrom-Json | Tee-Object -Variable modules | Format-Table + $pipPath = (python3 -m pip -V) -replace '^.*from |pip \(.*$' -replace $HOME, '~' + Write-Host "`e[96m$(python3 -V) `e[0m|`e[96m $($modules.Count) modules installed in `e[1;34m$pipPath`e[0m" + break + } + + # *Activate virtual environment. + { $_ -in @('update', 'venv') -and -not $env:VIRTUAL_ENV -and $venvCreated } { + if ($PSBoundParameters.Verbose) { Write-Verbose ". $($activateScript.Replace($PWD, ''))" } + . $activateScript + } + + # *Setup python virtual environment. + venv { + # create virtual environment + if ($null -eq $env:VIRTUAL_ENV) { + if ($venvCreated) { + . $activateScript + } else { + Write-Host "`e[96mSet up Python environment.`e[0m" + python3 -m venv $VENV_DIR + Invoke-VenvActivate + } + } else { + Write-Host "`e[96mVirtual environment already set.`e[0m" + } + # add files to the project + if (-not (Test-Path '.gitignore')) { + Write-Host "`e[95madd Python .gitignore`e[0m" + [Net.WebClient]::new().DownloadFile($GITIGNORE, '.gitignore') + } + if (-not (Test-Path $req.name)) { + Write-Host "`e[95madd `e[1;3mrequirements.txt`e[22;23m with dev modules`e[0m" + New-Item $req.name -Value $req.value | Out-Null + } + } + + # *Update pip, wheel and setuptools. + { $_ -in @('install', 'venv', 'update') } { + Write-Host "`e[95mupdate pip, wheel and setuptools`e[0m" + python3 -m pip install -U pip wheel setuptools + } + + # *Install requirements. + { $_ -in @('install', 'venv') } { + if (Test-Path $req.name) { + # get modules from requirements files + $modules = $req_files | ForEach-Object { Get-Content $_ } + } + if ($modules) { + Write-Host "`e[95install requirements`e[0m" + $reqs_temp = 'reqs_temp.txt' + Set-Content -Path $reqs_temp -Value $modules + python3 -m pip install -U -r $reqs_temp + Remove-Item $reqs_temp + } + # add project path in virtual environment + if ($AppPath -and $env:VIRTUAL_ENV -and 'pypath-magic' -in $modules) { + pypath add ([IO.Path]::Combine($PWD, $AppPath)) 2>$null + pypath add $PWD 2>$null + } + break + } + + # *Update all modules. + update { + $modules = (python3 -m pip list --format=json | ConvertFrom-Json).name + if ($modules) { + Write-Host "`e[95mupdate all modules`e[0m" + $reqs_temp = 'reqs_temp.txt' + Set-Content -Path $reqs_temp -Value $modules + python3 -m pip install -U -r $reqs_temp + Remove-Item $reqs_temp + } + break + } + } + } +} + +Set-Alias -Name ips -Value Invoke-PySetup + + +<# +.SYNOPSIS +Manage uv environments. +.PARAMETER Option +Select script action. +.PARAMETER PyProjectFile +Specify pyproject.toml file to use. +#> +function Invoke-UvSetup { + [CmdletBinding()] + param ( + [Parameter(Position = 0)] + [ArgumentCompletions('activate', 'bytecode', 'clean', 'envs', 'fix', 'list', 'prune', 'remove', 'setup')] + [string]$Option, + + [switch]$CertificateFix + ) + + dynamicparam { + if (@('bytecode', 'setup') -match "^$Option") { + $paramDict = [System.Management.Automation.RuntimeDefinedParameterDictionary]::new() + + $attributeCollection = [System.Collections.ObjectModel.Collection[System.Attribute]]::new() + $attributeCollection.Add([Management.Automation.ParameterAttribute]@{ Position = 1 }) + $attributeCollection.Add([Management.Automation.ArgumentCompleterAttribute]::new( + [ScriptBlock]::Create({ + [IO.Directory]::SetCurrentDirectory($PWD) + [array]$extrasName = if ([System.IO.Path]::Exists('./pyproject.toml')) { + $content = [System.IO.File]::ReadAllText('./pyproject.toml') + $reExtras = '(?s)(?<=\[project\.optional-dependencies\]\n)(.*?)(?=\n\[)' + $extras = [regex]::Matches($content, $reExtras).Value + if ($extras) { + $reExtrasName = '\b\w+(?=\s*=\s*\[)' + [regex]::Matches($extras, $reExtrasName).Value + } + } + $extrasName ? (, 'all-extras' + $extrasName) : 'none' + }) + )) + $dynParam = [System.Management.Automation.RuntimeDefinedParameter]::new( + 'Extras', [string], $attributeCollection + ) + $paramDict.Add('Extras', $dynParam) + + return $paramDict + } + } + + begin { + # check if uv is installed + $break = if ($IsLinux) { + if (Test-Path $HOME/.local/bin/uv) { + $false + } else { + Write-Warning 'uv not installed.' + $true + } + } else { + if (Get-Command 'uv' -ErrorAction SilentlyContinue) { + $false + } else { + Write-Warning 'uv not installed.' + $true + } + } + if ($break) { return } + + if (-not $Option) { + [Console]::WriteLine( + [string]::Join("`n", + "Invoke-UvSetup function manages uv environments.`n", + "usage: Invoke-UvSetup [-Option] [-PyProjectFile ] [-CertificateFix] [[-Environment] ] [[-Dependencies] ]`n", + 'The following Options are available:', + " `e[1;97mactivate`e[0m Activate virtual environment", + " `e[1;97mclean`e[0m Clear the cache", + " `e[1;97mbytecode`e[0m Update the project's environment with bytecode compilation", + " `e[1;97menvs`e[0m Enumerate all pyproject.toml files from the current path", + " `e[1;97mfix`e[0m Fix self-signed certificates", + " `e[1;97mlist`e[0m List packages", + " `e[1;97mprune`e[0m Prune all unreachable objects from the cache", + " `e[1;97mremove`e[0m Remove virtual environment", + " `e[1;97msetup`e[0m Create/upgrade environment from pyproject.toml`n" + ) + ) + return + } + # evaluate Option parameter abbreviations + $optSet = @( + 'activate' + 'bytecode' + 'clean' + 'envs' + 'fix' + 'list' + 'prune' + 'remove' + 'setup' + ) + $opt = $optSet -match "^$Option" + if ($opt.Count -eq 0) { + Write-Warning "Option parameter name '$Option' is invalid. Valid Option values are:`n`t $($optSet -join ', ')" + break + } elseif ($opt.Count -gt 1) { + Write-Warning "Option parameter name '$Option' is ambiguous. Possible matches include: $($opt -join ', ')." + break + } + + # constants + $VENV_DIR = '.venv' + + if ($opt -in @('activate', 'bytecode', 'fix', 'list', 'remove', 'setup')) { + # set location to the specified pyproject.toml location + Push-Location ($PSBoundParameters.Environment ?? '.') -StackName 'EnvDir' + # get activate script path + $activateScript = Invoke-VenvActivate -GetPath + $venvCreated = $activateScript ? $true : $false + $pyProject = (Test-Path './pyproject.toml') ? $true : $false + } + # deactivate virtual environment if already activated + if ($opt -in @('bytecode', 'remove', 'setup') -and $env:VIRTUAL_ENV) { + Invoke-VenvDeactivate -Quiet + } + } + + # *Execute option + process { + if ($CertificateFix -and $opt -in @('bytecode', 'setup')) { + $opt = $opt + 'fix' + } + switch -Regex ($opt) { + clean { + # *Clean uv cache + if ($PSBoundParameters.Verbose) { Write-Verbose 'uv cache clean' } + uv cache clean + break + } + + prune { + # *Clean uv cache + if ($PSBoundParameters.Verbose) { Write-Verbose 'uv cache prune' } + uv cache prune + break + } + + envs { + # *List environments + $tomls = Get-ChildItem '.' -Filter 'pyproject.toml' -File -Recurse + foreach ($toml in $tomls) { + # $toml = $tomls[0] + $envName = (Select-String -Pattern '^name *= *"(\S+)"' -Path $toml).Matches.Groups.Where({ $_.Name -eq '1' }).Value + [PSCustomObject]@{ + Name = $envName + Path = $toml.DirectoryName.Replace($PWD, '.') + Venv = (Invoke-VenvActivate -GetPath -Path $toml.DirectoryName) ? $true : $false + } + } + break + } + + # *Activate virtual environment. + { $_ -in @('activate', 'fix', 'list') } { + if ($venvCreated) { + if ($PSBoundParameters.Verbose) { Write-Verbose ". $($activateScript.Replace($PWD, ''))" } + . $activateScript + if ($opt -eq 'activate') { + break + } + } else { + Write-Host 'venv: environment not created.' + Pop-Location -StackName 'EnvDir' + break + } + } + + list { + # *List packages + if ($PSBoundParameters.Verbose) { Write-Verbose 'uv pip list' } + uv pip list --format=json | ConvertFrom-Json | Tee-Object -Variable modules | Format-Table + if ($modules) { + $moduleLocation = (uv pip show $modules[0].name | Select-String '(?<=Location: )\S+').Matches.Value + $relPath = [IO.Path]::GetRelativePath($PWD, $moduleLocation) + Write-Host "`e[96m$(python3 -V) `e[0m|`e[96m $($modules.Count) modules installed in `e[1;4;34m$relPath`e[0m" + } else { + Write-Host 'No modules installed.' + } + break + } + + remove { + # *Remove environment + if (Test-Path $VENV_DIR) { + Write-Host 'Removing virtual environment.' + if ($PSBoundParameters.Verbose) { Write-Verbose "Remove-Item $VENV_DIR -Recurse -Force" } + Remove-Item $VENV_DIR -Recurse -Force + } else { + Write-Host "$VENV_DIR directory doesn't exist!" + } + Pop-Location -StackName 'EnvDir' + break + } + + 'bytecode|setup' { + if ($pyProject) { + [System.Collections.Generic.List[string]]$uvArgs = @('sync') + if ($venvCreated) { + Write-Host 'Environment already exist. Upgrading...' + $uvArgs.Add('--upgrade') + } else { + Write-Host 'Creating virtual environment.' + } + if ($opt -eq 'bytecode') { $uvArgs.Add('--compile-bytecode') } + if ($PSBoundParameters.Extras) { + if ($PSBoundParameters.Extras -eq 'all-extras') { + $uvArgs.Add('--all-extras') + } elseif ($PSBoundParameters.Extras -ne 'none') { + $uvArgs.Add('--extra') + $uvArgs.Add($PSBoundParameters.Extras) + } + } + if ($PSBoundParameters.Verbose) { Write-Verbose "uv $uvArgs" } + & uv @uvArgs + Invoke-VenvActivate + } else { + Write-Warning "`e[4mpyproject.toml`e[24m file not found" + Pop-Location -StackName 'EnvDir' + break + } + } + + fix { + # *Fix certificates + Invoke-CertifiFixFromChain + break + } + } + } +} + +Set-Alias -Name ius -Value Invoke-UvSetup diff --git a/modules/do-common/do-common.psd1 b/modules/do-common/do-common.psd1 new file mode 100644 index 00000000..5ce6db23 --- /dev/null +++ b/modules/do-common/do-common.psd1 @@ -0,0 +1,147 @@ +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'do-common.psm1' + + # Version number of this module. + ModuleVersion = '1.8.3' + + # Supported PSEditions + CompatiblePSEditions = @('Core') + + # ID used to uniquely identify this module + GUID = '4fa2b6d3-def2-4684-8ed2-8d02508f35bc' + + # Author of this module + Author = 'Szymon Osiecki' + + # Copyright statement for this module + Copyright = '(c) Szymon Osiecki. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'This module is intended to streamline my workflow with PowerShell.' + + # Minimum version of the PowerShell engine required by this module + PowerShellVersion = '7.0' + + # Modules that must be imported into the global environment prior to importing this module + RequiredModules = @() + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + ScriptsToProcess = @() + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @( + # certs + 'Add-CertificateProperties' + 'ConvertFrom-PEM' + 'ConvertTo-PEM' + 'Get-Certificate' + 'Get-CertificateOpenSSL' + 'Get-RootCertificates' + 'Show-Certificate' + 'Show-CertificateChain' + 'Show-ConvertedPem' + # cli + 'Invoke-DigColored' + # common + 'ConvertFrom-Base64' + 'ConvertTo-Base64' + 'ConvertFrom-Base64Url' + 'ConvertFrom-JWT' + 'ConvertFrom-Cfg' + 'ConvertTo-Cfg' + 'ConvertTo-UTF8LF' + 'Convert-ROT13' + 'ConvertTo-JsonFormatted' + 'Get-ArrayIndexMenu' + 'Get-CmdletAlias' + 'Get-DotEnv' + 'Get-LogMessage' + 'Get-PSReadLineHistory' + 'Format-Duration' + 'Invoke-CommandRetry' + 'Invoke-ExampleScriptSave' + 'New-Password' + 'Set-DotEnv' + 'Show-Object' + 'Test-IsAdmin' + # dotnet + 'Get-DotnetCurrentDirectory' + 'Set-DotnetCurrentDirectory' + 'Set-DotnetLocation' + # logs + 'Set-LogFile' + 'Show-LogContext' + 'Write-LogContext' + # net + 'ConvertFrom-CIDR' + 'Invoke-DownloadFile' + # python + 'Invoke-CertifiFixFromChain' + 'Invoke-VenvActivate' + 'Invoke-VenvDeactivate' + 'Invoke-CondaSetup' + 'Invoke-PySetup' + 'Invoke-UvSetup' + ) + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = '*' + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @( + # certs + 'pemdec' + # cli + 'digc' + # common + 'alias' + 'egsave' + 'json' + 'pshistory' + 'ghi' + # dotnet + 'swd' + 'sswd' + 'cds' + # net + 'idf' + # python + 'fixcertpy' + 'fxcertpy' + 'iva' + 'ivd' + 'ics' + 'ips' + 'ius' + ) + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + LicenseUri = 'https://github.com/szymonos/ps-modules/blob/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/szymonos/ps-modules' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + # Prerelease = 'beta' + + } # End of PSData hashtable + + } # End of PrivateData hashtable + +} diff --git a/modules/do-common/do-common.psm1 b/modules/do-common/do-common.psm1 new file mode 100644 index 00000000..33a7f302 --- /dev/null +++ b/modules/do-common/do-common.psm1 @@ -0,0 +1,95 @@ +$ErrorActionPreference = 'Stop' + +. $PSScriptRoot/Functions/certs.ps1 +. $PSScriptRoot/Functions/cli.ps1 +. $PSScriptRoot/Functions/common.ps1 +. $PSScriptRoot/Functions/dotnet.ps1 +. $PSScriptRoot/Functions/logs.ps1 +. $PSScriptRoot/Functions/net.ps1 +. $PSScriptRoot/Functions/python.ps1 + +$exportModuleMemberParams = @{ + Function = @( + # certs + 'Add-CertificateProperties' + 'ConvertFrom-PEM' + 'ConvertTo-PEM' + 'Get-Certificate' + 'Get-CertificateOpenSSL' + 'Get-RootCertificates' + 'Show-Certificate' + 'Show-CertificateChain' + 'Show-ConvertedPem' + # cli + 'Invoke-DigColored' + # common + 'ConvertFrom-Base64' + 'ConvertTo-Base64' + 'ConvertFrom-Base64Url' + 'ConvertFrom-JWT' + 'ConvertFrom-Cfg' + 'ConvertTo-Cfg' + 'ConvertTo-UTF8LF' + 'Convert-ROT13' + 'ConvertTo-JsonFormatted' + 'Get-ArrayIndexMenu' + 'Get-CmdletAlias' + 'Get-DotEnv' + 'Get-LogMessage' + 'Get-PSReadLineHistory' + 'Format-Duration' + 'Invoke-CommandRetry' + 'Invoke-ExampleScriptSave' + 'New-Password' + 'Set-DotEnv' + 'Show-Object' + 'Test-IsAdmin' + # dotnet + 'Get-DotnetCurrentDirectory' + 'Set-DotnetCurrentDirectory' + 'Set-DotnetLocation' + # logs + 'Set-LogFile' + 'Show-LogContext' + 'Write-LogContext' + # net + 'ConvertFrom-CIDR' + 'Invoke-DownloadFile' + # python + 'Invoke-CertifiFixFromChain' + 'Invoke-VenvActivate' + 'Invoke-VenvDeactivate' + 'Invoke-CondaSetup' + 'Invoke-PySetup' + 'Invoke-UvSetup' + ) + Variable = @() + Alias = @( + # certs + 'pemdec' + # cli + 'digc' + # common + 'alias' + 'egsave' + 'json' + 'pshistory' + 'ghi' + # dotnet + 'swd' + 'sswd' + 'cds' + # net + 'idf' + # python + 'fixcertpy' + 'fxcertpy' + 'iva' + 'ivd' + 'ics' + 'ips' + 'ius' + ) +} + +Export-ModuleMember @exportModuleMemberParams diff --git a/modules/do-linux/Functions/common.ps1 b/modules/do-linux/Functions/common.ps1 new file mode 100644 index 00000000..e57b8f60 --- /dev/null +++ b/modules/do-linux/Functions/common.ps1 @@ -0,0 +1,138 @@ +<# +.SYNOPSIS +Returns system information from /etc/os-release. +#> +function Get-SysInfo { + # get os-release properties + $osr = Get-DotEnv '/etc/os-release' + # get cpu info + $cpu = @{} + (Select-String '^model name|^cpu cores|^siblings' '/proc/cpuinfo' -Raw | Select-Object -Unique).ForEach({ + $key, $value = $_.Split(':').Trim() + $cpu[$key] = $value + } + ) + # calculate memory usage + $mem = @{} + (Select-String '^MemTotal|^MemAvailable' '/proc/meminfo' -Raw).ForEach({ + $key, $value = $_.Split(':') + $mem[$key] = ($value -replace '[^0-9]') / 1MB + } + ) + $mem['MemUsed'] = $mem.MemTotal - $mem.MemAvailable + + # build system properties + $sysProp = [ordered]@{ + UserHost = "`e[1;34m$(id -un)`e[0m@`e[1;34m$([System.IO.File]::ReadAllLines('/proc/sys/kernel/hostname'))`e[0m" + OS = "`e[1;37m$($osr.NAME) $($osr.BUILD_ID ?? $osr.VERSION ?? $osr.VERSION_ID) $(uname -m)`e[0m" + Kernel = uname -r + Uptime = "$(Get-Uptime)" + } + if ($env:WSL_DISTRO_NAME) { $sysProp['OS Host'] = 'Windows Subsystem for Linux' } + if ($env:WSL_DISTRO_NAME) { $sysProp['WSL Distro'] = $env:WSL_DISTRO_NAME } + if ($env:CONTAINER_ID) { $sysProp['DistroBox'] = $env:CONTAINER_ID } + if ($env:TERM_PROGRAM) { $sysProp['Terminal'] = $env:TERM_PROGRAM } + $sysProp['Shell'] = "PowerShell $($PSVersionTable.PSVersion)" + $sysProp['CPU'] = "$($cpu['model name']) ($($cpu['cpu cores'])/$($cpu['siblings']))" + $sysProp['Memory'] = '{0:n2} GiB / {1:n2} GiB ({2:p0})' -f $mem['MemUsed'], $mem['MemTotal'], ($mem['MemUsed'] / $mem['MemTotal']) + if ($env:LANG) { $sysProp['Locale'] = $env:LANG } + + return [PSCustomObject]$sysProp +} + +New-Alias -Name gsi -Value Get-SysInfo + + +<# +.SYNOPSIS +Run commands as root in PowerShell. +.DESCRIPTION +Wrapper for sudo command to handle defined aliases and one-liner functions. +#> +function Invoke-Sudo { + for ($i = 0; $i -lt $args.Count; $i++) { + # expand arguments alias/function definition + if ($cmd = (Get-ChildItem Alias:/$($args[$i]) -ErrorAction SilentlyContinue || Get-ChildItem Function:/$($args[$i]) -ErrorAction SilentlyContinue).Definition.Where({ $_ -notmatch '\n' })) { + $args[$i] = "$cmd".Trim().Replace('$input | ', '').Replace('& /usr/bin/env ', '').Replace(' @args', '') + } elseif ($args[$i] -match ' ') { + # quote arguments with spaces + $args[$i] = "'$($args[$i])'" + } + } + & /usr/bin/env bash -c "/usr/bin/env sudo $args" +} + +Set-Alias -Name _ -Value Invoke-Sudo + + +<# +.SYNOPSIS +Run PowerShell cmdlets as root. +.DESCRIPTION +Wrapper for sudo command to execute PowerShell cmdlets and handle defined aliases and one-liner functions. +#> +function Invoke-SudoPS { + for ($i = 0; $i -lt $args.Count; $i++) { + # expand arguments alias/function definition + if ($cmd = (Get-ChildItem Alias:/$($args[$i]) -ErrorAction SilentlyContinue || Get-ChildItem Function:/$($args[$i]) -ErrorAction SilentlyContinue).Definition.Where({ $_ -notmatch '\n' })) { + $args[$i] = "$cmd".Trim().Replace('$input | ', '').Replace('& /usr/bin/env ', '').Replace(' @args', '') + } elseif ($args[$i] -match ' ') { + # quote arguments with spaces + $args[$i] = "'$($args[$i])'" + } + } + # run sudo command with resolved commands + & /usr/bin/env sudo pwsh -NoProfile -NonInteractive -Command "$args" +} + +Set-Alias -Name sps -Value Invoke-SudoPS + + +<# +.SYNOPSIS +Fix executable bit based on shebang presence. +.DESCRIPTION +Process specified directory, looking for bash and powershell scripts, and sets executable bit based on shebang presence. +#> +function Invoke-ExecutableBitFix { + [CmdletBinding()] + [OutputType([System.Void])] + param ( + [Parameter(Position = 0)] + [ValidateNotNullorEmpty()] + [ValidateScript({ Test-Path $_ -PathType 'Container' }, ErrorMessage = "`e[1;4m{0}`e[22;24m is not valid path")] + [string]$Path = '.', + + [ValidateNotNullorEmpty()] + [string[]]$ExtensionFilter = @('.ps1', '.py', '.sh') + ) + + # *adding executable bit in files with shebang + (Get-ChildItem $Path -File -Recurse -Force).Where({ + $_.DirectoryName -notmatch '/\.(git|venv)\b' ` + -and ($_.Extension -in $ExtensionFilter -or -not $_.Extension) ` + -and $_.UnixMode -notmatch '^-rwx' ` + -and (Get-Content $_ -Head 1 | Select-String '^#!' -Quiet) + } + ).ForEach({ + Write-Host $_.FullName -ForegroundColor Green + chmod +x $_.FullName + } + ) + + # *removing executable bit from files without shebang + (Get-ChildItem $Path -File -Recurse -Force).Where({ + $_.DirectoryName -notmatch '/\.(git|venv)\b' ` + -and ($_.Extension -in $ExtensionFilter -or -not $_.Extension) ` + -and $_.UnixMode -match '^-rwx' ` + -and (Get-Content $_ -Head 1 | Select-String '^#!' -NotMatch -Quiet) + } + ).ForEach({ + Write-Host $_.FullName + chmod -x $_.FullName + } + ) +} + +Set-Alias -Name fixmod -Value Invoke-ExecutableBitFix +Set-Alias -Name fxmod -Value Invoke-ExecutableBitFix diff --git a/modules/do-linux/Functions/completers.ps1 b/modules/do-linux/Functions/completers.ps1 new file mode 100644 index 00000000..360aa5c6 --- /dev/null +++ b/modules/do-linux/Functions/completers.ps1 @@ -0,0 +1,73 @@ +<# +.SYNOPSIS +Registers a tab-completion function for Makefile targets. + +.DESCRIPTION +Call 'Register-MakeCompleter' in your Powershell Profile for auto-completions on your Makefiles. +If you include a description for you target, it'll use that too: + target: ## This target does a thing. +#> +function Register-MakeCompleter { + $ScriptBlock = { + param( + $wordToComplete + ) + + # if no Makefile exists in the current directory, return no completions + if (-not (Test-Path './Makefile')) { + return + } + + # parse the Makefile, looking for targets and their descriptions + # the regex looks for a line starting with a target name, followed by ':', and optionally a comment starting with '##'. + $content = [System.IO.File]::ReadAllLines("$PWD/Makefile") + + $targets = $content.ForEach({ + if ($_ -match '^([a-zA-Z0-9_-]+):.*?\#\#\s*(.*)$') { + # try capturing target and description + [PSCustomObject]@{ + Name = $matches[1] + Description = $matches[2].Trim() + } + } elseif ($_ -match '^([a-zA-Z0-9_-]+):') { + # target without a description + [PSCustomObject]@{ + Name = $matches[1] + Description = '' + } + } + } + ) | Sort-Object Name -Unique + + # calculate the maximum length of target names for padding purposes + $maxNameLength = ($targets.ForEach({ $_.Name.Length }) | Measure-Object -Maximum).Maximum + + # define colors and styles for the display text + $blue = $PSStyle.Foreground.Blue + $bold = $PSStyle.Bold + $reset = $PSStyle.Reset + + # filter and return the completion results + $targets.Where({ $_.Name -match "^$wordToComplete" }).ForEach({ + # incorporate description into the display text for visibility + $paddedName = $_.Name.PadRight($maxNameLength + 2) + $displayText = if ([string]::IsNullOrWhiteSpace($_.Description)) { + $_.Name + } else { + "$($blue)$($bold)$($paddedName)$($reset)$($_.Description)" + } + + # even though we still pass the description as tooltip, it's mainly for completeness + # the $displayText ensures visibility in the suggestion list. + [System.Management.Automation.CompletionResult]::new( + $_.Name, # completionText + $displayText, # listItemText + 'ParameterValue', # resultType + $displayText # toolTip + ) + } + ) + } + + Register-ArgumentCompleter -Native -CommandName @('make', 'm') -ScriptBlock $ScriptBlock +} diff --git a/modules/do-linux/do-linux.psd1 b/modules/do-linux/do-linux.psd1 new file mode 100644 index 00000000..5ee8747e --- /dev/null +++ b/modules/do-linux/do-linux.psd1 @@ -0,0 +1,149 @@ +# +# Module manifest for module 'do-linux' +# +# Generated by: szymono +# +# Generated on: 2022-12-04 +# + +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'do-linux.psm1' + + # Version number of this module. + ModuleVersion = '0.6.0' + + # Supported PSEditions + # CompatiblePSEditions = @() + + # ID used to uniquely identify this module + GUID = '28b20dfb-9519-4438-8517-f4b1212d0522' + + # Author of this module + Author = 'szymono' + + # Company or vendor of this module + # CompanyName = 'Unknown' + + # Copyright statement for this module + Copyright = '(c) szymono. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'This module is intended to streamline my workflow with PowerShell on Linux.' + + # Minimum version of the PowerShell engine required by this module + CompatiblePSEditions = @('Core') + PowerShellVersion = '7.0' + + # Name of the PowerShell host required by this module + # PowerShellHostName = '' + + # Minimum version of the PowerShell host required by this module + # PowerShellHostVersion = '' + + # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # DotNetFrameworkVersion = '' + + # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # ClrVersion = '' + + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' + + # Modules that must be imported into the global environment prior to importing this module + RequiredModules = @( + 'do-common' + ) + + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() + + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() + + # Format files (.ps1xml) to be loaded when importing this module + # FormatsToProcess = @() + + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + # NestedModules = @() + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = @( + # common + 'Get-SysInfo' + 'Invoke-Sudo' + 'Invoke-SudoPS' + 'Invoke-ExecutableBitFix' + # completers + 'Register-MakeCompleter' + ) + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = '*' + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = @( + # common + 'gsi' + '_' + 'sps' + 'fixmod' + 'fxmod' + ) + + # DSC resources to export from this module + # DscResourcesToExport = @() + + # List of all modules packaged with this module + # ModuleList = @() + + # List of all files packaged with this module + # FileList = @() + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + LicenseUri = 'https://github.com/szymonos/ps-modules/blob/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/szymonos/ps-modules' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + Prerelease = 'beta' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + } # End of PrivateData hashtable + + # HelpInfo URI of this module + # HelpInfoURI = '' + + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' + +} diff --git a/modules/do-linux/do-linux.psm1 b/modules/do-linux/do-linux.psm1 new file mode 100644 index 00000000..4594ab83 --- /dev/null +++ b/modules/do-linux/do-linux.psm1 @@ -0,0 +1,27 @@ +$ErrorActionPreference = 'Stop' + +. $PSScriptRoot/Functions/common.ps1 +. $PSScriptRoot/Functions/completers.ps1 + +$exportModuleMemberParams = @{ + Function = @( + # common + 'Get-SysInfo' + 'Invoke-Sudo' + 'Invoke-SudoPS' + 'Invoke-ExecutableBitFix' + # completers + 'Register-MakeCompleter' + ) + Variable = @() + Alias = @( + # common + 'gsi' + '_' + 'sps' + 'fixmod' + 'fxmod' + ) +} + +Export-ModuleMember @exportModuleMemberParams diff --git a/modules/InstallUtils/Functions/common.ps1 b/modules/psm-windows/Functions/common.ps1 similarity index 65% rename from modules/InstallUtils/Functions/common.ps1 rename to modules/psm-windows/Functions/common.ps1 index 0551b91b..2cadad1f 100644 --- a/modules/InstallUtils/Functions/common.ps1 +++ b/modules/psm-windows/Functions/common.ps1 @@ -1,3 +1,51 @@ +<# +.SYNOPSIS +Formats log message. + +.PARAMETER Message +Log message text to be printed. +.PARAMETER Level +Log level. +#> +function Get-LogMessage { + [CmdletBinding()] + param ( + [Parameter(Mandatory, Position = 0)] + [ValidateNotNullOrEmpty()] + [string]$Message, + + [ValidateSet('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL')] + [string]$Level = 'INFO' + ) + + # ANSI escape sequence + $ESC = [char]0x001b + # calculate message color + $msgColor = switch ($Level) { + DEBUG { "$ESC[36m" } + INFO { "$ESC[34m" } + WARNING { "$ESC[33m" } + ERROR { "$ESC[31m" } + CRITICAL { "$ESC[91m" } + } + # calculate message information + $position = "$(Split-Path $MyInvocation.ScriptName -Leaf):$($MyInvocation.ScriptLineNumber)" + $ts = (Get-Date).ToString('s').Replace('T', ' ') + + # print log message + $msg = "$ESC[32m{0}$ESC[0m|$ESC[30m{1}$ESC[0m|{2} - $msgColor{3}$ESC[0m" -f $ts, $Level.ToUpper(), $position, $Message + Write-Host $msg +} + + +<# +.SYNOPSIS +Retry executing command if fails on HttpRequestException. +.PARAMETER Command +Script block of commands to execute. +.PARAMETER MaxRetries +Maximum number of retries to rerun the script block. +#> function Invoke-CommandRetry { [CmdletBinding()] param ( @@ -44,6 +92,20 @@ function Invoke-CommandRetry { } until ($exit) } + +<# +.SYNOPSIS +Combines objects from the pipeline into a single string. + +.PARAMETER InputObject +Specifies the text to be joined. +.PARAMETER Separator +Text or characters such as a comma or semicolon that's inserted between the text for each pipeline object. +.PARAMETER SingleQuote +Wraps the string value of each pipeline object in single quotes. +.PARAMETER DoubleQuote +Wraps the string value of each pipeline object in double-quotes. +#> function Join-Str { [CmdletBinding(DefaultParameterSetName = 'None')] [OutputType([string])] @@ -84,6 +146,11 @@ function Join-Str { } } + +<# +.SYNOPSIS +Check if PowerShell runs elevated. +#> function Test-IsAdmin { $currentIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent() $principal = [System.Security.Principal.WindowsPrincipal]$currentIdentity @@ -92,6 +159,11 @@ function Test-IsAdmin { return $principal.IsInRole($admin) } + +<# +.SYNOPSIS +Refresh path environment variable for process scope. +#> function Update-SessionEnvironmentPath { # instantiate a HashSet to store unique paths $auxHashSet = [Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase) @@ -109,3 +181,5 @@ function Update-SessionEnvironmentPath { # set the Path environment variable in the current process scope [System.Environment]::SetEnvironmentVariable('Path', $pathStr, 'Process') } + +Set-Alias -Name refreshenvpath -Value Update-SessionEnvironmentPath diff --git a/modules/psm-windows/psm-windows.psd1 b/modules/psm-windows/psm-windows.psd1 new file mode 100644 index 00000000..6383604f --- /dev/null +++ b/modules/psm-windows/psm-windows.psd1 @@ -0,0 +1,131 @@ +# +# Module manifest for module 'psm-windows' +# +# Generated by: szymo +# +# Generated on: 2023-09-29 +# + +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'psm-windows.psm1' + + # Version number of this module. + ModuleVersion = '0.5.0' + + # Supported PSEditions + CompatiblePSEditions = @('Core', 'Desk') + + # ID used to uniquely identify this module + GUID = '2e3fe756-ac40-4ab9-968b-46c1d3982f1c' + + # Author of this module + Author = 'Szymon Osiecki' + + # Company or vendor of this module + # CompanyName = 'Unknown' + + # Copyright statement for this module + Copyright = '(c) Szymon Osiecki. All rights reserved.' + + # Description of the functionality provided by this module + Description = 'Module with basic functions, compatible with Windows PowerShell.' + + # Minimum version of the PowerShell engine required by this module + PowerShellVersion = '5.1' + + # Name of the PowerShell host required by this module + # PowerShellHostName = '' + + # Minimum version of the PowerShell host required by this module + # PowerShellHostVersion = '' + + # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # DotNetFrameworkVersion = '' + + # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. + # ClrVersion = '' + + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' + + # Modules that must be imported into the global environment prior to importing this module + # RequiredModules = @() + + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() + + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() + + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() + + # Format files (.ps1xml) to be loaded when importing this module + # FormatsToProcess = @() + + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + # NestedModules = @() + + # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. + FunctionsToExport = '*' + + # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. + CmdletsToExport = @() + + # Variables to export from this module + VariablesToExport = '*' + + # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. + AliasesToExport = '*' + + # DSC resources to export from this module + # DscResourcesToExport = @() + + # List of all modules packaged with this module + # ModuleList = @() + + # List of all files packaged with this module + # FileList = @() + + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + LicenseUri = 'https://github.com/szymonos/ps-modules/blob/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/szymonos/ps-modules' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + # Prerelease string of this module + Prerelease = 'beta' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + + } # End of PrivateData hashtable + + # HelpInfo URI of this module + # HelpInfoURI = '' + + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' + +} diff --git a/modules/InstallUtils/InstallUtils.psm1 b/modules/psm-windows/psm-windows.psm1 similarity index 68% rename from modules/InstallUtils/InstallUtils.psm1 rename to modules/psm-windows/psm-windows.psm1 index a07def98..a2501bc0 100644 --- a/modules/InstallUtils/InstallUtils.psm1 +++ b/modules/psm-windows/psm-windows.psm1 @@ -1,21 +1,19 @@ $ErrorActionPreference = 'Stop' . $PSScriptRoot/Functions/common.ps1 -. $PSScriptRoot/Functions/git.ps1 $exportModuleMemberParams = @{ Function = @( - # common + 'Get-LogMessage' 'Invoke-CommandRetry' 'Join-Str' 'Test-IsAdmin' 'Update-SessionEnvironmentPath' - # git - 'Invoke-GhRepoClone' - 'Update-GitRepository' ) Variable = @() - Alias = @() + Alias = @( + 'refreshenvpath' + ) } Export-ModuleMember @exportModuleMemberParams diff --git a/modules/InstallUtils/Functions/git.ps1 b/modules/utils-install/Functions/git.ps1 similarity index 77% rename from modules/InstallUtils/Functions/git.ps1 rename to modules/utils-install/Functions/git.ps1 index f3d343b8..57a7005b 100644 --- a/modules/InstallUtils/Functions/git.ps1 +++ b/modules/utils-install/Functions/git.ps1 @@ -27,14 +27,13 @@ function Invoke-GhRepoClone { $org, $repo = $OrgRepo.Split('/') # command for getting the remote url $getOrigin = { git config --get remote.origin.url; if (-not $?) { 'https://github.com/' } } - # determine clone protocol: prefer SSH if key is configured, fallback to HTTPS. - # the Get-Command guard matters on Windows PowerShell hosts (e.g. wsl_setup.ps1) where - # OpenSSH may not be on PATH; without it the bare `ssh` call throws under ErrorAction=Stop. - $gitProtocol = if ((Get-Command ssh -ErrorAction SilentlyContinue) -and (ssh -T git@github.com 2>&1 | Select-String -Quiet 'successfully authenticated')) { - 'git@github.com:' - } else { - $(Invoke-Command $getOrigin) -replace '(^.+github\.com[:/]).*', '$1' - } + # derive clone protocol from the parent repo's remote URL. The previous + # version did an `ssh -T git@github.com` probe to force SSH-first when + # ssh was available; that was removed because the probe blocks on + # host-key prompts, slow DNS, and firewall holes - and the catch block + # below already retries SSH failures over HTTPS, so the probe was + # redundant defensive-ness. + $gitProtocol = $(Invoke-Command $getOrigin) -replace '(^.+github\.com[:/]).*', '$1' # calculate destination path $destPath = Join-Path $Path -ChildPath $repo } @@ -60,23 +59,24 @@ function Invoke-GhRepoClone { } Pop-Location } catch { - # clone target repository - try SSH first, fall back to HTTPS + # clone target repository. Capture combined stdout+stderr and check + # $LASTEXITCODE - the previous `git clone ... | ForEach-Object {...}` + # made $? reflect the pipeline's tail (ForEach-Object, always true), + # masking clone failures and skipping the HTTPS fallback. $cloneUrl = "${gitProtocol}${org}/${repo}.git" - $cloneErr = $null - git clone $cloneUrl "$destPath" --quiet 2>&1 | ForEach-Object { $cloneErr += "$_`n" } - if (-not $?) { - if ($gitProtocol -eq 'git@github.com:') { - Write-Warning "SSH clone failed, retrying with HTTPS: $($cloneErr?.Trim())" - $cloneUrl = "https://github.com/${org}/${repo}.git" - $cloneErr = $null - git clone $cloneUrl "$destPath" --quiet 2>&1 | ForEach-Object { $cloneErr += "$_`n" } - } + $cloneOut = git clone $cloneUrl "$destPath" --quiet 2>&1 + $cloneOk = $LASTEXITCODE -eq 0 + if (-not $cloneOk -and $gitProtocol -eq 'git@github.com:') { + Write-Warning "SSH clone failed, retrying with HTTPS: $(($cloneOut | Out-String).Trim())" + $cloneUrl = "https://github.com/${org}/${repo}.git" + $cloneOut = git clone $cloneUrl "$destPath" --quiet 2>&1 + $cloneOk = $LASTEXITCODE -eq 0 } - $status = if ($?) { + $status = if ($cloneOk) { Write-Verbose "Repository `"$OrgRepo`" cloned successfully." Write-Output 1 } else { - Write-Warning "Cloning `"$OrgRepo`" failed ($cloneUrl): $($cloneErr?.Trim())" + Write-Warning "Cloning `"$OrgRepo`" failed ($cloneUrl): $(($cloneOut | Out-String).Trim())" Write-Output 0 } } diff --git a/modules/InstallUtils/InstallUtils.psd1 b/modules/utils-install/utils-install.psd1 similarity index 95% rename from modules/InstallUtils/InstallUtils.psd1 rename to modules/utils-install/utils-install.psd1 index f0ba873d..deed9e8e 100644 --- a/modules/InstallUtils/InstallUtils.psd1 +++ b/modules/utils-install/utils-install.psd1 @@ -1,5 +1,5 @@ # -# Module manifest for module 'InstallUtils' +# Module manifest for module 'utils-install' # # Generated by: szymo # @@ -9,7 +9,7 @@ @{ # Script module or binary module file associated with this manifest. - RootModule = 'InstallUtils.psm1' + RootModule = 'utils-install.psm1' # Version number of this module. ModuleVersion = '0.3.4' @@ -70,11 +70,6 @@ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. FunctionsToExport = @( - # common - 'Invoke-CommandRetry' - 'Join-Str' - 'Test-IsAdmin' - 'Update-SessionEnvironmentPath' # git 'Invoke-GhRepoClone' 'Update-GitRepository' diff --git a/modules/utils-install/utils-install.psm1 b/modules/utils-install/utils-install.psm1 new file mode 100644 index 00000000..6e0952cb --- /dev/null +++ b/modules/utils-install/utils-install.psm1 @@ -0,0 +1,15 @@ +$ErrorActionPreference = 'Stop' + +. $PSScriptRoot/Functions/git.ps1 + +$exportModuleMemberParams = @{ + Function = @( + # git + 'Invoke-GhRepoClone' + 'Update-GitRepository' + ) + Variable = @() + Alias = @() +} + +Export-ModuleMember @exportModuleMemberParams diff --git a/modules/SetupUtils/Functions/wsl.ps1 b/modules/utils-setup/Functions/wsl.ps1 similarity index 98% rename from modules/SetupUtils/Functions/wsl.ps1 rename to modules/utils-setup/Functions/wsl.ps1 index 2cb3c4e4..a6c40ddf 100644 --- a/modules/SetupUtils/Functions/wsl.ps1 +++ b/modules/utils-setup/Functions/wsl.ps1 @@ -142,7 +142,7 @@ https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconf .PARAMETER Distro Name of the WSL distro to set wsl.conf. .PARAMETER ConfDict -Input ordered dictionary consisting configuration to be saved into wsl.conf. +Input dictionary consisting configuration to be saved into wsl.conf. .PARAMETER ShowConf Print current wsl.conf after setting the configuration. #> @@ -152,7 +152,7 @@ function Set-WslConf { [Parameter(Mandatory, Position = 0)] [string]$Distro, - [System.Collections.Specialized.OrderedDictionary]$ConfDict, + [System.Collections.IDictionary]$ConfDict, [switch]$ShowConf ) diff --git a/modules/SetupUtils/SetupUtils.psd1 b/modules/utils-setup/utils-setup.psd1 similarity index 91% rename from modules/SetupUtils/SetupUtils.psd1 rename to modules/utils-setup/utils-setup.psd1 index faae0f29..49faaed4 100644 --- a/modules/SetupUtils/SetupUtils.psd1 +++ b/modules/utils-setup/utils-setup.psd1 @@ -1,5 +1,5 @@ # -# Module manifest for module 'SetupUtils' +# Module manifest for module 'utils-setup' # # Generated by: szymo # @@ -9,10 +9,10 @@ @{ # Script module or binary module file associated with this manifest. - RootModule = 'SetupUtils.psm1' + RootModule = 'utils-setup.psm1' # Version number of this module. - ModuleVersion = '0.6.0' + ModuleVersion = '0.7.0' # Supported PSEditions CompatiblePSEditions = @('Core') @@ -70,18 +70,6 @@ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. FunctionsToExport = @( - # certs - 'ConvertFrom-PEM' - 'ConvertTo-PEM' - 'Get-Certificate' - # common - 'Get-LogMessage' - 'ConvertFrom-Cfg' - 'ConvertTo-Cfg' - 'Get-ArrayIndexMenu' - 'Invoke-ExampleScriptSave' - # logs - 'Show-LogContext' # wsl 'Get-WslDistro' 'Set-WslConf' diff --git a/modules/utils-setup/utils-setup.psm1 b/modules/utils-setup/utils-setup.psm1 new file mode 100644 index 00000000..7bea18a9 --- /dev/null +++ b/modules/utils-setup/utils-setup.psm1 @@ -0,0 +1,15 @@ +$ErrorActionPreference = 'Stop' + +. $PSScriptRoot/Functions/wsl.ps1 + +$exportModuleMemberParams = @{ + Function = @( + # wsl + 'Get-WslDistro' + 'Set-WslConf' + ) + Variable = @() + Alias = @() +} + +Export-ModuleMember @exportModuleMemberParams diff --git a/scripts_egsave.ps1 b/scripts_egsave.ps1 index 2fd4c959..f693ed1d 100755 --- a/scripts_egsave.ps1 +++ b/scripts_egsave.ps1 @@ -33,11 +33,11 @@ begin { # set location to workspace folder Push-Location $PSScriptRoot - # check if the Invoke-ExampleScriptSave function is available, otherwise clone ps-modules repo + # check if the Invoke-ExampleScriptSave function is available, otherwise import do-common module try { Get-Command Invoke-ExampleScriptSave -CommandType Function | Out-Null } catch { - Import-Module (Resolve-Path './modules/SetupUtils') + Import-Module (Resolve-Path './modules/do-common') } # rewrite PSBoundParameters to the param variable diff --git a/tests/pester/ConvertCfg.Tests.ps1 b/tests/pester/ConvertCfg.Tests.ps1 index 3635c0ad..0ca7f7c5 100644 --- a/tests/pester/ConvertCfg.Tests.ps1 +++ b/tests/pester/ConvertCfg.Tests.ps1 @@ -1,105 +1,105 @@ #Requires -Modules Pester -# Unit tests for ConvertFrom-Cfg and ConvertTo-Cfg in SetupUtils module +# Unit tests for ConvertFrom-Cfg and ConvertTo-Cfg in do-common module BeforeAll { - . $PSScriptRoot/../../modules/SetupUtils/Functions/common.ps1 + . $PSScriptRoot/../../modules/do-common/Functions/common.ps1 } Describe 'ConvertFrom-Cfg' { It 'parses section with key-value pairs' { - $input = @( + $cfgInput = @( '[section1]' 'key1 = value1' 'key2 = value2' ) - $result = $input | ConvertFrom-Cfg + $result = $cfgInput | ConvertFrom-Cfg $result['section1']['key1'] | Should -Be 'value1' $result['section1']['key2'] | Should -Be 'value2' } It 'parses multiple sections' { - $input = @( + $cfgInput = @( '[section1]' 'key1 = value1' '[section2]' 'key2 = value2' ) - $result = $input | ConvertFrom-Cfg + $result = $cfgInput | ConvertFrom-Cfg $result.Keys | Should -HaveCount 2 $result['section1']['key1'] | Should -Be 'value1' $result['section2']['key2'] | Should -Be 'value2' } It 'preserves header comments in __header__ key' { - $input = @( + $cfgInput = @( '# This is a header comment' '# Another header line' '[section1]' 'key = value' ) - $result = $input | ConvertFrom-Cfg + $result = $cfgInput | ConvertFrom-Cfg $result.Contains('__header__') | Should -BeTrue $result['__header__'] | Should -BeLike '*header comment*' } It 'preserves comments within sections' { - $input = @( + $cfgInput = @( '[section1]' '# inline comment' 'key = value' ) - $result = $input | ConvertFrom-Cfg + $result = $cfgInput | ConvertFrom-Cfg $result['section1']['Comment1'] | Should -Be '# inline comment' $result['section1']['key'] | Should -Be 'value' } It 'ignores non-comment lines before first section' { - $input = @( + $cfgInput = @( 'stray line without section' '[section1]' 'key = value' ) - $result = $input | ConvertFrom-Cfg + $result = $cfgInput | ConvertFrom-Cfg $result['section1']['key'] | Should -Be 'value' $result.Contains('__header__') | Should -BeFalse } It 'handles empty value' { - $input = @( + $cfgInput = @( '[section1]' 'key =' ) - $result = $input | ConvertFrom-Cfg + $result = $cfgInput | ConvertFrom-Cfg $result['section1']['key'] | Should -Be '' } It 'trims whitespace from values' { - $input = @( + $cfgInput = @( '[section1]' 'key = spaced value ' ) - $result = $input | ConvertFrom-Cfg + $result = $cfgInput | ConvertFrom-Cfg $result['section1']['key'] | Should -Be 'spaced value' } It 'handles semicolon comments' { - $input = @( + $cfgInput = @( '[section1]' '; semicolon comment' 'key = value' ) - $result = $input | ConvertFrom-Cfg + $result = $cfgInput | ConvertFrom-Cfg $result['section1']['Comment1'] | Should -Be '; semicolon comment' } It 'resets comment counter per section' { - $input = @( + $cfgInput = @( '[section1]' '# comment in s1' '[section2]' '# comment in s2' ) - $result = $input | ConvertFrom-Cfg + $result = $cfgInput | ConvertFrom-Cfg $result['section1']['Comment1'] | Should -Be '# comment in s1' $result['section2']['Comment1'] | Should -Be '# comment in s2' } @@ -152,15 +152,6 @@ Describe 'ConvertTo-Cfg' { $result = $dict | ConvertTo-Cfg -LineFeed $result | Should -Not -Match "`r`n" } - - It 'accepts a non-ordered IDictionary (hashtable)' { - # PR A widened the parameter type from OrderedDictionary to IDictionary; - # this asserts a plain hashtable now pipes in cleanly. - $dict = @{ - section1 = @{ key = 'value' } - } - { $dict | ConvertTo-Cfg } | Should -Not -Throw - } } Describe 'ConvertFrom-Cfg / ConvertTo-Cfg roundtrip' { diff --git a/tests/pester/ConvertPEM.Tests.ps1 b/tests/pester/ConvertPEM.Tests.ps1 index 5f535446..67d5f475 100644 --- a/tests/pester/ConvertPEM.Tests.ps1 +++ b/tests/pester/ConvertPEM.Tests.ps1 @@ -1,8 +1,8 @@ #Requires -Modules Pester -# Unit tests for ConvertFrom-PEM and ConvertTo-PEM in SetupUtils module +# Unit tests for ConvertFrom-PEM and ConvertTo-PEM in do-common module BeforeAll { - . $PSScriptRoot/../../modules/SetupUtils/Functions/certs.ps1 + . $PSScriptRoot/../../modules/do-common/Functions/certs.ps1 } Describe 'ConvertFrom-PEM' { diff --git a/tests/pester/GetLogLine.Tests.ps1 b/tests/pester/GetLogLine.Tests.ps1 index 9fc8492d..b66b5126 100644 --- a/tests/pester/GetLogLine.Tests.ps1 +++ b/tests/pester/GetLogLine.Tests.ps1 @@ -1,8 +1,8 @@ #Requires -Modules Pester -# Unit tests for Get-LogLine in SetupUtils module +# Unit tests for Get-LogLine in do-common module BeforeAll { - . $PSScriptRoot/../../modules/SetupUtils/Functions/logs.ps1 + . $PSScriptRoot/../../modules/do-common/Functions/logs.ps1 } Describe 'Get-LogLine' { diff --git a/tests/pester/InvokeCommandRetry.Tests.ps1 b/tests/pester/InvokeCommandRetry.Tests.ps1 index 8005a18a..339f4250 100644 --- a/tests/pester/InvokeCommandRetry.Tests.ps1 +++ b/tests/pester/InvokeCommandRetry.Tests.ps1 @@ -1,8 +1,8 @@ #Requires -Modules Pester -# Unit tests for Invoke-CommandRetry in InstallUtils module +# Unit tests for Invoke-CommandRetry in do-common module BeforeAll { - . $PSScriptRoot/../../modules/InstallUtils/Functions/common.ps1 + . $PSScriptRoot/../../modules/do-common/Functions/common.ps1 } Describe 'Invoke-CommandRetry' { diff --git a/tests/pester/JoinStr.Tests.ps1 b/tests/pester/JoinStr.Tests.ps1 index 0f83b44a..32a29a8b 100644 --- a/tests/pester/JoinStr.Tests.ps1 +++ b/tests/pester/JoinStr.Tests.ps1 @@ -1,8 +1,8 @@ #Requires -Modules Pester -# Unit tests for Join-Str in InstallUtils module +# Unit tests for Join-Str in psm-windows module BeforeAll { - . $PSScriptRoot/../../modules/InstallUtils/Functions/common.ps1 + . $PSScriptRoot/../../modules/psm-windows/Functions/common.ps1 } Describe 'Join-Str' { diff --git a/vagrant/hyperv/arch/Vagrantfile b/vagrant/hyperv/arch/Vagrantfile index 4f1beeed..85c78f99 100644 --- a/vagrant/hyperv/arch/Vagrantfile +++ b/vagrant/hyperv/arch/Vagrantfile @@ -48,7 +48,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -152,7 +157,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/hyperv/debian/Vagrantfile b/vagrant/hyperv/debian/Vagrantfile index 3f01b57c..04204ea6 100644 --- a/vagrant/hyperv/debian/Vagrantfile +++ b/vagrant/hyperv/debian/Vagrantfile @@ -56,7 +56,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -159,7 +164,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/hyperv/fedora/Vagrantfile b/vagrant/hyperv/fedora/Vagrantfile index 671a69cb..7840b4a9 100644 --- a/vagrant/hyperv/fedora/Vagrantfile +++ b/vagrant/hyperv/fedora/Vagrantfile @@ -46,7 +46,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -158,7 +163,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/hyperv/ubuntu/Vagrantfile b/vagrant/hyperv/ubuntu/Vagrantfile index 9e21f36f..4cb0acb1 100644 --- a/vagrant/hyperv/ubuntu/Vagrantfile +++ b/vagrant/hyperv/ubuntu/Vagrantfile @@ -55,7 +55,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -158,7 +163,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/libvirt/alpine/Vagrantfile b/vagrant/libvirt/alpine/Vagrantfile index 98b474ca..51a3ec02 100644 --- a/vagrant/libvirt/alpine/Vagrantfile +++ b/vagrant/libvirt/alpine/Vagrantfile @@ -39,7 +39,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -108,7 +113,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/libvirt/arch/Vagrantfile b/vagrant/libvirt/arch/Vagrantfile index 50442648..048254df 100644 --- a/vagrant/libvirt/arch/Vagrantfile +++ b/vagrant/libvirt/arch/Vagrantfile @@ -41,7 +41,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -133,7 +138,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/libvirt/debian/Vagrantfile b/vagrant/libvirt/debian/Vagrantfile index aa28fa21..452590df 100644 --- a/vagrant/libvirt/debian/Vagrantfile +++ b/vagrant/libvirt/debian/Vagrantfile @@ -33,7 +33,12 @@ script_install_packages = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -122,7 +127,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/libvirt/fedora/Vagrantfile b/vagrant/libvirt/fedora/Vagrantfile index b5406aba..8b52ce8d 100644 --- a/vagrant/libvirt/fedora/Vagrantfile +++ b/vagrant/libvirt/fedora/Vagrantfile @@ -41,7 +41,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -133,7 +138,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/libvirt/opensuse/Vagrantfile b/vagrant/libvirt/opensuse/Vagrantfile index f28dffea..fa6bc1c8 100644 --- a/vagrant/libvirt/opensuse/Vagrantfile +++ b/vagrant/libvirt/opensuse/Vagrantfile @@ -42,7 +42,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -134,7 +139,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/libvirt/ubuntu/Vagrantfile b/vagrant/libvirt/ubuntu/Vagrantfile index 9ba9604b..004a92aa 100644 --- a/vagrant/libvirt/ubuntu/Vagrantfile +++ b/vagrant/libvirt/ubuntu/Vagrantfile @@ -45,7 +45,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -135,7 +140,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/virtualbox/fedora/Vagrantfile b/vagrant/virtualbox/fedora/Vagrantfile index e62e1d4e..506ac8a7 100644 --- a/vagrant/virtualbox/fedora/Vagrantfile +++ b/vagrant/virtualbox/fedora/Vagrantfile @@ -41,7 +41,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -151,7 +156,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/vagrant/virtualbox/ubuntu/Vagrantfile b/vagrant/virtualbox/ubuntu/Vagrantfile index 3ec2f720..be1362fc 100644 --- a/vagrant/virtualbox/ubuntu/Vagrantfile +++ b/vagrant/virtualbox/ubuntu/Vagrantfile @@ -47,7 +47,12 @@ script_configure_static_ip = <<~SCRIPT SCRIPT script_install_psmodules = <<~SCRIPT - pwsh -nop -c "@('aliases-git', 'do-common', 'do-linux') | ~/source/repos/szymonos/ps-modules/module_manage.ps1 -CleanUp" || true + cd ~/source/repos/szymonos/linux-setup-scripts || exit 0 + mkdir -p ~/.local/share/powershell/Modules + for module in aliases-git do-common do-linux; do + rm -rf ~/.local/share/powershell/Modules/$module + cp -rf modules/$module ~/.local/share/powershell/Modules/ + done SCRIPT # *VM provisioning @@ -154,7 +159,7 @@ Vagrant.configure("2") do |config| node.vm.provision "shell", name: "install pwsh...", path: "../../../.assets/provision/install_pwsh.sh", :args => '>/dev/null' node.vm.provision "shell", name: "set up pwsh for all users...", path: "../../../.assets/provision/setup_profile_allusers.ps1" node.vm.provision "shell", name: "set up pwsh for current user...", path: "../../../.assets/provision/setup_profile_user.ps1", privileged: false - node.vm.provision "shell", name: "clone ps-modules repo...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts szymonos/ps-modules'], privileged: false + node.vm.provision "shell", name: "clone repos...", path: "../../../.assets/provision/setup_gh_repos.sh", :args => ['--repos', 'szymonos/linux-setup-scripts'], privileged: false node.vm.provision "shell", name: "install ps-modules...", inline: script_install_psmodules, privileged: false end if copy_ssh_key diff --git a/wsl/pwsh_setup.ps1 b/wsl/pwsh_setup.ps1 index 1638c04b..e1979b00 100644 --- a/wsl/pwsh_setup.ps1 +++ b/wsl/pwsh_setup.ps1 @@ -21,8 +21,8 @@ begin { # set location to workspace folder Push-Location "$PSScriptRoot/.." - # import InstallUtils for the Invoke-GhRepoClone function - Import-Module (Resolve-Path './modules/InstallUtils') + # import utils-install for the Invoke-GhRepoClone function + Import-Module (Resolve-Path './modules/utils-install') # clone/refresh szymonos/powershell-scripts repository if (Invoke-GhRepoClone -OrgRepo 'szymonos/powershell-scripts' -Path '..') { diff --git a/wsl/wsl_certs_add.ps1 b/wsl/wsl_certs_add.ps1 index b8fbb22e..c7ee91c5 100644 --- a/wsl/wsl_certs_add.ps1 +++ b/wsl/wsl_certs_add.ps1 @@ -46,11 +46,17 @@ begin { # set location to workspace folder Push-Location "$PSScriptRoot/.." - # check if the required functions are available, otherwise import SetupUtils module + # check if the required functions are available, otherwise import utils-setup module try { Get-Command Get-WslDistro -CommandType Function | Out-Null } catch { - Import-Module (Resolve-Path './modules/SetupUtils') + Import-Module (Resolve-Path './modules/utils-setup') + } + # import do-common for the Get-Certificate and ConvertTo-PEM functions + try { + Get-Command Get-Certificate -CommandType Function | Out-Null + } catch { + Import-Module (Resolve-Path './modules/do-common') } # check if distro exist diff --git a/wsl/wsl_files_copy.ps1 b/wsl/wsl_files_copy.ps1 index e50c15cb..4b41b39e 100644 --- a/wsl/wsl_files_copy.ps1 +++ b/wsl/wsl_files_copy.ps1 @@ -65,8 +65,10 @@ begin { exit 0 } - # import SetupUtils for the Get-WslDistro function - Import-Module (Convert-Path './modules/SetupUtils') + # import utils-setup for the Get-WslDistro function + Import-Module (Convert-Path './modules/utils-setup') + # import do-common for the Get-ArrayIndexMenu function + Import-Module (Convert-Path './modules/do-common') # get list of existing WSL distros $distros = Get-WslDistro -FromRegistry diff --git a/wsl/wsl_install.ps1 b/wsl/wsl_install.ps1 index e28ffc81..5a1df2cd 100644 --- a/wsl/wsl_install.ps1 +++ b/wsl/wsl_install.ps1 @@ -40,6 +40,9 @@ Intercept and add certificates from chain into selected distro. Set network settings from the selected network interface in Windows. .PARAMETER SkipRepoUpdate Skip updating current repository before running the setup. +.PARAMETER WebDownload +Switch, whether to use web download for WSL distro installation instead of Microsoft Store. +This is useful when the Store download is very slow or unavailable. .EXAMPLE # :perform basic Ubuntu WSL setup @@ -83,7 +86,9 @@ param ( [switch]$FixNetwork, - [switch]$SkipRepoUpdate + [switch]$SkipRepoUpdate, + + [switch]$WebDownload ) begin { @@ -96,10 +101,12 @@ begin { # set location to workspace folder Push-Location "$PSScriptRoot/.." - # import InstallUtils for the Update-SessionEnvironmentPath function - Import-Module (Resolve-Path './modules/InstallUtils') -Force + # import utils-install for the Update-GitRepository function + Import-Module (Resolve-Path './modules/utils-install') -Force + # import psm-windows for the Update-SessionEnvironmentPath and Join-Str functions + Import-Module (Resolve-Path './modules/psm-windows') -Force - if (-not $SkipRepoUpdate) { + if (-not $PSBoundParameters.SkipRepoUpdate) { Write-Host 'checking if the repository is up to date...' -ForegroundColor Cyan if ((Update-GitRepository) -eq 2) { Write-Host "`nRun the script again!" -ForegroundColor Yellow @@ -159,15 +166,16 @@ process { # *Set up WSL # build command string $sb = [System.Text.StringBuilder]::new("wsl/wsl_setup.ps1 -Distro '$Distro'") - if ($Scope) { + if ($PSBoundParameters.Scope) { $scopeStr = $Scope | Join-Str -Separator ',' -SingleQuote $sb.Append(" -Scope @($scopeStr,'shell')") | Out-Null } - if ($Repos) { + if ($PSBoundParameters.Repos) { $reposStr = $Repos | Join-Str -Separator ',' -SingleQuote $sb.Append(" -Repos @($reposStr)") | Out-Null } - if ($AddCertificate) { $sb.Append(' -AddCertificate') | Out-Null } + if ($PSBoundParameters.AddCertificate) { $sb.Append(' -AddCertificate') | Out-Null } + if ($PSBoundParameters.WebDownload) { $sb.Append(' -WebDownload') | Out-Null } $sb.Append(" -OmpTheme 'base'") | Out-Null $sb.Append(' -SkipRepoUpdate') | Out-Null # run the wsl_setup script diff --git a/wsl/wsl_network_fix.ps1 b/wsl/wsl_network_fix.ps1 index 02f6ef16..3c840604 100644 --- a/wsl/wsl_network_fix.ps1 +++ b/wsl/wsl_network_fix.ps1 @@ -55,8 +55,10 @@ begin { # set location to workspace folder Push-Location "$PSScriptRoot/.." - # import SetupUtils module - Import-Module (Resolve-Path './modules/SetupUtils') + # import utils-setup for the Get-WslDistro and Set-WslConf functions + Import-Module (Resolve-Path './modules/utils-setup') + # import do-common for the Get-ArrayIndexMenu function + Import-Module (Resolve-Path './modules/do-common') # check if distro exist $distros = Get-WslDistro -FromRegistry diff --git a/wsl/wsl_setup.ps1 b/wsl/wsl_setup.ps1 index 20dc81b0..667ce52c 100644 --- a/wsl/wsl_setup.ps1 +++ b/wsl/wsl_setup.ps1 @@ -49,6 +49,9 @@ Intercept and add certificates from chain into selected distro. Set network settings from the selected network interface in Windows. .PARAMETER SkipRepoUpdate Skip updating current repository before running the setup. +.PARAMETER WebDownload +Switch, whether to use web download for WSL distro installation instead of Microsoft Store. +This is useful when the Store download is very slow or unavailable. .EXAMPLE $Distro = 'Ubuntu' @@ -69,7 +72,7 @@ $OmpTheme = 'nerd' wsl/wsl_setup.ps1 $Distro -s $Scope -o $OmpTheme wsl/wsl_setup.ps1 $Distro -s $Scope -o $OmpTheme -AddCertificate # :set up WSL distro and clone specified GitHub repositories -$Repos = @('szymonos/linux-setup-scripts', 'szymonos/ps-modules') +$Repos = @('szymonos/linux-setup-scripts') wsl/wsl_setup.ps1 $Distro -r $Repos -s $Scope -o $OmpTheme wsl/wsl_setup.ps1 $Distro -r $Repos -s $Scope -o $OmpTheme -AddCertificate # :update all existing WSL distros @@ -127,7 +130,9 @@ param ( [Parameter(ParameterSetName = 'GitHub')] [switch]$FixNetwork, - [switch]$SkipRepoUpdate + [switch]$SkipRepoUpdate, + + [switch]$WebDownload ) begin { @@ -140,10 +145,12 @@ begin { # set location to workspace folder Push-Location "$PSScriptRoot/.." - # import InstallUtils for the Invoke-GhRepoClone function - Import-Module (Convert-Path './modules/InstallUtils') -Force - # import SetupUtils for the Set-WslConf function - Import-Module (Convert-Path './modules/SetupUtils') -Force + # import utils-install for the Update-GitRepository function + Import-Module (Convert-Path './modules/utils-install') -Force + # import utils-setup for the Get-WslDistro and Set-WslConf functions + Import-Module (Convert-Path './modules/utils-setup') -Force + # import do-common for the Show-LogContext, Test-IsAdmin, and Get-ArrayIndexMenu functions + Import-Module (Convert-Path './modules/do-common') -Force if (-not $SkipRepoUpdate) { Show-LogContext 'checking if the repository is up to date' @@ -156,6 +163,10 @@ begin { # *get list of distros $lxss = Get-WslDistro | Where-Object Name -NotMatch '^docker-desktop' if ($PsCmdlet.ParameterSetName -ne 'Update') { + $installArgs = [System.Collections.Generic.List[string]]::new([string[]]@('--install', '--distribution', $Distro)) + if ($PSBoundParameters.WebDownload) { + $installArgs.Add('--web-download') + } if ($Distro -notin $lxss.Name) { for ($i = 0; $i -lt 5; $i++) { if ($onlineDistros = Get-WslDistro -Online) { break } @@ -165,10 +176,10 @@ begin { Show-LogContext "specified distribution not found ($Distro), proceeding to install" try { Get-Service WSLService | Out-Null - wsl.exe --install --distribution $Distro --no-launch + wsl.exe @installArgs --no-launch if ($? -and $Distro -notin (Get-WslDistro -FromRegistry).Name) { Write-Host "`nSetting up user profile in WSL distro. Type 'exit' when finished to proceed with WSL setup!`n" -ForegroundColor Yellow - wsl.exe --install --distribution $Distro + wsl.exe @installArgs } if (-not $?) { Show-LogContext "`"$Distro`" distro installation failed." -Level ERROR @@ -176,7 +187,7 @@ begin { } } catch { if (Test-IsAdmin) { - wsl.exe --install --distribution $Distro + wsl.exe @installArgs if ($?) { Show-LogContext 'WSL service installation finished.' Show-LogContext "`nRestart the system and run the script again to install the specified WSL distro!`n" -Level WARNING @@ -186,7 +197,7 @@ begin { } } else { Show-LogContext "`nInstalling WSL service. Wait for the process to finish and restart the system!`n" -Level WARNING - Start-Process pwsh.exe "-NoProfile -Command `"wsl.exe --install --distribution $Distro`"" -Verb RunAs + Start-Process pwsh.exe "-NoProfile -Command `"wsl.exe $($installArgs -join ' ')`"" -Verb RunAs if ($?) { Show-LogContext 'WSL service installation finished.' Show-LogContext "`nRestart the system and run the script again to install the specified WSL distro!`n" -Level WARNING @@ -237,7 +248,7 @@ begin { break } } - wsl.exe --install --distribution $Distro --no-launch + wsl.exe @installArgs --no-launch } } Show-LogContext 'getting GitHub authentication config from the default distro' @@ -500,19 +511,6 @@ process { $sshStatus.sshKey = 'missing' } } - - # *whitelist Windows-mount repo paths as git safe.directory - # On /mnt/c/ paths the .git dir owner UID (from the Windows side) - # doesn't match the WSL user's UID, so git refuses operations with a - # "dubious ownership" warning. Two globs cover the typical layouts: - # ~/source/repos/ - flat - # ~/source/repos// - org-scoped (the convention here) - # Per-user (writes ~/.gitconfig in the WSL user's home), idempotent. - $mntRepos = "/mnt/c/Users/$env:USERNAME/source/repos" - foreach ($glob in "$mntRepos/*", "$mntRepos/*/*") { - $cmnd = "git config --global --get-all safe.directory 2>/dev/null | grep -qFx '$glob' || git config --global --add safe.directory '$glob'" - wsl.exe --distribution $Distro --exec bash -c $cmnd | Out-Null - } #endregion #region install scopes @@ -613,31 +611,27 @@ process { Show-LogContext 'setting up profile for current user' wsl.exe --distribution $Distro --exec .assets/provision/setup_profile_user.ps1 - # *install PowerShell modules from ps-modules repository - # clone/refresh szymonos/ps-modules repository - $repoClone = Invoke-GhRepoClone -OrgRepo 'szymonos/ps-modules' -Path '..' - if ($repoClone) { - Write-Verbose "Repository `"ps-modules`" $($repoClone -eq 1 ? 'cloned': 'refreshed') successfully." - } else { - Write-Error 'Cloning ps-modules repository failed.' - } + # *install PowerShell modules from local modules directory Show-LogContext 'installing ps-modules' Write-Host "`e[32mAllUsers :`e[0;90m do-common`e[0m" - wsl.exe --distribution $Distro --user root --exec ../ps-modules/module_manage.ps1 'do-common' -CleanUp + $allUsersCmd = 'mkdir -p /usr/local/share/powershell/Modules && rm -rf /usr/local/share/powershell/Modules/do-common && cp -rf modules/do-common /usr/local/share/powershell/Modules/' + wsl.exe --distribution $Distro --user root --exec sh -c $allUsersCmd # instantiate psmodules generic lists $modules = [System.Collections.Generic.SortedSet[String]]::new([string[]]@('aliases-git', 'do-linux')) # determine modules to install if ('az' -in $scopes) { $modules.Add('do-az') | Out-Null - Write-Verbose "Added `e[3mdo-az`e[23m to be installed from ps-modules." + Write-Verbose "Added `e[3mdo-az`e[23m to be installed." } if ('k8s_base' -in $scopes) { $modules.Add('aliases-kubectl') | Out-Null - Write-Verbose "Added `e[3maliases-kubectl`e[23m to be installed from ps-modules." + Write-Verbose "Added `e[3maliases-kubectl`e[23m to be installed." } Write-Host "`e[32mCurrentUser :`e[0;90m $($modules -join ', ')`e[0m" - $cmd = "@($($modules | Join-String -SingleQuote -Separator ',')) | ../ps-modules/module_manage.ps1 -CleanUp" - wsl.exe --distribution $Distro --exec pwsh -nop -c $cmd + $srcs = ($modules.ForEach({ "modules/$_" })) -join ' ' + $rms = ($modules.ForEach({ "`$HOME/.local/share/powershell/Modules/$_" })) -join ' ' + $userCmd = "mkdir -p `$HOME/.local/share/powershell/Modules && rm -rf $rms && cp -rf $srcs `$HOME/.local/share/powershell/Modules/" + wsl.exe --distribution $Distro --exec sh -c $userCmd # *install PowerShell Az modules if ('az' -in $scopes) { $cmd = [string]::Join("`n", diff --git a/wsl/wsl_systemd.ps1 b/wsl/wsl_systemd.ps1 index 782bfbdd..29075065 100644 --- a/wsl/wsl_systemd.ps1 +++ b/wsl/wsl_systemd.ps1 @@ -51,8 +51,8 @@ begin { # set location to workspace folder Push-Location "$PSScriptRoot/.." - # import SetupUtils module - Import-Module (Resolve-Path './modules/SetupUtils') + # import utils-setup module + Import-Module (Resolve-Path './modules/utils-setup') # check if distro exist $distros = Get-WslDistro -FromRegistry diff --git a/wsl/wsl_wslg.ps1 b/wsl/wsl_wslg.ps1 index 4013a4a2..3574f1d6 100644 --- a/wsl/wsl_wslg.ps1 +++ b/wsl/wsl_wslg.ps1 @@ -35,8 +35,8 @@ begin { # set location to workspace folder Push-Location "$PSScriptRoot/.." - # import SetupUtils module - Import-Module (Resolve-Path './modules/SetupUtils') + # import do-common for the ConvertFrom-Cfg and ConvertTo-Cfg functions + Import-Module (Resolve-Path './modules/do-common') } process {