Skip to content

Instantly share code, notes, and snippets.

@BladeFireLight
Last active Mar 19, 2019
Embed
What would you like to do?
Write-Warning "Starting Deployment"
######################
#
# David Jones
# @BladefireLight
######################
# thanks to Steve Kearney for his Scripting Guys blog where alot of this comes from
$WinPETemp = 'C:\TempPE'
function Get-ArchitectureString
{
$Arch = (Get-CimInstance win32_operatingsystem).OSArchitecture
if ($Arch -eq '64-Bit')
{
Return [string]' (x86)'
}
}
$WinADK = "C:\Program Files$(Get-ArchitectureString)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\"
if (-not(Test-Path $WinADK))
{
'throw Windows 10 Assessment and Deployment kit must be installed'
}
$WinADKTools = "$WinADK\..\..\Deployment Tools\amd64"
#region Populate WinPETemp
New-Item -ItemType Directory -Path $WinPETemp -Force
Copy-Item -Path "$WinADK\Media" -Destination $WinPETemp -Recurse -Force
New-Item -ItemType Directory -Path "$WinPETemp\Media\Sources" -Force
Copy-Item -Path "$WinADK\en-us\winpe.wim" -Destination "$WinPETemp\Media\Sources\boot.wim"
Copy-Item -Path "$WinADKTools\Oscdimg\efisys.bin" -Destination "$WinPETemp\efisys.bin"
New-Item -ItemType Directory -Path $WinPETemp\Mount -Force
#endregion
#Mount and update boot WIM
Mount-WindowsImage -ImagePath "$WinPETemp\Media\Sources\boot.wim" -Index 1 -Path "$WinPETemp\Mount"
#region Add packages
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\WinPE-WMI.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\en-us\WinPE-WMI_en-us.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\WinPE-NetFx.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\en-us\WinPE-NetFx_en-us.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\WinPE-Scripting.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\en-us\WinPE-Scripting_en-us.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\WinPE-PowerShell.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\en-us\WinPE-PowerShell_en-us.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\WinPE-DismCmdlets.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\en-us\WinPE-DismCmdlets_en-us.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\WinPE-EnhancedStorage.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\en-us\WinPE-EnhancedStorage_en-us.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\WinPE-StorageWMI.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
Add-WindowsPackage -PackagePath "$($WinADK)\Winpe_OCS\en-us\WinPE-StorageWMI_en-us.cab" -Path "$WinPETemp\Mount" -IgnoreCheck
#endregion
#region Add Certificates to Registry
$root1 = @{
thumbprint = '2214BD84320227996E6D9001B9A427D0A4F70133'
Blob = ([byte[]](0x5c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x60, 0x34, 0x3b, 0x29, 0xdf, 0x72, 0x0b, 0x88, 0x19, 0x9e, 0x35, 0x8b, 0x3b, 0xcd, 0xd2, 0xd9, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1d, 0x6d, 0xdf, 0x9c, 0xc3, 0xe2, 0x61, 0xfb, 0x60, 0x1b, 0xf6, 0xe0, 0x8f, 0x74, 0x0e, 0x0d, 0x40, 0x31, 0xbd, 0x29, 0x85, 0xb2, 0x9f, 0xae, 0x97, 0x8a, 0x80, 0x16, 0x75, 0xf9, 0x54, 0x51, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x22, 0x14, 0xbd, 0x84, 0x32, 0x02, 0x27, 0x99, 0x6e, 0x6d, 0x90, 0x01, 0xb9, 0xa4, 0x27, 0xd0, 0xa4, 0xf7, 0x01, 0x33, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xf6, 0x5c, 0xf2, 0x52, 0x86, 0x72, 0x5c, 0x8d, 0x33, 0x7d, 0x2a, 0x41, 0x0e, 0xbf, 0x4f, 0x14, 0xe8, 0x5c, 0xa1, 0xee, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x34, 0x7b, 0x99, 0x11, 0xaa, 0x5e, 0x2d, 0xe2, 0x47, 0xf9, 0x3f, 0x2f, 0x45, 0x47, 0x19, 0x44, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x05, 0x00, 0x00, 0x30, 0x82, 0x05, 0x44, 0x30, 0x82, 0x03, 0x2c, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x71, 0x55, 0x0b, 0xdc, 0x9e, 0x8f, 0x8b, 0x93, 0x4c, 0x66, 0xf9, 0x4a, 0x06, 0x43, 0x14, 0xcd, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x21, 0x31, 0x1f, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x16, 0x50, 0x69, 0x6e, 0x6e, 0x61, 0x63, 0x65, 0x42, 0x61, 0x6e, 0x63, 0x6f, 0x72, 0x70, 0x2d, 0x43, 0x41, 0x2d, 0x52, 0x6f, 0x6f, 0x74, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x34, 0x30, 0x34, 0x30, 0x38, 0x31, 0x34, 0x34, 0x39, 0x31, 0x31, 0x5a, 0x17, 0x0d, 0x32, 0x36, 0x30, 0x34, 0x30, 0x38, 0x31, 0x34, 0x35, 0x39, 0x31, 0x30, 0x5a, 0x30, 0x21, 0x31, 0x1f, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x16, 0x50, 0x69, 0x6e, 0x6e, 0x61, 0x63, 0x65, 0x42, 0x61, 0x6e, 0x63, 0x6f, 0x72, 0x70, 0x2d, 0x43, 0x41, 0x2d, 0x52, 0x6f, 0x6f, 0x74, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00, 0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, 0x02, 0x01, 0x00, 0xf7, 0x02, 0x7a, 0xce, 0x59, 0xed, 0xa5, 0x13, 0xd8, 0x88, 0xf3, 0xaa, 0xf7, 0x03, 0xdd, 0x12, 0xb3, 0xbf, 0x85, 0xac, 0xdc, 0x60, 0x8b, 0x5a, 0x05, 0x09, 0xeb, 0xd8, 0x59, 0xd8, 0xbd, 0x34, 0x3a, 0x94, 0x68, 0x3b, 0xbe, 0x3b, 0x0d, 0x05, 0xef, 0xe3, 0x58, 0x2b, 0x25, 0x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xc7, 0xd6, 0x6c, 0xae, 0xf7, 0x10, 0x96, 0x0a, 0x5e, 0x06, 0x24, 0xf1, 0x1b, 0x8d, 0x25, 0x8a, 0x13, 0x0f, 0x44, 0x63, 0x55, 0x80, 0xb3, 0xbc, 0x6c, 0x3b, 0x42, 0xd8, 0x0a, 0xc1, 0x12, 0xb6, 0x01, 0xe0, 0x85, 0xa2, 0x36, 0x92, 0x59, 0xa1, 0x86, 0x4d, 0xeb, 0x9d, 0xba, 0x4b, 0x0c, 0x0e, 0x20, 0x83, 0x5a, 0x18, 0xfb, 0x44, 0xd2, 0xa6, 0x54, 0xda, 0x31, 0x34, 0x93, 0x9d, 0x96, 0xc0, 0xa1, 0xbe, 0xd1, 0x50, 0x86, 0x28, 0xc6, 0x59, 0x5d, 0xd0, 0xd4, 0x9b, 0xac, 0x02, 0x39, 0x16, 0x24, 0xf8, 0x0e, 0x5c, 0x14, 0x2c, 0x35, 0xb8, 0x94, 0xed, 0x77, 0xe8, 0x44, 0x39, 0x4a, 0x64, 0xb9, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x78, 0x30, 0x76, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02, 0x01, 0x86, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xf6, 0x5c, 0xf2, 0x52, 0x86, 0x72, 0x5c, 0x8d, 0x33, 0x7d, 0x2a, 0x41, 0x0e, 0xbf, 0x4f, 0x14, 0xe8, 0x5c, 0xa1, 0xee, 0x30, 0x12, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x15, 0x01, 0x04, 0x05, 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x23, 0x06, 0x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2b, 0x83, 0xeb, 0x74, 0xff, 0x94, 0x26, 0xce, 0xcc, 0x0e, 0xb1, 0x9a))
}
$root2 = @{
thumbprint = '6EABF9503898CD6D5E6F4E7ED53958BC794972D1'
Blob = ([byte[]](0x5c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x72, 0x95, 0x74, 0xc4, 0xa1, 0x79, 0x2a, 0xd0, 0x61, 0x49, 0x28, 0xe0, 0xac, 0x29, 0x17, 0xe9, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x8f, 0xf4, 0x2d, 0x46, 0x18, 0x6d, 0x85, 0xc1, 0x78, 0xe1, 0xf8, 0x78, 0xed, 0x38, 0x32, 0xf4, 0x60, 0x87, 0x48, 0xbd, 0x39, 0x68, 0xdd, 0x00, 0xfb, 0x8c, 0xa4, 0x4d, 0x67, 0x60, 0x19, 0xf4, 0x0a, 0x25, 0x44, 0xa3, 0x4a, 0xd0, 0xe4, 0x78, 0xed, 0x49, 0x7d, 0xdb, 0x0c, 0xb9, 0x6b, 0x64, 0x66, 0xa1, 0xd7, 0x67, 0x14, 0xa0, 0xd8, 0x94, 0xbd, 0x98, 0x9d, 0x65, 0xc9, 0xe9, 0x0c, 0xad, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x6e, 0xab, 0xf9, 0x50, 0x38, 0x98, 0xcd, 0x6d, 0x5e, 0x6f, 0x4e, 0x7e, 0xd5, 0x39, 0x58, 0xbc, 0x79, 0x49, 0x72, 0xd1, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x2d, 0xdf, 0x5a, 0x63, 0x7b, 0xf2, 0xcf, 0x11, 0xd1, 0x7c, 0x89, 0x1f, 0x36, 0xfc, 0xf4, 0x2c, 0x02, 0x56, 0xcb, 0xd3, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xfe, 0x7e, 0xab, 0x40, 0x9f, 0xb5, 0xb2, 0x6e, 0x3f, 0x3a, 0xe1, 0x02, 0xbc, 0x61, 0xde, 0xe7, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x21, 0x05, 0x00, 0x00, 0x30, 0x82, 0x05, 0x1d, 0x30, 0x82, 0x03, 0x05, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x31, 0x48, 0x36, 0x19, 0x17, 0xe3, 0xdb, 0xb0, 0x46, 0x88, 0x90, 0x3e, 0x97, 0x08, 0xec, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0d, 0x05, 0x00, 0x30, 0x21, 0x31, 0x1f, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x16, 0x50, 0x69, 0x6e, 0x6e, 0x61, 0x63, 0x65, 0x42, 0x61, 0x6e, 0x63, 0x6f, 0x72, 0x70, 0x2d, 0x43, 0x41, 0x2d, 0x52, 0x6f, 0x6f, 0x74, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x33, 0x30, 0x37, 0x33, 0x31, 0x32, 0x31, 0x31, 0x34, 0x30, 0x33, 0x5a, 0x17, 0x0d, 0x32, 0x35, 0x30, 0x37, 0x33, 0x31, 0x32, 0x31, 0x32, 0x34, 0x30, 0x32, 0x5a, 0x30, 0x21, 0x31, 0x1f, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x16, 0x50, 0x69, 0x6e, 0x6e, 0x61, 0x63, 0x65, 0x42, 0x61, 0x6e, 0x63, 0x6f, 0x72, 0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0x01, 0xa3, 0x51, 0x30, 0x4f, 0x30, 0x0b, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x04, 0x04, 0x03, 0x02, 0x01, 0x86, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x2d, 0xdf, 0x5a, 0x63, 0x7b, 0xf2, 0xcf, 0x11, 0xd1, 0x7c, 0x89, 0x1f, 0x36, 0xfc, 0xf4, 0x2c, 0x02, 0x56, 0xcb, 0xd3, 0x30, 0x10, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x15, 0x01, 0x04, 0x03, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0d, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x38, 0x6d, 0x95, 0x6e, 0xe3, 0xe5, 0xa9, 0xd2, 0x1a, 0xfd, 0x45, 0x8e, 0x83, 0xc2, 0xdc, 0xf9, 0x55, 0x50, 0xaa, 0x68, 0xd5, 0xc2, 0x78, 0x16, 0x53, 0xe7, 0x97, 0xff, 0xe5, 0xd7, 0xdf, 0x4a, 0x68, 0x19, 0x33, 0x23, 0x7c, 0xa9, 0x8d, 0x56, 0x47, 0xc0, 0x84, 0x30, 0x7c, 0x49, 0xce, 0x2b, 0xca, 0x06, 0xbb, 0xd9, 0x25, 0x16, 0x54, 0x47, 0xc2, 0x6b, 0x8f, 0xd8, 0xe2, 0x82, 0x40, 0x9b, 0x57, 0x50, 0xe2, 0xc5, 0x54, 0xff, 0x59, 0x54, 0x90, 0x09, 0x72, 0x85, 0xdc, 0x88, 0xab, 0xe1, 0xdc, 0xad, 0xe2, 0x97, 0xb0, 0xba, 0xd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 0x7e, 0x9e, 0x38, 0xbf, 0x6f, 0xde, 0x69, 0x7f, 0xe4, 0xed, 0xdf, 0x6b, 0xb9, 0x0e, 0xb4, 0xe1, 0x91, 0xf1, 0x5f, 0xfc, 0x29, 0x21, 0x41, 0xea, 0xd6, 0x9d, 0xe8, 0x52, 0x93, 0x09, 0x78, 0xf4, 0xa5, 0xca, 0x65, 0x58, 0xb1, 0x5b, 0x9a, 0xcb, 0x15, 0x95, 0xa9, 0xd5, 0xc2, 0x43, 0xa3, 0x57, 0xb2, 0x2d, 0x80, 0x4d, 0x90, 0xf4))
}
## online Key path HKLM:\Software\Microsoft\Enterprise\Certificates\Root\Certificates
$CertKey = 'HKLM:\temp\Microsoft\EnterpriseCertificates\Root\Certificates'
reg.exe LOAD HKLM\TEMP "$WinPETemp\Mount\WINDOWS\SYSTEM32\CONFIG\SOFTWARE"
New-Item -Path $CertKey -Name $root1.thumbprint
New-ItemProperty -Path "$CertKey\$($root1.thumbprint)" -Name Blob -PropertyType Binary -Value $root1.Blob
New-Item -Path $CertKey -Name $root2.thumbprint
New-ItemProperty -Path "$CertKey\$($root2.thumbprint)" -Name Blob -PropertyType Binary -Value $root2.Blob
#fix for Access denied uloading registry
0
[gc]::collect()
# end fix
reg.exe UNLOAD HKLM\TEMP
#endregion
#region Replace STartnet to run Powershell and create function
$STartNetContent = {
echo off
wpeinit
powershell.exe -ExecutionPolicy Bypass -NoExit -file x:\WINDOWS\SYSTEM32\function.ps1
}
$FunctionContent = {
function Get-BuildScript
{
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]
$Script,
[string]
$Path = 'x:\Start.ps1',
#[Parameter(Mandatory = $true,HelpMessage = 'User with access to TFS')]
[System.Management.Automation.Credential()]
[PSCredential]
$credintial
)
if ($credential) {
$params = @{
UseBasicParsing = $true
Credential = $credintial
MaximumRedirection = 0
ErrorAction = 'SilentlyContinue'
}
$response = Invoke-WebRequest @params -Uri $script
Invoke-WebRequest -UseBasicParsing -Uri $response.Headers.Location -Credential $credintial -OutFile $Path
}
else
{
$params = @{
UseBasicParsing = $true
MaximumRedirection = 0
ErrorAction = 'SilentlyContinue'
}
$response = Invoke-WebRequest @params -Uri $script
Invoke-WebRequest -UseBasicParsing -Uri $response.Headers.Location -OutFile $Path
}
}
#Get-BuildScript -Script 'http://bit.ly/SummitDeploy'
#Write-Output -InputObject 'NewBranch build script saved to x:\start.ps1'
Write-Output -InputObject "Get-BuildScript -Script 'http://bit.ly/SummitDeploy' to download the build script, then run x:\start.ps1"
}
Set-Content -Path "$WinPETemp\Mount\WINDOWS\SYSTEM32\Startnet.cmd" -Value $STartNetContent
Set-Content -Path "$WinPETemp\Mount\WINDOWS\SYSTEM32\function.ps1" -Value $FunctionContent
#endregion
Dismount-WindowsImage -Path "$WinPETemp\Mount" -Save
#END Mount and update WIM
# create ISO
& "$WinADKTools\Oscdimg\oscdimg.exe" -b"$($WinPETemp)\efisys.bin" -pEF -u1 -udfver102 $WinPETemp\media $WinPETemp\Deploy.iso 2> $null
#region setup USB
{
$Disk = Get-Disk |
Where-Object -FilterScript {
$_.BusType -eq 'USB'
} |
Out-GridView -PassThru
Get-Disk -Number ($Disk.number) |
Get-Partition |
Remove-Partition -confirm:$false -ErrorAction SilentlyContinue
Clear-Disk -Number $Disk.Number -RemoveData -RemoveOEM -confirm:$false -ErrorAction SilentlyContinue
Initialize-Disk -Number $Disk.Number -PartitionStyle MBR -ErrorAction SilentlyContinue
$OSDrive = 'Z'
$Partition = New-Partition -DiskNumber $Disk.Number -DriveLetter $OSDrive -UseMaximumSize -IsActive
Format-Volume -Partition $Partition -FileSystem FAT32 -NewFileSystemLabel 'WinPE'
Copy-Item "$WinADK\Media" -Path -Destination "$($OSDrive):" -Recurse
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment