Script directory for a PowerShell profile. https://blog.lksz.me/keeping-track-of-everything/#-mypsscriptroot
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

Get-MyAliases.ps1 650 B

1234567891011121314151617181920212223242526
  1. [CmdletBinding(SupportsShouldProcess)]param()
  2. $local:allAliases = @()
  3. $MyAliasScope = 0
  4. $local:_scope = 0
  5. $local:_done = $false
  6. do {
  7. try {
  8. $local:newAliases += Get-Alias -Scope $_scope |
  9. Where-Object {
  10. ($_.Definition -match "^$MyPSScriptRoot") -or ($_.Description -match '#MyAlias')
  11. }
  12. if( $newAliases ) {
  13. $allAliases += $newAliases
  14. $MyAliasScope = $_scope;
  15. Write-Verbose "`$MyAliasScope is now set to $MyAliasScope"
  16. }
  17. } catch {
  18. Write-Verbose "catch: $($_.Exception.Message)"
  19. $_done = $_.Exception.Message -match 'The scope .* exceeds'
  20. }
  21. $_scope += 1
  22. } until ( $_done )
  23. $allAliases