Public/Get-Enum.ps1

<#
 
# Get-Enum
 
Für die Analyse, Finden bzw. Nachschlagen von Enumerationen hilfreich
 
- **Hashtags** Cmdlet Enum
- **Version** 2019.11.14
 
#>


using namespace System
using namespace System.Runtime.InteropServices
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
Set-StrictMode -Version Latest

function Get-Enum {
    param (
        [string]$Value,
        [String]$Name,
        [switch]$All
    )
    $defaultManifestModules = 'CommonLanguageRuntimeLibrary', 
                              'Microsoft.CSharp.dll', 
                              'Microsoft.Management.Infrastructure.dll', 
                              'Microsoft.PowerShell.Commands.Management.dll', 
                              'Microsoft.PowerShell.commands.Utility.dll', 
                              'System.dll', 
                              'System.Configuration.dll',
                              'System.Configuration.Install.dll',
                              'System.Core.dll', 
                              'System.Data.dll', 
                              'System.DirectoryServices.dll', 
                              'System.Management.Automation.dll', 
                              'System.Management.dll',
                              'System.ServiceProcess.dll',
                              'System.Transactions.dll', 
                              'System.Xml.dll'
    
    [System.AppDomain]::CurrentDomain.GetAssemblies() | 
        Where-Object -FilterScript {$All -or ($defaultManifestModules -contains $_.ManifestModule)} |
        ForEach-Object -Process { try { $_.GetExportedTypes() } catch { "Keine ExportedTypes vorhanden" | Write-Verbose } } |
        Where-Object -FilterScript { $_.IsEnum -and $_.Name -imatch $Name } |
        ForEach-Object -Process {
            return [PSCustomObject]@{
                Name   = $_.FullName
                Source = $_.Module.ScopeName
                Values = [System.Enum]::GetNames($_)
            }
        } |
        Where-Object -Property Values -imatch -Value $Value
  }