SOLVED

Powershell Declaring XML in ModuleBase

Copper Contributor

I am automating Windows Updates on remote servers. I am using the PSWindowsUpdate module to make the updates. My question is regarding this error:

Install-WindowsUpdate : Missing SmtpServer; Use -PSWUSettings or declare PSWUSettings.xml in ModuleBase path.

 

I created the required PSWUSettings.xml file in the "C:\Program Files\WindowsPowerShell\Modules\PSWindowsUpdate" folder but I can't get the Install-WindowsUpate command to use it.

 

My question is then how do I 'declare' the PSWUSettings.xml file for the Install WindowsUpdate command to reference?

 

Thanks for your help.

 

 

6 Replies

It's a format like below I guess (https://github.com/Ichigo49/psh-tools/blob/master/lib/Modules/PSWindowsUpdate/2.0.0.0/PSWUSettings.x...

<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <Obj RefId="0">
    <TN RefId="0">
      <T>System.Collections.Hashtable</T>
      <T>System.Object</T>
    </TN>
    <DCT>
      <En>
        <S N="Key">Port</S>
        <S N="Value">25</S>
      </En>
      <En>
        <S N="Key">SmtpServer</S>
        <S N="Value">smtpwawa.server.pl</S>
      </En>
      <En>
        <S N="Key">To</S>
        <S N="Value">Email address removed</S>
      </En>
      <En>
        <S N="Key">From</S>
        <S N="Value">Email address removed</S>
      </En>
    </DCT>
  </Obj>
</Objs>

 

@Harm_Veenstra 

Thanks for the information. The XML file with those settings was created in the module's folder.

The question regards how to declare the PSWUSettings.xml in the Powershell command line. 

 

Here is the error message I received.

Install-WindowsUpdate : Missing SmtpServer; Use -PSWUSettings or declare PSWUSettings.xml in ModuleBase path.

 

Thanks

@LL10890 Sorry, my bad :) It should be in a hashtable format, command should be something like

 

 

Install-WindowsUpdate -ComputerName nysrv1 -MicrosoftUpdate -AcceptAll - IgnoreReboot -SendReport –PSWUSettings @{SmtpServer="smtp.woshub.com";From="Email address removed";To="Email address removed";Port=25} -Verbose

 

(http://woshub.com/pswindowsupdate-module/)

 

 

best response confirmed by LL10890 (Copper Contributor)
Solution

@LL10890 Did this work for you?

Yes. Thanks for your advice.
The command line is working now.
Nice to hear :)
1 best response

Accepted Solutions
best response confirmed by LL10890 (Copper Contributor)
Solution

@LL10890 Did this work for you?

View solution in original post