Last active
August 29, 2015 14:27
-
-
Save Thermionix/8ffc980077f8c7de8094 to your computer and use it in GitHub Desktop.
setup.netfx3.ps1 - choose and ISO file to use as the source for enabling NetFx3 in DISM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -Version 4.0 | |
#Requires -RunAsAdministrator | |
Trap { Write-Host $_ -Fore Red ; pause ; exit 1 } | |
$ErrorActionPreference = "Stop" | |
function Mount-Iso([string] $isoPath) | |
{ | |
if ( -not (Test-Path $isoPath)) { throw "$isoPath does not exist" } | |
Write-Host "Mounting $isoPath using powershell" | |
Mount-DiskImage -ImagePath $isoPath | |
$driveLetter = (Get-DiskImage $isoPath | Get-Volume).DriveLetter | |
start-sleep -s 3 | |
return ($driveLetter + ":\") | |
} | |
function Dismount-Iso([string] $isoPath) | |
{ | |
start-sleep -s 5 | |
Write-Host "Unmounting $isoPath using powershell" | |
Dismount-DiskImage -DevicePath (Get-DiskImage -ImagePath $isoPath).DevicePath | |
} | |
function FindISO-Dialog | |
{ | |
$titleText="Please select the ISO File used to install your edition of windows" | |
Write-Host $titleText -fore Yellow | |
Add-Type -AssemblyName System.Windows.Forms | |
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{ | |
Title = $titleText | |
Filter = 'ISO Files (*.iso)|*.iso' | |
Multiselect = $false | |
} | |
[void]$FileBrowser.ShowDialog() | |
return $FileBrowser.FileName | |
} | |
if ([Environment]::OSVersion.Version -ge (new-object 'Version' 6,2)) | |
{ | |
$isoFile = FindISO-Dialog | |
$mountPath = Mount-Iso $isoFile | |
$sourcesPath = Join-Path $mountPath "\sources\sxs" | |
if ( -not (Test-Path $sourcesPath)) { Write-Error "$sourcesPath does not exist" } | |
else { & Dism /online /enable-feature /featurename:NetFx3 /All /Source:$sourcesPath /LimitAccess | Out-Host } | |
Dismount-Iso $isoFile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment