Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell Add-Windowsfeature

Posted on 2014-10-21
2
Medium Priority
?
481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
becraig earned 1500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

715 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