Wednesday, October 9, 2013

Everyday Powershell - Part 3 - Learn to use Powershell for adding windows features NOW!

This is the next part in an ongoing series about Powershell. You may have heard about how awesome Powershell is but have struggled to find ways to make it useful in your day to day work. That's what this series is going to address. It'll provide scripts and knowledge to address practical everyday problems!

The problem we're fixing today might seem a bit redundant, until you've used it a few times. We're doing a really basic admin function today, Adding Windows Features!

Yup that thing you can do with add roles and features wizard. It's a common task for admins after they've run up a fresh server. The cool thing with powershell is once you know what dependencies you need and get it sorted in powershell it's then never more than a few keystrokes away!

get-windowsfeature You can use this to figure out what a particular feature should be called and check if it's already installed

add-windowsfeature This will add the feature (or features) you've designated. You can add more than one feature just use a comma as a separator.

Again I've got to reiterate you'll only see the benefit of this if you start to use it. There is value trust me. Last month while building a test Sharepoint 2013 environment, I figured out all the prerequisites and got it all installed using Powershell. Once sharepoint was up a running I went to lunch. Came back and the Volume I'd provisioned my Virtual Machine on had been nuked by an admin (it was a test environment after all). It wasn't a problem at all though I just brought up another fresh OS and because I had spent the time to figure out the prerequisites I could run a little powershell to setup everything sharepoint would need! So there was plenty of time left over to torture that admin!

So to get you started with this here's some prerequisites already all sorted for you;

Exchange 2013
Add-WindowsFeature Desktop-Experience, NET-HTTP-Activation, RPC-over-HTTP-proxy, RSAT-Clustering, WAS-Process-Model, Web-Asp-Net, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Dir-Browsing, Web-Dyn-Compression, Web-Http-Errors, Web-Http-Logging, Web-Http-Redirect, Web-Http-Tracing, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Lgcy-Mgmt-Console, Web-Metabase, Web-Mgmt-Console, Web-Mgmt-Service, Web-Net-Ext, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI, RSAT-Clustering-CmdInterface

Sharepoint 2013
Add-windowsfeature Net-Framework-Features, Web-Server, Web-WebServer, Web-Common-Http, Web-Static-Content, Web-Default-Doc, Web-Dir-Browsing, Web-Http-Errors, Web-App-Dev, Web-Asp-Net, Web-Net-Ext, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Health, Web-Http-Logging, Web-Log-Libraries, Web-Request-Monitor, Web-Http-Tracing, Web-Security, Web-Basic-Auth, Web-Windows-Auth, Web-Filtering, Web-Digest-Auth, Web-Performance, Web-Stat-Compression, Web-Dyn-Compression, Web-Mgmt-Tools, Web-Mgmt-Console, Web-Mgmt-Compat, Web-Metabase, Application-Server, AS-Web-Support, AS-TCP-Port-Sharing, AS-WAS-Support, AS-HTTP-Activation, AS-TCP-Activation, AS-Named-Pipes, AS-Net-Framework, WAS, WAS-Process-Model, WAS-NET-Environment, WAS-Config-APIs, Web-Lgcy-Scripting, Windows-Identity-Foundation, Server-Media-Foundation, Xps-Viewer

Lync 2013
Add-windowsfeature RSAT-ADDS,Web-Server,Web-Static-Content,Web-Default-Doc,Web-Http-Errors,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Http-Tracing,Web-Basic-Auth,Web-Windows-Auth,Web-Client-Auth,Web-Filtering,Web-Stat-Compression,Web-Dyn-Compression,NET-WCF-HTTP-Activation45,Web-Asp-Net45,Web-Mgmt-Tools,Web-Scripting-Tools,Web-Mgmt-Compat,NET-Framework-Core,NET-HTTP-Activation,Desktop-Experience,Windows-Identity-Foundation,Telnet-Client,BITS 

SCCM 2012
Add-windowsfeature "BITS","BITS-IIS-Ext","BITS-Compact-Server","RDC","WAS-Process-Model","WAS-Config-APIs","WAS-Net-Environment","Web-Server","Web-ISAPI-Ext","Web-ISAPI-Filter","Web-Net-Ext","Web-Net-Ext45","Web-ASP-Net","Web-ASP-Net45","Web-ASP","Web-Windows-Auth","Web-Basic-Auth","Web-URL-Auth","Web-IP-Security","Web-Scripting-Tools","Web-Mgmt-Service","Web-Stat-Compression","Web-Dyn-Compression","Web-Metabase","Web-WMI","Web-HTTP-Redirect","Web-Log-Libraries","Web-HTTP-Tracing","UpdateServices-RSAT","UpdateServices-API","UpdateServices-UI"

One thing to note is that some of these install the .net 3.5 framework... A odd quirk of Server 2012 is that these need to come from your install media for some reason. Just mount the ISO and hand this parameter to the command;
-Source D:\sources\sxs 

If you are doing a Sharepoint 2013 build check up Craig Lussiers post here it'll likely save you hours!

If you are getting into an SCCM install check out NicloaJ's post here

For other System Center products Steve Beaumont has put in a lot of effort on documenting and aquiring prerequisites

No comments:

Post a Comment