diff --git a/Add-WindowsCapabilities.ps1 b/Add-WindowsCapabilities.ps1
index 9e458c7..ba0f6cc 100644
--- a/Add-WindowsCapabilities.ps1
+++ b/Add-WindowsCapabilities.ps1
@@ -18,7 +18,7 @@
The directory path to the mounted windows image or the drive letter of a windows image that has been expanded onto a disk while in WindowsPE.
.PARAMETER CapabilitiesToAdd
- A valid regular expression. Allows to enable mutiple capabilities by using a regular expression.
+ A valid regular expression. Allows to enable mutiple capabilities by using a regular expression. Do not worry about using escpe characters within the regular expression as the regular expression will be escaped automatically.
Example: .*NetFX3.*|^SNMP.*Client.*|.*WMI.*SNMP.*Provider.*Client.*
Meaning: Anything with "NetFX3" in the capability name; Anything that begins with SNMP and has the word "Client" in the capability name; Anything that has the words WMI, SNMP, Provider, and Client in the capability name.
@@ -149,7 +149,7 @@
[Parameter(Mandatory=$False)]
[ValidateNotNullOrEmpty()]
[Alias('FODs')]
- [Regex]$CapabilitiesToAdd = '.*NetFX3.*|^SNMP.*Client.*|.*WMI.*SNMP.*Provider.*Client.*',
+ [Regex]$CapabilitiesToAdd = 'NetFX3~~~~|SNMP.Client~~~~0.0.1.0|WMI-SNMP-Provider.Client~~~~0.0.1.0',
[Parameter(Mandatory=$False)]
[ValidateNotNullOrEmpty()]
@@ -177,6 +177,7 @@
$Bios = Get-WmiObject -Namespace "root\CIMv2" -Class "Win32_Bios" -Property * | Select-Object -Property *
$ComputerSystem = Get-WmiObject -Namespace "root\CIMv2" -Class "Win32_ComputerSystem" -Property * | Select-Object -Property *
$OperatingSystem = Get-WmiObject -Namespace "root\CIMv2" -Class "Win32_OperatingSystem" -Property * | Select-Object -Property *
+ $MSSystemInformation = Get-WmiObject -Namespace "root\WMI" -Class "MS_SystemInformation" -Property * | Select-Object -Property *
#Retrieve property values
$OSArchitecture = $($OperatingSystem.OSArchitecture).Replace("-bit", "").Replace("32", "86").Insert(0,"x").ToUpper()
@@ -194,16 +195,6 @@
[System.IO.DirectoryInfo]$ToolsDirectoryGeneric = "$($ScriptDirectory.FullName)\Tools\All"
[System.IO.DirectoryInfo]$ToolsDirectoryArchSpecific = "$($ScriptDirectory.FullName)\Tools\$($OSArchitecture)"
$IsWindowsPE = Test-Path -Path 'HKLM:\SYSTEM\ControlSet001\Control\MiniNT' -ErrorAction SilentlyContinue
-
-#Log any useful information
- $LogMessage = "IsWindowsPE = $($IsWindowsPE.ToString())`r`n"
- Write-Verbose -Message "$($LogMessage)" -Verbose
-
- $LogMessage = "Script Path = $($ScriptPath.FullName)`r`n"
- Write-Verbose -Message "$($LogMessage)" -Verbose
-
- $LogMessage = "Script Directory = $($ScriptDirectory.FullName)`r`n"
- Write-Verbose -Message "$($LogMessage)" -Verbose
#Log task sequence variables if debug mode is enabled within the task sequence
Try
@@ -262,32 +253,41 @@
#Log any useful information
$LogMessage = "IsWindowsPE = $($IsWindowsPE.ToString())"
Write-Verbose -Message "$($LogMessage)" -Verbose
-
+
+ $LogMessage = "Capability Expression (Original) = $($CapabilitiesToAdd.ToString())"
+ Write-Verbose -Message "$($LogMessage)" -Verbose
+
+ $LogMessage = "Capability Expression (Escaped) = $([Regex]::Escape($CapabilitiesToAdd.ToString()))"
+ Write-Verbose -Message "$($LogMessage)" -Verbose
+
$LogMessage = "Script Path = $($ScriptPath.FullName)"
Write-Verbose -Message "$($LogMessage)" -Verbose
- $DirectoryVariables = Get-Variable | Where-Object {($_.Value -ine $Null) -and ($_.Value -is [System.IO.DirectoryInfo])}
+ $DirectoryVariables = Get-Variable | Where-Object {($_.Value -ine $Null) -and (($_.Value -is [System.IO.DirectoryInfo]) -or ($_.Value -is [System.IO.DirectoryInfo[]]))}
ForEach ($DirectoryVariable In $DirectoryVariables)
{
- $LogMessage = "$($DirectoryVariable.Name) = $($DirectoryVariable.Value.FullName)"
+ $LogMessage = "$($DirectoryVariable.Name) = $($DirectoryVariable.Value.FullName -Join ', ')"
Write-Verbose -Message "$($LogMessage)" -Verbose
}
#region Import Dependency Modules
-$Modules = Get-Module -Name "$($ModulesDirectory.FullName)\*" -ListAvailable -ErrorAction Stop
-
-$ModuleGroups = $Modules | Group-Object -Property @('Name')
-
-ForEach ($ModuleGroup In $ModuleGroups)
+If (($ModulesDirectory.Exists -eq $True) -and ($ModulesDirectory.GetDirectories().Count -gt 0))
{
- $LatestModuleVersion = $ModuleGroup.Group | Sort-Object -Property @('Version') -Descending | Select-Object -First 1
-
- If ($LatestModuleVersion -ine $Null)
+ $Modules = Get-Module -Name "$($ModulesDirectory.FullName)\*" -ListAvailable -ErrorAction Stop
+
+ $ModuleGroups = $Modules | Group-Object -Property @('Name')
+
+ ForEach ($ModuleGroup In $ModuleGroups)
{
- $LogMessage = "Attempting to import dependency powershell module `"$($LatestModuleVersion.Name) [Version: $($LatestModuleVersion.Version.ToString())]`". Please Wait..."
- Write-Verbose -Message "$($LogMessage)" -Verbose
- Import-Module -Name "$($LatestModuleVersion.Path)" -Global -DisableNameChecking -Force -ErrorAction Stop
+ $LatestModuleVersion = $ModuleGroup.Group | Sort-Object -Property @('Version') -Descending | Select-Object -First 1
+
+ If ($LatestModuleVersion -ine $Null)
+ {
+ $LogMessage = "Attempting to import dependency powershell module `"$($LatestModuleVersion.Name) [Version: $($LatestModuleVersion.Version.ToString())]`". Please Wait..."
+ Write-Verbose -Message "$($LogMessage)" -Verbose
+ Import-Module -Name "$($LatestModuleVersion.Path)" -Global -DisableNameChecking -Force -ErrorAction Stop
+ }
}
}
#endregion
@@ -355,8 +355,18 @@ ForEach ($ModuleGroup In $ModuleGroups)
If (($IsRunningTaskSequence -eq $True))
{
If (($PSBoundParameters.ContainsKey('ImagePath') -eq $False) -and ($ImagePath -eq $Null))
- {
- [System.IO.DirectoryInfo]$ImagePath = "$($TSEnvironment.Value('OSDisk'))\"
+ {
+ Switch ('OSDTargetSystemDrive', 'OSDisk')
+ {
+ {[String]::IsNullOrEmpty($TSEnvironment.Value($_)) -eq $False}
+ {
+ $LogMessage = "Checking to see the task sequence variable `"`$($_)`" has a value. Please Wait..."
+ Write-Verbose -Message "$($LogMessage)" -Verbose
+
+ [System.IO.DirectoryInfo]$ImagePath = "$($TSEnvironment.Value($_))\"
+ Break
+ }
+ }
}
}
@@ -406,7 +416,7 @@ ForEach ($ModuleGroup In $ModuleGroups)
{$_ -imatch 'RegQword'} {$VariableValue = [System.Convert]::ToInt64(($RegistryValue.ValueData), 16)}
}
- $CreateVariableFromRegistryValue = New-Variable -Name "$($VariableName)" -Value ($VariableValue) -Description "$($VariableDescription)" -Force -Verbose
+ $CreateVariableFromRegistryValue = Set-Variable -Name "$($VariableName)" -Value ($VariableValue) -Description "$($VariableDescription)" -Force -Verbose
}
}
Catch
@@ -487,7 +497,7 @@ ForEach ($ModuleGroup In $ModuleGroups)
$WindowsCapabilities = Get-WindowsCapability @GetWindowsCapabilityParameters | Select-Object -Property @('*') | Sort-Object -Property @('Name')
- $WindowsCapabilitiesToAdd = $WindowsCapabilities | Where-Object {($_.Name -imatch $CapabilitiesToAdd.ToString())}
+ $WindowsCapabilitiesToAdd = $WindowsCapabilities | Where-Object {($_.Name -imatch [Regex]::Escape($CapabilitiesToAdd.ToString()))}
$WindowsCapabilitiesToAddCount = $WindowsCapabilitiesToAdd | Measure-Object | Select-Object -ExpandProperty Count
diff --git a/Guides/ActionList.xml b/Guides/ActionList.xml
new file mode 100644
index 0000000..cf2860b
--- /dev/null
+++ b/Guides/ActionList.xml
@@ -0,0 +1,480 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Guides/How to Export a set of capabilities into a new repository (better use ready FOD iso) - My Digital Life Forums.url b/Guides/How to Export a set of capabilities into a new repository (better use ready FOD iso) - My Digital Life Forums.url
new file mode 100644
index 0000000..d53dba5
--- /dev/null
+++ b/Guides/How to Export a set of capabilities into a new repository (better use ready FOD iso) - My Digital Life Forums.url
@@ -0,0 +1,2 @@
+[InternetShortcut]
+URL=https://forums.mydigitallife.net/threads/how-to-export-a-set-of-capabilities-into-a-new-repository-better-use-ready-fod-iso.80739/
diff --git a/Guides/Output.txt b/Guides/Output.txt
new file mode 100644
index 0000000..9866072
--- /dev/null
+++ b/Guides/Output.txt
@@ -0,0 +1,37 @@
+PS C:\Users\QTQZC0\OneDrive - USPS> dism.exe /Image:"D:\ISOs\SW_DVD9_Win_Pro_10_1909.3_64BIT_English_Pro_Ent_EDU_N_MLF_X22-27457_Mount" /Export-Source /?
+
+Deployment Image Servicing and Management tool
+Version: 10.0.17763.771
+
+Image Version: 10.0.18363.720
+
+
+/Export-Source {/CapabilityName: | /Recipe:}
+ /Source: /Target: [/IncludeImageCapabilities]
+
+ Export a set of capabilities into a new repository.
+
+ Use the /CapabilityName to specify the capability you would like to
+ export. Multiple /CapabilityName arguments can be used. You can use /Recipe
+ instead of /CapabilityName to specify multiple capabilities at a time.
+ Use the /Source argument to specify the location of the source repository.
+ Use the /Target to specify the location of the new repository.
+ Use the /IncludeImageCapabilities to export image capabilities into the
+ new repository.
+
+ Examples:
+ Dism /Image:C:\test\offline /Export-Source /Source:C:\test\source
+ /Target:C:\test\target /CapabilityName:Language.Basic~~~en-US~0.0.1.0
+
+ Dism /Image:C:\test\offline /Export-Source /Source:C:\test\source
+ /Target:C:\test\target /Recipe:C:\test\recipe\recipe.xml
+
+Use commands below and adjust for needs
+
+dism.exe /Image:"D:\ISOs\SW_DVD9_Win_Pro_10_1909.3_64BIT_English_Pro_Ent_EDU_N_MLF_X22-27457_Mount" /Export-Source /Source:"D:\ISOs\SW_DVD9_NTRL_Win_10_1903_64Bit_MultiLang_FOD_1_X22-01658" /Target:"C:\Users\QTQZC0\OneDrive - USPS\Powershell\Scripts\Add-WindowsCapabilities\WindowsCapabilities\1909\X64\Exported" /CapabilityName:"Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0" /CapabilityName:"NetFX3~~~~" /CapabilityName:"WMI-SNMP-Provider.Client~~~~0.0.1.0" /CapabilityName:"SNMP.Client~~~~0.0.1.0"
+
+Without AD Tools
+dism.exe /Image:"C:\ImageServicing\Mount\os2005081002" /Export-Source /Source:"D:\FeaturesOnDemand\SW_DVD9_NTRL_Win_10_1809_64Bit_MultiLang_FOD_1_X21-91307" /Target:"C:\Users\QTQZC0\OneDrive - USPS\Powershell\Scripts\Add-WindowsCapabilities\WindowsCapabilities\1809\X64" /CapabilityName:"NetFX3~~~~" /CapabilityName:"WMI-SNMP-Provider.Client~~~~0.0.1.0" /CapabilityName:"SNMP.Client~~~~0.0.1.0"
+
+With AD Tools
+dism.exe /Image:"C:\ImageServicing\Mount\os2005081002" /Export-Source /Source:"D:\FeaturesOnDemand\SW_DVD9_NTRL_Win_10_1809_64Bit_MultiLang_FOD_1_X21-91307" /Target:"C:\Users\QTQZC0\OneDrive - USPS\Powershell\Scripts\Add-WindowsCapabilities\WindowsCapabilities\1809\X64" /CapabilityName:"Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0" /CapabilityName:"NetFX3~~~~" /CapabilityName:"WMI-SNMP-Provider.Client~~~~0.0.1.0" /CapabilityName:"SNMP.Client~~~~0.0.1.0"
\ No newline at end of file