8/28/2012

Adding or removing features with Powershell (or Dism)

Installing or uninstalling, waiting for updates, re-starting, staring at that "please-waaaaiiiit-wheel" can make you feel like... you're wasting your time.
What if you want to install a feature with a script, or manually/graphically adding one doesn't work - you start over, you restart the machine, go back to add/remove features and realize that - well - it didn't install the rest of the management features... *sigh* instead of waiting... clicking Next... Filling out forms... Restarting... and so on bla bla.

So! We'll look at different ways to add, install or uninstall features in Windows 8 and Windows Server 2012:

Uninstalling or Installing Windows Features using Poweshell
Run Powershell as Administrator and execute the following:
Get-WindowsFeature
to view a list of Available and Installed Features

If you want to remove a Windows feature such as the Graphical user interface on Windows Server 2012 (GUI) and run core you can uninstall Graphical Management Tools and Infrastructure (Server-Gui-Mgmt-Infra) and Server Graphical Shelll (Server-Gui-Shell) you can run the following command to uninstall the windows features
Uninstall-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell -Restart

So if you want to Install a windows feature you simply run Install instead:
Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell -Restart

Uninstalling or Installing Windows Features using DISM
Run CMD as administrator and execute the following
dism /online /get-features | more
To install a feature using dism, for example .Net 3.5, .Net2.0 for older applications use
dism /online /enable-feature /featurename:NetFx3

Getting errors, or how to install features that are missing installation files using an ISO
Did you install a Core server and can't get the windows feature for GUI to install? Grab a Windows Server 2012 (or Windows 8 ISO if you're trying to install .net on a client) and use install.wim to get a hold of the c:\windows\winsxs folder which has all the nessecary files to install a windows feature.

With Powershell
1. Mount the ISO and create a folder called C:\mount. Mount a Server 2012 or Windows 8 ISO depending on your working environment and note the drive letter, in this example I will use D:\, by running the following:
Mount-Diskimage C:\Lab\windows8orserver2012.iso
2. Determine what Index number you will use (Datacenter or Enterprise etc) by running the following command:
Get-WindowsImage -ImagePath D:\sources\install.wim
3. Mount the install.wim from the ISO by running the following commandline:
Mount-WindowsImage -ImagePath D:\sources\install.wim -Index 4 -Path C:\mount -Optimize -ReadOnly
4. Install the feature using the winsxs folder from your mounted install.wim image by running the following commandline:
Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell
Restart
Source c:\mountwim\windows\winsxs
5. To dismount the wimfile run
Dismount-WindowsImage -Path C:\mount -Discard Dismount-WindowsImage -Path C:\mount -Discard

If you need to create a folder you can use New-Item cmdlet to create a folder:
New-Item c:\ Mount -type directory




With Dism
1. Mount the ISO and note the drive letter and create a folder called C:\Mount, in this example I will use D:\
2. Determine what Index number you will use (Datacenter or Enterprise etc) by running the following command:
Dism /get-wiminfo /wimfile:D:sources\install.wim
3. Mount the install.wim file (in this example the Index number is 4) by running the following commandline:
Dism /mount-wim /WimFile:D:\sources\install.wim /Index:4 /MountDir:c:\mount /readonly
4. Install the windows feature by running the following
dism /online /enable-feature /featurename:servercore-fullserver /featurename:server-gui-shell /featurename:server-gui-mgmt /all /source:N:\sources\sxs

If you need to create a folder use mkdir.

Inga kommentarer:

Skicka en kommentar