Skip to content

Instantly share code, notes, and snippets.

@Dan1el42
Created March 30, 2017 10:26
Show Gist options
  • Save Dan1el42/acc7fea5eb1e07a22ab8e670183fc5b2 to your computer and use it in GitHub Desktop.
Save Dan1el42/acc7fea5eb1e07a22ab8e670183fc5b2 to your computer and use it in GitHub Desktop.
Translate DISM feature names into PowerShell compatible ones.
# Translate DISM feature names to PowerShell
$translationTable = @'
NetFx4ServerFeatures
NetFx4
NetFx4Extended-ASPNET45
IIS-WebServerRole
IIS-WebServer
IIS-CommonHttpFeatures
IIS-Security
IIS-RequestFiltering
IIS-StaticContent
IIS-DefaultDocument
IIS-DirectoryBrowsing
IIS-HttpErrors
IIS-HttpRedirect
IIS-WebDAV
IIS-HealthAndDiagnostics
IIS-HttpLogging
IIS-Performance
IIS-HttpCompressionStatic
IIS-WebServerManagementTools
IIS-ManagementConsole
IIS-LoggingLibraries
IIS-RequestMonitor
IIS-CustomLogging
IIS-ODBCLogging
'@ -split "`n" |
ForEach-Object {
$feature = Get-WindowsOptionalFeature -Online -FeatureName ($_.Trim())
[PSCustomObject] @{
DismFeatureName = $feature.FeatureName
PowerShellFeatureName = $feature.CustomProperties |
Where-Object { $_.Name -eq 'UniqueName' -and $_.Path -eq 'ServerComponent' } |
Select-Object -ExpandProperty Value
}
}
# Output whole translation table
#$translationTable
# Only output the PowerShell feature names
$translationTable.PowerShellFeatureName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment