Installing WSUS on Windows Server “8” Beta using PowerShell

Installing WSUS on Windows Server “8” Beta using PowerShell

  • Comments 3
  • Likes

CMDAuthors:

Travis Plunk, Software Developer Engineer
Yuri Diogenes, Senior Technical Writer

Technical Reviewers:

Cecilia Cole, Program Manager

In our previous post, we demonstrated how to install the WSUS Role on the Windows Server “8” Beta using the new Server Manager. In this post you will learn how to perform the same task using PowerShell.

To install WSUS on Windows Server “8” Beta using PowerShell, follow the steps below:

1. Sign in on Windows Server “8” Beta

2. On the taskbar click Windows PowerShell button.

image

3. In the PowerShell Console type Install-WindowsFeature -Name UpdateServices, UpdateServices-Ui and press ENTER.

4. The installation process will start and a progress counter will appear on the screen. Wait until the installation reaches 100% and you receive a message that the installation succeeded before moving on to the next step.

5. Type & ‘C:\Program Files\Update Services\Tools\WsusUtil.exe’ postinstall contentdir=C:\Mycontent and press ENTER.

6. Wait until you receive the message that the post installation successfully finished.

8. Type Exit and press ENTER to leave the PowerShell interface.

At this point the WSUS installation is completed and you may launch the WSUS Console using the Tools menu. When you launch WSUS for the first time the WSUS Configuration Wizard will appear. For more information about how to configure WSUS, read Step 3: Configure WSUS in the Deploying Windows Server Updates Services in the Organization article at the TechNet Library.

If you want to perform the full installation and post installation tasks using PowerShell you should run this script once you finish the installation via PowerShell.

Stay tuned for more exciting stuff on this blog and the Windows Server Blog from the server leadership team.

Yuri Diogenes | Senior Technical Writer

Get the latest System Center news on Facebook and Twitter:

clip_image001 clip_image002

App-V Team blog: http://blogs.technet.com/appv/
ConfigMgr Support Team blog: http://blogs.technet.com/configurationmgr/
DPM Team blog: http://blogs.technet.com/dpm/
MED-V Team blog: http://blogs.technet.com/medv/
Orchestrator Support Team blog: http://blogs.technet.com/b/orchestrator/
Operations Manager Team blog: http://blogs.technet.com/momteam/
SCVMM Team blog: http://blogs.technet.com/scvmm
Server App-V Team blog: http://blogs.technet.com/b/serverappv
Service Manager Team blog: http://blogs.technet.com/b/servicemanager
System Center Essentials Team blog: http://blogs.technet.com/b/systemcenteressentials
WSUS Support Team blog: http://blogs.technet.com/sus/

The Forefront Server Protection blog: http://blogs.technet.com/b/fss/
The Forefront Endpoint Security blog : http://blogs.technet.com/b/clientsecurity/
The Forefront Identity Manager blog : http://blogs.msdn.com/b/ms-identity-support/
The Forefront TMG blog: http://blogs.technet.com/b/isablog/
The Forefront UAG blog: http://blogs.technet.com/b/edgeaccessblog/

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Hi, this way of installing is no longer working on Windows Server 2012 RTM. Here is a script that works for us:

    function Install-WSUS {

       param(

           [switch]

           $ContentLocal,

           [string]

           $ContentDirectory = "C:\ProgramData\WSUS\Content"

       )

       Install-WindowsFeature -Name updateservices -IncludeManagementTools

       # Modification of the UpdateServices-Services.xml

       # NOTE :

       # When the installation is made with the previous cmdlet "Install-WindowsFeature ..." and not with the ServerManager GUI the XML configuration file UpdateServices-Services.xml is not correctly set.

       # We need to set the value of the two properties : ContentDirectory and ContentLocal

       #

       invoke-command -ScriptBlock {

         Write-Output "Configuring UpdateServices-Services with ContentLocal: $($ContentLocal), ContentDirectory: $($ContentDirectory)";

         $assemblyReferences=@("System.Xml", "System.Xml.Linq");

         $sourceCode=@"

    using System;

    using System.IO;

    using System.Diagnostics;

    using System.Linq;

    using System.Xml.Linq;

    namespace CSharpScripts {

       public class UpdateServicesConfigurationV11 {

           public static string SetServicesProperties(bool contentLocal, string contentDirectory) {

               string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "ServerManager", "ComponentConfiguration", "UpdateServices-Services.xml");

               SetServicesProperties(path, contentLocal, contentDirectory);

               return path;

           }

           public static void SetServicesProperties(string path, bool contentLocal, string contentDirectory) {

               XDocument doc;

               using(StreamReader reader = new StreamReader(path, true)) {

                   doc = System.Xml.Linq.XDocument.Load(reader);

               }

               XElement instance = doc.Element("INSTANCE");

               if (instance.Attribute("CLASSNAME").Value != "ServerComponent_UpdateServices_Services") {

                   throw new InvalidOperationException("Bad file");

               }

               foreach (XElement property in instance.Elements("PROPERTY")) {

                   switch (property.Attribute("NAME").Value) {

                       case "ContentDirectory":

                           SetPropertyValue(property, contentDirectory);

                           break;

                       case "ContentLocal":

                           SetPropertyValue(property, contentLocal, toLower:true);

                           break;

                       default:

                           break;

                   }

               }

               //Workaround for access denied...

               string tempPath = Path.ChangeExtension(path, ".xml.tmp");

               doc.Save(tempPath);

               File.Delete(path);

               File.Move(tempPath, path);

           }

           private static void SetPropertyValue(XElement property, object value, bool toLower = false) {

               XElement valueElement;

               string stringValue = (value ?? string.Empty).ToString();

               if (toLower) {

                   stringValue = stringValue.ToLowerInvariant();

               }

               if (property.Elements("VALUE").Count()>0) {

                   valueElement = property.Element("VALUE");

               } else {

                   valueElement = new XElement("VALUE");

                   property.Add(valueElement);

               }

               valueElement.Value = stringValue.ToString();

           }

       }

    }

    "@

           Add-Type -ReferencedAssemblies $assemblyReferences -TypeDefinition $sourceCode -Language CSharp

           $configFile = [CSharpScripts.UpdateServicesConfigurationV11]::SetServicesProperties($ContentLocal, $ContentDirectory);

           Get-Content -Path $configFile;

           }

         Write-Output "Launching Post installation of UpdateServices-Services";

       # Run post-installation by command line

       & 'C:\Program Files\Update Services\Tools\WsusUtil.exe' postinstall /sm

    }