SOLVED

Powershell Declaring XML in ModuleBase

%3CLINGO-SUB%20id%3D%22lingo-sub-3053733%22%20slang%3D%22en-US%22%3EPowershell%20Declaring%20XML%20in%20ModuleBase%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3053733%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20automating%20Windows%20Updates%20on%20remote%20servers.%20I%20am%20using%20the%26nbsp%3BPSWindowsUpdate%20module%20to%20make%20the%20updates.%201My%20question%20is%20regarding%20this%20error%3A%3C%2FP%3E%3CP%3E%3CEM%3EInstall-WindowsUpdate%20%3A%20Missing%20SmtpServer%3B%20Use%20-PSWUSettings%20or%20declare%20PSWUSettings.xml%20in%20ModuleBase%20path.%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20created%20the%20required%26nbsp%3BPSWUSettings.xml%3CSTRONG%3E%26nbsp%3B%3C%2FSTRONG%3Efile%20in%20the%20%22C%3A%5CProgram%20Files%5CWindowsPowerShell%5CModules%5CPSWindowsUpdate%22%20folder%20but%20I%20can't%20get%20the%20Install-WindowsUpate%20command%20to%20use%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20question%20is%20then%20how%20do%20I%20'declare'%20the%20PSWUSettings.xml%20file%20for%20the%20Install%20WindowsUpdate%20command%20to%20reference%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3053733%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPSWindowsUpdate%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional 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 (Occasional Contributor)
Solution

@LL10890 Did this work for you?

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