Solved

Powershell Add-Windowsfeature

Posted on 2014-10-21
2
399 Views
Last Modified: 2014-11-10
Need a little help. I have this PowerShell script than bombs out halfway through I think. Here is the script:

Import-Module ServerManager | Out-File c:\Temp\test.txt -append -width 300
Add-WindowsFeature 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-Http-Tracing,Web-Windows-Auth,Web-Filtering,Web-Stat-Compression,Web-Mgmt-Console,Web-Scripting-Tools,Web-Client-Auth | Out-File c:\Temp\test.txt -append -width 300
Add-WindowsFeature RSAT-ADDS | Out-File c:\Temp\test.txt -append -width 300
Add-WindowsFeature MSMQ-SERVER, MSMQ-Directory | Out-File c:\Temp\test.txt -append -width 300
Add-WindowsFeature NET-Framework-Core | Out-File c:\Temp\test.txt -append -width 300
Set-executionpolicy Restricted | Out-File c:\Temp\test.txt -append -width 300
Restart-Computer | Out-File c:\Temp\test.txt -append -width 300

I am thinking because a couple of items down a reboot is required after install. Here is the log output. The two bottom items failed and there is not enough in the log file to tell. A more robust output would be nice. :) Thanks!

Success Restart Needed Exit Code Feature Result                              
------- -------------- --------- --------------                              
True    No             Success   {IIS Management Scripts and Tools, IIS Man...



Success Restart Needed Exit Code Feature Result                              
------- -------------- --------- --------------                              
True    Yes            Succes... {Server for NIS Tools, Active Directory mo...



Success Restart Needed Exit Code Feature Result                              
------- -------------- --------- --------------                              
False   Yes            Failed... {}                                          



Success Restart Needed Exit Code Feature Result                              
------- -------------- --------- --------------                              
False   Yes            Failed... {}
0
Comment
Question by:jbyrd1981
2 Comments
 
LVL 28

Accepted Solution

by:
becraig earned 500 total points
ID: 40395525
First why are you specifying a width if you need the output from the command ?

Second, since some of these will need a reboot as clearly indicated above, some features will not install with a pending reboot.

If you notice after the first step with a required reboot the others fail, you need to do your reboots and then continue your install.
0
 
LVL 1

Author Closing Comment

by:jbyrd1981
ID: 40434004
I switched the order of commands in the script to put the reboot one at the end. Works great now!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This article will help you understand what HashTables are and how to use them in PowerShell.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video discusses moving either the default database or any database to a new volume.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now