Remotezeit über WMI einstellen (Win32_OperatingSystem.SetDateTime () aufrufen)

487
George Sovetov

Das Ziel ist es, eine XML / SOAP / WSMan-Anforderung von Python und Linux zu erstellen und die Zeit auf einem Remote-Windows 10-Computer festzulegen.

Ich kann das über CMD, PowerShell oder Cygwin / SSH machen, aber ich brauche eine schnelle native Methode. Ich mache viel über WMI, es ist einfacher und schneller.

Ich versuche zu rufen Win32_OperatingSystem.SetDateTime.
Die Antwort von SOAP / WSMan umfasst:The SOAP XML in the message does not match the corresponding XML schema definition. Change the XML and retry. (extended fault data: )

Ich habe versucht, ähnliche Aufgaben manuell auf lokalen und Remote-Computern auszuführen. Ergebnisse sind gleich.

Über WMIC:

C:\Users\Administrator>wmic /node:10.254.251.2 os call SetDateTime 20180517141043.945000+000 Executing (Win32_OperatingSystem)->SetDateTime() ERROR: Description = Invalid method Parameter(s) 

Über WinRM:

C:\Users\Administrator>winrm invoke SetDateTime wmicimv2/Win32_OperatingSystem @ WSManFault Message ProviderFault WSManFault Message = The WS-Management service cannot process the request. The element for a datetime value must have exactly one child and no mixed content.  Error number: -2144108479 0x80338041 The SOAP XML in the message does not match the corresponding XML schema definition. Change the XML and retry. 

Über die WMI-Cmdlets von PowerShell:

PS C:\Users\Administrator> Invoke-WmiMethod -Class Win32_OperatingSystem -Name SetDateTime -ArgumentList '20180517133310.323710+000' -ComputerName 10.254.251.2 Invoke-WmiMethod : Invalid method Parameter(s)  At line:1 char:1 + Invoke-WmiMethod -Class Win32_OperatingSystem -Name SetDateTime -Argu ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Invoke-WmiMethod], ManagementException + FullyQualifiedErrorId : InvokeWMIManagementException,Microsoft.PowerShell.Commands.InvokeWmiMethod 

Wenn ich das Stringformat ändere, bekomme ich Type Error. Nur mit diesem Format, das scheinbar richtig ist, bekomme ich es Invalid method Parameter(s).

Auch bekomme ich Invalid method Parameter(s)bei der Ausführung von WBEMTest.

Ich habe Methodentypen mit untersucht WBEMTest. Parametertyp ist CIM_DATETIME. Was stimmt damit nicht? Wie kann ich die Uhrzeit auf einem Remote-Computer ändern?

Wie stelle ich die Uhrzeit über WMI ein?

Was ist die "entsprechende Schemadefinition" und wie erhalte ich sie?

0

2 Antworten auf die Frage

1
Vitali Kuzniatsou

Via WMIC: Ich bin in Wmic noob, aber ich habe den Befehl mit einer Art Filterung gefunden:

wmic os where(primary=1) call setdatetime 20070731144642.555555+480 

Ich habe geprüft und es funktioniert wirklich. Also, ich denke es sollte auch beim Remote-Calling gleich sein /node. Ich hoffe es wird für dich nützlich sein.

Hier die Quelle des Codes: Link

Anscheinend sind zwei Unterschiede das Argument "/ node" und die Klausel "where (1)". Wenn ich zu diesem Projekt zurückkehre, werde ich definitiv beides überprüfen. Vielen Dank. George Sovetov vor 5 Jahren 0
0
George Sovetov

Ich konnte nicht damit arbeiten, wmicaber dieses XML funktioniert für mich:

<?xml version="1.0" ?> <env:Envelope xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:b="http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd" xmlns:cfg="http://schemas.microsoft.com/wbem/wsman/1/config" xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:n="http://schemas.xmlsoap.org/ws/2004/09/enumeration" xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd" xmlns:rsp="http://schemas.microsoft.com/wbem/wsman/1/windows/shell" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns:x="http://schemas.xmlsoap.org/ws/2004/09/transfer" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <env:Header> <w:OperationTimeout>PT00H02M00.000S</w:OperationTimeout> <a:To>http://windows-host:5985/wsman</a:To> <w:SelectorSet/> <w:MaxEnvelopeSize mustUnderstand="true">153600</w:MaxEnvelopeSize> <w:ResourceURI mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_OperatingSystem</w:ResourceURI> <a:Action mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_OperatingSystem/SetDateTime</a:Action> <p:DataLocale mustUnderstand="false" xml:lang="en-US"/> <a:ReplyTo> <a:Address mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address> </a:ReplyTo> <a:MessageID>uuid:52029873-fef3-4f08-ba32-57827df5fb2c</a:MessageID> <w:Locale mustUnderstand="false" xml:lang="en-US"/> </env:Header> <env:Body> <SetDateTime_INPUT xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_OperatingSystem" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <p:LocalDateTime> <cim:Datetime>2018-07-21T19:51:34.365502Z</cim:Datetime> </p:LocalDateTime> </SetDateTime_INPUT> </env:Body> </env:Envelope> 

Dies ist dasselbe Format, mit dem WMI Win32_OperatingSystemzum Beispiel reagiert, wenn es angezeigt wird.