Solved

Powershell Add-Windowsfeature

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
A procedure for exporting installed hotfix details of remote computers using 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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 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

26 Experts available now in Live!

Get 1:1 Help Now