PowerShellBuddy.psm1
using namespace System.Management.Automation [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalFunctions', '')] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '')] param() #region Public Cmdlets-Code ausführen Get-ChildItem "$PSScriptRoot\Public\*.ps1" -PipelineVariable cmdlet -Exclude '*.Tests.ps1' | ForEach-Object -Process { . $cmdlet.FullName } #endregion #region Aliase definieren New-Alias -Name 'gh' -Value 'Get-Help' #endregion #region Argument Completer Register-ArgumentCompleter -Native -CommandName WinGet -ScriptBlock { param($wordToComplete, $commandAst, $cursorPosition) [Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new() $Local:word = $wordToComplete.Replace('"', '""') $Local:ast = $commandAst.ToString().Replace('"', '""') WinGet.exe complete --word="$Local:word" --commandline "$Local:ast" --position $cursorPosition | ForEach-Object { [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) } } #endregion #region Aufräumarbeiten bei Remove-Module -Name AKPT $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = { Remove-TypeData -TypeName 'System.Object' -ErrorAction 'Ignore' 'alias:\gea', 'alias:\gbf', 'alias:\gee', 'alias:\gpi', 'alias:\gti' | Remove-Item -Force -ErrorAction 'Ignore' } #endregion |