diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index 5b1d5ec..742f5ed 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -11,6 +11,8 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic [Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/15?closed=1) +* [#305](https://github.com/Icinga/icinga-powershell-framework/pull/305) Adds a new Cmdlet to test if functions with `Add-Type` are already present inside the current scope of the shell + ## 1.5.2 (2021-07-09) ### Security Fixes diff --git a/lib/core/tools/Test-IcingaAddTypeExist.psm1 b/lib/core/tools/Test-IcingaAddTypeExist.psm1 new file mode 100644 index 0000000..0c5fa7e --- /dev/null +++ b/lib/core/tools/Test-IcingaAddTypeExist.psm1 @@ -0,0 +1,18 @@ +function Test-IcingaAddTypeExist() +{ + param ( + [string]$Type = $null + ); + + if ([string]::IsNullOrEmpty($Type)) { + return $FALSE; + } + + foreach ($entry in [System.AppDomain]::CurrentDomain.GetAssemblies()) { + if ($entry.GetTypes() -Match $Type) { + return $TRUE; + } + } + + return $FALSE; +}