Add test function for add type

This commit is contained in:
Lord Hepipud 2021-07-16 10:59:59 +02:00
parent 25d539e1f8
commit 23041ef59f
2 changed files with 20 additions and 0 deletions

View file

@ -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) [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) ## 1.5.2 (2021-07-09)
### Security Fixes ### Security Fixes

View file

@ -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;
}