From 1fa768f365249d7b47fb5026b662b3dab4404f26 Mon Sep 17 00:00:00 2001 From: Tess Gauthier Date: Fri, 21 Jan 2022 14:33:53 -0500 Subject: [PATCH] detect add-type edge case with powershell 7 (#554) --- contrib/win32/openssh/OpenSSHUtils.psm1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contrib/win32/openssh/OpenSSHUtils.psm1 b/contrib/win32/openssh/OpenSSHUtils.psm1 index c7cbdf8e8..e70afd0d7 100644 --- a/contrib/win32/openssh/OpenSSHUtils.psm1 +++ b/contrib/win32/openssh/OpenSSHUtils.psm1 @@ -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