Solved

Powershell Add-Windowsfeature

Posted on 2014-10-21
2
428 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 29

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

763 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