detect add-type edge case with powershell 7 (#554)

This commit is contained in:
Tess Gauthier 2022-01-21 14:33:53 -05:00 committed by GitHub
parent af7130c91b
commit 1fa768f365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -95,7 +95,15 @@ public class AdjPriv
}
'@
$type = Add-Type $definition -PassThru -ErrorAction SilentlyContinue
try
{
$type = Add-Type $definition -PassThru -ErrorAction SilentlyContinue
}
catch
{
# Powershell 7 does not add a type if it already exists
$type = [AdjPriv]
}
<#
.Synopsis