From b8a2d9efde613e92232e146f50fb49ffb04360f6 Mon Sep 17 00:00:00 2001 From: James Stringer <38541878+jamesstringerparsec@users.noreply.github.com> Date: Sun, 21 Nov 2021 04:46:32 -0800 Subject: [PATCH] Fix compatibility with Powershell 7+ --- CopyFilesToVM.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CopyFilesToVM.ps1 b/CopyFilesToVM.ps1 index 2eea552..0662c91 100644 --- a/CopyFilesToVM.ps1 +++ b/CopyFilesToVM.ps1 @@ -4210,8 +4210,13 @@ VirtualHardDisk #endregion VHD Interop } "@ - + #ifdef for Powershell V7 or greater which looks for assemblies in same path as powershell dll path + if ($PSVersionTable.psversion.Major -ge 7){ + Add-Type -TypeDefinition $code -ErrorAction SilentlyContinue + } + else { Add-Type -TypeDefinition $code -ReferencedAssemblies "System.Xml","System.Linq","System.Xml.Linq" -ErrorAction SilentlyContinue + } } Function Modify-AutoUnattend {