Merge pull request #305 from Icinga:feature/add_test_for_types

Feature: Add test function for add type
This commit is contained in:
Lord Hepipud 2021-07-16 11:06:06 +02:00 committed by GitHub
commit 9db417b5b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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;
}