none
Wevtutil on multiple remote computers RRS feed

  • Question

  • Hi Scripting Masters,

    I'm trying to put a PS script together that will read from a list of remote computers and enable logging on each; however, I'm running into an error while attempting to do so.  Please see below and advise:

    CSV File Reads as follows:

    ComputerName

    Server1

    Server2

    Server3

    $servers = Import-csv "c:\Servers.csv"

    ForEach ($server in $servers){
    wevtutil set-log Microsoft-Windows-PrintService/Operational /e:true /r:$server.ComputerName
    }

    ERROR:

    wevtutil : Failed to read configuration for log Microsoft-Windows-PrintService/Operational. The RPC server is unavailable.
    At line:6 char:1
    + wevtutil set-log Microsoft-Windows-PrintService/Operational /e:true /r:$_.comput ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (Failed to read ...is unavailable.:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    I think the issue is with the string, but I'm not sure what is wrong.  When using /r:Server1, I have no issues enabling the log, but this isn't ideal when I have a giant list of servers to loop through.  Any help would be greatly appreciated.  Thanks.

    Wednesday, April 2, 2014 9:52 PM

Answers

  • Try this:

    foreeach($server in $servers){
         $cn=$server.Computername
         wevtutil set-log Microsoft-Windows-PrintService/Operational /e:true /r:"$cn"
    }

    The character pair :$ is problematic.


    ¯\_(ツ)_/¯

    • Marked as answer by Pigtaru Wednesday, April 2, 2014 10:31 PM
    Wednesday, April 2, 2014 10:26 PM

All replies

  • Try this:

    foreeach($server in $servers){
         $cn=$server.Computername
         wevtutil set-log Microsoft-Windows-PrintService/Operational /e:true /r:"$cn"
    }

    The character pair :$ is problematic.


    ¯\_(ツ)_/¯

    • Marked as answer by Pigtaru Wednesday, April 2, 2014 10:31 PM
    Wednesday, April 2, 2014 10:26 PM
  • Thanks jrv, you are the winner!
    Wednesday, April 2, 2014 10:31 PM
  • Thanks jrv, you are the winner!

    Glad that was it.  Good luck.

    ¯\_(ツ)_/¯

    Wednesday, April 2, 2014 10:57 PM