Solved

Powershell Add-Windowsfeature

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

772 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