Skip to content

Instantly share code, notes, and snippets.

@turboBasic
Last active October 9, 2017 12:57
Show Gist options
  • Save turboBasic/f73a1028f08ecc596f8943ea7866faa8 to your computer and use it in GitHub Desktop.
Save turboBasic/f73a1028f08ecc596f8943ea7866faa8 to your computer and use it in GitHub Desktop.
[Windows ADK Environment] Creates environment for Windows 10 ADK #powershell #windows #deployment
Function New-WindowsSetupISO {
Param(
[Parameter(
Mandatory = $false
)]
[alias( 'sourcePath' )]
[string] $Path = '.',
[Parameter(
Mandatory,
Position = 0
)]
[string] $isoFile
)
$base = "c:\1_windows"
. $base\Invoke-WADKenvironment.ps1
$bootData = "2#p0,e,b${Path}\..\fwfiles\etfsboot.com#pEF,e,b${Path}\..\fwfiles\efisys.bin"
OsCdImg.exe -m -o -u2 -udfver102 -bootdata:$bootData $Path $isoFile
}
$Root = "HKLM:\Software\Microsoft\Windows Kits\Installed Roots"
$Root6432 = "HKLM:\Software\Wow6432Node\Microsoft\Windows Kits\Installed Roots"
# Sets the PROCESSOR_ARCHITECTURE according to native platform for x86 and x64.
if( $ENV:PROCESSOR_ARCHITECTURE -eq 'x86' ) {
if( $ENV:PROCESSOR_ARCHITEW6432 ) {
$PROCESSOR_ARCHITECTURE = $ENV:PROCESSOR_ARCHITEW6432
}
} elseif( $ENV:PROCESSOR_ARCHITECTURE -ne 'amd64' ) {
"Not implemented for PROCESSOR_ARCHITECTURE of ${ENV:PROCESSOR_ARCHITECTURE}." | Write-Warning
"Using ${ENV:ProgramFiles}" | Write-Warning
$NewPath = ${ENV:ProgramFiles}
$ENV:Path = "$NewPath;${ENV:Path}"
Exit
}
# Query the 32-bit and 64-bit Registry hive for KitsRoot
$regKeyPathFound = $true
$wowRegKeyPathFound = $true
$KitsRootRegValueName = "KitsRoot10"
if( -not (Get-ItemProperty $Root6432).$KitsRootRegValueName ) {
$wowRegKeyPathFound = $false
}
if( -not (Get-ItemProperty $Root).$KitsRootRegValueName ) {
$regKeyPathFound = $false
}
if( !$wowRegKeyPathFound ) {
if( !$regKeyPathFound ) {
"KitsRoot not found, can't set common path for Deployment Tools" | Write-Warning
Exit
} else {
$regKeyPath = $Root
}
} else {
$regKeyPath = $Root6432
}
$KitsRoot = (Get-ItemProperty $regKeyPath).$KitsRootRegValueName
$KitsRoot += "\Assessment and Deployment Kit"
# Construct the path to WinPE directory, architecture-independent
$WinPERoot = "$KitsRoot\Windows Preinstallation Environment"
$WinPERootNoArch = "$KitsRoot\Windows Preinstallation Environment"
# Construct the path to DISM, Setup and USMT, architecture-independent
$WindowsSetupRootNoArch = "$KitsRoot\Windows Setup"
$USMTRootNoArch = "$KitsRoot\User State Migration Tool"
# Build the D&I Root from the queried KitsRoot
$DandIRoot = "$KitsRoot\Deployment Tools\${ENV:PROCESSOR_ARCHITECTURE}"
# Constructing tools paths relevant to the current Processor Architecture
$DISMRoot = "$DandIRoot\DISM"
$BCDBootRoot = "$DandIRoot\BCDBoot"
$ImagingRoot = "$DandIRoot\Imaging"
$OSCDImgRoot = "$DandIRoot\Oscdimg"
$WdsmcastRoot = "$DandIRoot\Wdsmcast"
# Now do the paths that apply to all architectures...
#
# Note that the last one in this list should not have a trailing semi-colon to avoid
# duplicate semi-colons on the last entry when the final path is assembled.
$HelpIndexerRoot = "$DandIRoot\..\HelpIndexer"
$WSIMRoot = "$DandIRoot\..\WSIM"
# Set ICDRoot. ICD is X86 only
$ICDRoot = "$KitsRoot\Imaging and Configuration Designer\x86"
# Now buld the master path from the various tool root folders...
#
# Note that each fragment above should have any required trailing
# semi-colon as a delimiter so we do not put any here.
#
# Note the last one appended to NewPath should be the last one
# set above in the arch. neutral section which also should not
# have a trailing semi-colon.
$NewPath = "$DISMRoot;$ImagingRoot;$BCDBootRoot;$OSCDImgRoot;$WdsmcastRoot;$HelpIndexerRoot;$WSIMRoot;$WinPERoot;$ICDRoot"
$ENV:Path = "$NewPath;${ENV:Path}"
# Set-Location $DandIRoot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment