namespace Vanara.PInvoke; /// Items from the WsmSvc.dll public static partial class WsmSvc { /// /// /// The __WSManEnumFlags enumeration contains constants, as listed in the following list, used in the flags parameter by /// calls to IWSManSession::Enumerate. /// /// /// Be aware that WSManFlagReturnObject and WSManFlagHierarchyDeep are the default if the flags parameter is not specified. /// /// // https://docs.microsoft.com/en-us/windows/win32/winrm/enumeration-constants [PInvokeData("wsmandisp.h")] [Flags] public enum WSManEnumFlags { /// /// This flag controls how the filter parameter in the call to Session.Enumerate is interpreted by WinRM. /// /// The format of the filter may be an XML fragment or a string of plain text. The format is determined by the filter dialect of /// the filter used in the call to Session.Enumerate or IWSManSession::Enumerate, which is specific to the operation performed. /// /// /// If the dialect parameter is not specified, WinRM attempts to determine the dialect based on the first character of the /// filter. If the first character is <, but the filter is not actually an XML fragment, then this flag should be set. For /// example, a filter in the following format requires that you set WSManFlagNonXmlText so that the filter is correctly interpreted: /// /// <25 && > 1 /// /// If the filter is an XML fragment, then this flag is not required because the fragment starts with <, which WinRM /// correctly interprets as XML. For example, /// /// <filter>select * from aDataStructure</filter> /// If the filter is in plain text that does not start with <, then this flag is not required. For example, /// select * from aDataStructure /// WSManFlagNonXmlText = 0x00000001, /// Batches contain the requested XML instances. This is the default value for the flag parameter. WSManFlagReturnObject = 0x00000000, /// Batches contain endpoint references (EPRs) for the corresponding XML instances, but not the actual instances. WSManFlagReturnEPR = 0x00000002, /// Batches contain both the requested XML instances and the corresponding EPRs contained in a wsman:Items element. WSManFlagReturnObjectAndEPR = 0x00000004, /// Derived class instances are included and are represented according to their actual schemas. WSManFlagHierarchyDeep = 0x00000000, /// Derived class instances are excluded. Only instances of the requested type are shown. WSManFlagHierarchyShallow = 0x00000020, /// /// Derived class instances are included and are represented according to the base class schema. Properties defined in the /// derived class are not shown. /// WSManFlagHierarchyDeepBasePropsOnly = 0x00000040, /// WSManFlagAssociatedInstance = 0x00000000, /// WSManFlagAssociationInstance = 0x00000080 } /// Defines the proxy access type flags. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/ne-wsmandisp-wsmanproxyaccesstypeflags typedef enum // _WSManProxyAccessTypeFlags { WSManProxyIEConfig, WSManProxyWinHttpConfig, WSManProxyAutoDetect, WSManProxyNoProxyServer } WSManProxyAccessTypeFlags; [PInvokeData("wsmandisp.h", MSDNShortId = "NE:wsmandisp._WSManProxyAccessTypeFlags")] [Flags] public enum WSManProxyAccessTypeFlags { /// Use the Internet Explorer proxy configuration for the current user. WSManProxyIEConfig = 0x01, /// Use the proxy settings configured for WinHTTP. This is the default setting. WSManProxyWinHttpConfig = 0x02, /// Force autodetection of a proxy. WSManProxyAutoDetect = 0x04, /// Do not use a proxy server. All host names are resolved locally. WSManProxyNoProxyServer = 0x08, } /// Determines the proxy authentication mechanism. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/ne-wsmandisp-wsmanproxyauthenticationflags typedef enum // _WSManProxyAuthenticationFlags { WSManFlagProxyAuthenticationUseNegotiate, WSManFlagProxyAuthenticationUseBasic, // WSManFlagProxyAuthenticationUseDigest } WSManProxyAuthenticationFlags; [PInvokeData("wsmandisp.h", MSDNShortId = "NE:wsmandisp._WSManProxyAuthenticationFlags")] [Flags] public enum WSManProxyAuthenticationFlags { /// /// Use Negotiate authentication. The client sends a request to the server to authenticate. The server determines whether to use /// Kerberos or NTLM. In general, Kerberos is selected to authenticate a domain account and NTLM is selected for local computer /// accounts. But there are also some special cases in which Kerberos/NTLM are selected. The user name should be specified in /// the form DOMAIN\username for a domain user or SERVERNAME\username for a local user on a server computer. /// WSManFlagProxyAuthenticationUseNegotiate = 0x01, /// /// Use Basic authentication. The client presents credentials in the form of a user name and password that are directly /// transmitted in the request message. /// WSManFlagProxyAuthenticationUseBasic = 0x02, /// /// Use Digest authentication. Only the client computer can initiate a Digest authentication request. The client sends a request /// to the server to authenticate and receives from the server a token string. The client then sends the resource request, /// including the user name and a cryptographic hash of the password combined with the token string. Digest authentication is /// supported for HTTP and HTTPS. /// WSManFlagProxyAuthenticationUseDigest = 0x04, } /// Constants that specify encoding, encryption, and service principal name port. [PInvokeData("wsmandisp.h")] [Flags] public enum WSManSessionFlags : int { /// Sends the request in UTF8 rather than UTF16. WSManFlagUTF8 = 1, /// /// Use the user name and password as the credentials. Set this flag when you create a ConnectionOptions object and supply /// Username and Password. The credentials can be a domain account or an account on the local computer. By default, the account /// must be a member of the local Administrators group on the local or remote computer. However, the WinRM service can be /// configured to allow other users. For more information, see Installation and Configuration for Windows Remote Management. You /// can set this flag when you specify credentials for Negotiate authentication (also known as Windows Integrated /// Authentication) or for Basic authentication. /// WSManFlagCredUsernamePassword = 0x1000, /// /// When connecting over HTTPS, the client does not validate that the server certificate is signed by a trusted certification /// authority (CA). Use this value only when the remote computer is trusted by other means, for example, if the remote computer /// is part of a network that is physically secure and isolated or the remote computer is listed as a trusted host in the WinRM configuration. /// WSManFlagSkipCACheck = 0x2000, /// /// When connecting over HTTPS, the client will not validate that the common name (CN) in the server certificate matches the /// computer name in the connection string. Use only when the remote computer is trusted by other means, for example, if the /// remote computer is part of a network that is physically secure and isolated or the remote computer is listed as a trusted /// host in the WinRM configuration. /// WSManFlagSkipCNCheck = 0x4000, /// /// Use no authentication. Specify this constant when testing a connection to a remote computer to determine if a service that /// implements the WS-Management protocol is configured to listen for data requests. WSManFlagUseNoAuthentication cannot be /// combined with any other Session constant. /// WSManFlagUseNoAuthentication = 0x8000, /// /// Use Digest authentication. Only the client computer can initiate a Digest authentication request. The client sends a request /// to the server to authenticate and receives a token string from the server. The client then sends the resource request, /// including the user name and a cryptographic hash of the password combined with the token string. Digest authentication is /// supported for HTTP and HTTPS. WinRM client scripts and applications can specify Digest authentication, but not the service. /// WSManFlagUseDigest = 0x10000, /// /// Use Negotiate authentication. The client sends a request to the server to authenticate. The server determines whether to use /// Kerberos or NTLM. Kerberos is selected to authenticate a domain account and NTLM is selected for local computer accounts. /// The user name should be specified in the form domain\username for a domain user or servername\username for a local user on a /// server computer. /// /// User Account Control (UAC) affects access to the WinRM service.When Negotiate authentication is used in a workgroup or /// domain, only the built-in Administrator account can access the service.To allow all accounts in the Administrators group to /// access the service, set the following registry key to 1: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system\LocalAccountTokenFilterPolicy. /// /// WSManFlagUseNegotiate = 0x20000, /// /// Use Basic authentication. The client presents credentials in the form of a user name and password, directly transmitted in /// the request message. You can specify only credentials that identify a local administrator account on the remote computer. /// WSManFlagUseBasic = 0x40000, /// Use Kerberos authentication. The client and server mutually authenticate using Kerberos tickets. WSManFlagUseKerberos = 0x80000, /// /// Do not encrypt the messages sent over the network. This setting is allowed only if the listener is configured so that /// AllowUnencrypted is set to True. /// WSManFlagNoEncryption = 0x100000, /// Use client certificate-based authentication. WSManFlagUseClientCertificate = 0x200000, /// /// Specify the Service Principal Name (SPN) port when connecting directly to remote BMC hardware, also known as an out-of-band /// connection. Because both the WinRM server computer and the BMC hardware can share the same IP address, this flag indicates /// that the SPN port number must be used to determine whether the connection is to the service or directly to the BMC. For more /// information, see Name Formats for Unique SPNs. /// WSManFlagEnableSPNServerPort = 0x400000, /// Sends the request in UTF16. WSManFlagUTF16 = 0x800000, /// Use Credential Security Support Provider (CredSSP) authentication. WSManFlagUseCredSsp = 0x1000000, /// Do not check for certificate revocation during authentication. WSManFlagSkipRevocationCheck = 0x2000000, /// Allow implicit credentials. WSManFlagAllowNegotiateImplicitCredentials = 0x4000000, /// Use Secure Socket Layer, enables HTTPS. WSManFlagUseSsl = 0x8000000 } /// /// Provides methods and properties used to create a session, represented by a Session object. Any Windows Remote Management /// operations require creation of a Session that connects to a remote computer, base management controller (BMC), or the local /// computer. Operations include getting, writing, or enumerating data, or invoking methods. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsman [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSMan")] [ComImport, Guid("190D8637-5CD3-496d-AD24-69636BB5A3B5"), InterfaceType(ComInterfaceType.InterfaceIsDual)] [CoClass(typeof(WSMan))] public interface IWSMan { /// Creates a Session object that can then be used for subsequent network operations. /// /// The protocol and service to connect to, including either IPv4 or IPv6. The format of the connection information is as /// follows: <Transport><Address><Suffix>. For examples, see Remarks. If no connection information is /// provided, the local computer is used. /// /// /// /// The session flags that specify the authentication method, such as Negotiate authentication or Digest authentication, for /// connecting to a remote computer. These flags also specify other session connection information, such as encoding or /// encryption. This parameter must contain one or more of the flags in __WSManSessionFlags for a remote connection. For /// more information, see Session Constants. No flag settings are required for a connection to the WinRM service on the local computer. /// /// /// If no authentication flags are specified, Kerberos is used unless one of the following conditions is true, in which case /// Negotiate is used: /// /// /// /// explicit credentials are supplied and the destination host is trusted /// /// /// the destination host is "localhost", "127.0.0.1" or "[::1]" /// /// /// the client computer is in a workgroup and the destination host is trusted /// /// /// For more information, see /// Authentication for Remote Connections /// and the /// connectionOptions /// parameter. /// /// /// A pointer to an IWSManConnectionOptions object that contains a user name and password. The default is NULL. /// /// A pointer to a new IWSManSession object. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// The following list contains examples of formats used to specify connection information in the connection parameter (when /// creating an HTTPS session, the <Address> field must match the server computer certificate name, otherwise a failure occurs): /// /// /// /// "https://service" /// Uses HTTPS to connect to the default web service location. /// /// /// /// "https://service.corp.com/websvcs/wsman" /// Uses HTTPS to connect to the specific web service location. /// /// /// /// "https://[E3D7:0000:0000:0000:51F4:9BC8:C0A8:6420]" /// Uses HTTPS and IPv6 with the default port. /// /// /// /// "https://[E3D7:0000:0000:0000:51F4:9BC8:C0A8:6420]:9999/wsman" /// Uses HTTPS and IPv6 with the given port. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-createsession HRESULT CreateSession( BSTR // connection, long flags, IDispatch *connectionOptions, IDispatch **session ); [PreserveSig, DispId(1)] HRESULT CreateSession([MarshalAs(UnmanagedType.BStr)] string connection, [Optional] WSManSessionFlags flags, IWSManConnectionOptions? connectionOptions, out IWSManSession session); /// Creates an IWSManConnectionOptions object that specifies the user name and password used when creating a session. /// A pointer to a new IWSManConnectionOptions object. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-createconnectionoptions HRESULT // CreateConnectionOptions( IDispatch **connectionOptions ); [PreserveSig, DispId(2)] HRESULT CreateConnectionOptions(out IWSManConnectionOptions connectionOptions); /// /// Gets the command line of the process that loads the automation component. /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/winrm/wsman-commandline WSMan.CommandLine As BSTR [DispId(3)] string CommandLine { [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// /// /// Gets additional error information, in an XML stream, for the preceding call to an IWSMan method if Windows Remote Management /// service was unable to create an IWSManSession object, an IWSManConnectionOptions object, or an IWSManResourceLocator object. /// /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-get_error HRESULT get_Error( BSTR *value ); [DispId(4)] string Error { [DispId(4)] [return: MarshalAs(UnmanagedType.BStr)] get; } } /// /// The IWSManConnectionOptions object is passed to the IWSMan::CreateSession method to provide the user name and password /// associated with the local account on the remote computer. If no parameters are supplied, then the credentials of the account /// running the script are the default values. /// /// /// If a Windows Remote Management client application is running under impersonation, then a failure occurs if you set the Password /// property. A client application is a script or other program that sends a request to WinRM on the local or a remote computer. The /// client application may be running under impersonation because it called a function like ImpersonateClient. An Active Server Page /// (ASP) or service cannot request a user name and password if the ASP process runs under an account that impersonates a client. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmanconnectionoptions [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSManConnectionOptions")] [ComImport, Guid("F704E861-9E52-464f-B786-DA5EB2320FDD"), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface IWSManConnectionOptions { /// /// /// Sets and gets the user name of a local or a domain account on the remote computer. This property determines the user name /// for authentication. If no value is supplied and the WSManFlagCredUsernamePassword flag is not set, then the user name /// of the account that is running the script is used. /// /// /// If the WSManFlagCredUsernamePassword flag is set but no user name is specified, the script prompts the user to enter /// the user name and password. If no user name and password are entered then an access denied error is returned. For more /// information, see Authentication for Remote Connections. /// /// This property is read/write. /// /// /// You can supply UserName and Password for a domain account when using Negotiate or Kerberos authentication, or for a local /// account with Basic authentication. To connect to a local account, the WSMan.CreateSession flags must contain the combination /// of the WSManFlagUseBasic flag and the WsmanFlagCredUserNamePassword flag. To connect to a domain account, the /// WSMan.CreateSession flags must contain the combination of the WSManFlagUseNegotiate flag and the /// WsmanFlagCredUserNamePassword flag, or the combination of the WSManFlagUseKerberos flag and the /// WsmanFlagCredUserNamePassword flag. For a domain account, UserName must be specified in the form /// "computer\username", where the "computer" part of the string can be either the name or the IP address. For more information, /// see Authentication for Remote Connections. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptions-get_username HRESULT // get_UserName( BSTR *name ); [DispId(1)] string UserName { [DispId(1)] [return: MarshalAs(UnmanagedType.BStr)] get; [DispId(1)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } /// /// /// Sets the password of a local or a domain account on the remote computer. For more information, see Authentication for Remote Connections. /// /// This property is write-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptions-put_password HRESULT // put_Password( BSTR password ); [DispId(2)] string Password { [DispId(2)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } } /// /// The IWSManConnectionOptionsEx object is passed to the IWSMan::CreateSession method to provide the thumbprint of the /// client certificate used for authentication. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmanconnectionoptionsex [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSManConnectionOptionsEx")] [ComImport, Guid("EF43EDF7-2A48-4d93-9526-8BD6AB6D4A6B"), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface IWSManConnectionOptionsEx : IWSManConnectionOptions { /// /// /// Sets and gets the user name of a local or a domain account on the remote computer. This property determines the user name /// for authentication. If no value is supplied and the WSManFlagCredUsernamePassword flag is not set, then the user name /// of the account that is running the script is used. /// /// /// If the WSManFlagCredUsernamePassword flag is set but no user name is specified, the script prompts the user to enter /// the user name and password. If no user name and password are entered then an access denied error is returned. For more /// information, see Authentication for Remote Connections. /// /// This property is read/write. /// /// /// You can supply UserName and Password for a domain account when using Negotiate or Kerberos authentication, or for a local /// account with Basic authentication. To connect to a local account, the WSMan.CreateSession flags must contain the combination /// of the WSManFlagUseBasic flag and the WsmanFlagCredUserNamePassword flag. To connect to a domain account, the /// WSMan.CreateSession flags must contain the combination of the WSManFlagUseNegotiate flag and the /// WsmanFlagCredUserNamePassword flag, or the combination of the WSManFlagUseKerberos flag and the /// WsmanFlagCredUserNamePassword flag. For a domain account, UserName must be specified in the form /// "computer\username", where the "computer" part of the string can be either the name or the IP address. For more information, /// see Authentication for Remote Connections. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptions-get_username HRESULT // get_UserName( BSTR *name ); [DispId(1)] new string UserName { [DispId(1)] [return: MarshalAs(UnmanagedType.BStr)] get; [DispId(1)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } /// /// /// Sets the password of a local or a domain account on the remote computer. For more information, see Authentication for Remote Connections. /// /// This property is write-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptions-put_password HRESULT // put_Password( BSTR password ); [DispId(2)] new string Password { [DispId(2)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } /// /// Sets or gets the certificate thumbprint to use when authenticating by using client certificate authentication. /// This property is read/write. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex-get_certificatethumbprint // HRESULT get_CertificateThumbprint( BSTR *thumbprint ); [DispId(3)] string CertificateThumbprint { [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] get; [DispId(3)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } } /// /// The IWSManConnectionOptionsEx2 object is passed to the IWSMan::CreateSession method to provide the authentication /// mechanism, access type, and credentials to connect to a proxy server. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmanconnectionoptionsex2 [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSManConnectionOptionsEx2")] [ComImport, Guid("F500C9EC-24EE-48ab-B38D-FC9A164C658E"), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface IWSManConnectionOptionsEx2 : IWSManConnectionOptionsEx { /// /// /// Sets and gets the user name of a local or a domain account on the remote computer. This property determines the user name /// for authentication. If no value is supplied and the WSManFlagCredUsernamePassword flag is not set, then the user name /// of the account that is running the script is used. /// /// /// If the WSManFlagCredUsernamePassword flag is set but no user name is specified, the script prompts the user to enter /// the user name and password. If no user name and password are entered then an access denied error is returned. For more /// information, see Authentication for Remote Connections. /// /// This property is read/write. /// /// /// You can supply UserName and Password for a domain account when using Negotiate or Kerberos authentication, or for a local /// account with Basic authentication. To connect to a local account, the WSMan.CreateSession flags must contain the combination /// of the WSManFlagUseBasic flag and the WsmanFlagCredUserNamePassword flag. To connect to a domain account, the /// WSMan.CreateSession flags must contain the combination of the WSManFlagUseNegotiate flag and the /// WsmanFlagCredUserNamePassword flag, or the combination of the WSManFlagUseKerberos flag and the /// WsmanFlagCredUserNamePassword flag. For a domain account, UserName must be specified in the form /// "computer\username", where the "computer" part of the string can be either the name or the IP address. For more information, /// see Authentication for Remote Connections. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptions-get_username HRESULT // get_UserName( BSTR *name ); [DispId(1)] new string UserName { [DispId(1)] [return: MarshalAs(UnmanagedType.BStr)] get; [DispId(1)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } /// /// /// Sets the password of a local or a domain account on the remote computer. For more information, see Authentication for Remote Connections. /// /// This property is write-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptions-put_password HRESULT // put_Password( BSTR password ); [DispId(2)] new string Password { [DispId(2)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } /// /// Sets or gets the certificate thumbprint to use when authenticating by using client certificate authentication. /// This property is read/write. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex-get_certificatethumbprint // HRESULT get_CertificateThumbprint( BSTR *thumbprint ); [DispId(3)] new string CertificateThumbprint { [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] get; [DispId(3)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } /// Sets the proxy information for the session. /// /// Specifies the proxy access type. This parameter must be set to one of the values in the WSManProxyAccessTypeFlags /// enumeration. The default value is WSManProxyWinHttpConfig. /// /// /// Specifies the authentication mechanism to use for the proxy. This parameter is optional and the default value is 0. If this /// parameter is set to 0, the WinRM client chooses either Kerberos or Negotiate. Otherwise, this parameter must be set to one /// of the values in the WSManProxyAuthenticationFlags enumeration. The default value from the enumeration is WSManFlagProxyAuthenticationUseNegotiate. /// /// /// Specifies the user name for proxy authentication. This parameter is optional. If a value is not specified for this /// parameter, the default credentials are used. /// /// /// Specifies the password for proxy authentication. This parameter is optional. If a value is not specified for this parameter, /// the default credentials are used. /// /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// The default credentials are the credentials under which the current thread is operating. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex2-setproxy HRESULT // SetProxy( long accessType, long authenticationMechanism, BSTR userName, BSTR password ); [PreserveSig, DispId(4)] HRESULT SetProxy([Optional] WSManProxyAccessTypeFlags accessType, [Optional] WSManProxyAuthenticationFlags authenticationMechanism, [Optional, MarshalAs(UnmanagedType.BStr)] string? userName, [Optional, MarshalAs(UnmanagedType.BStr)] string? password); /// /// Returns the value of the proxy access type flag WSManProxyIEConfig for use in the accessType parameter of the /// IWSManConnectionOptionsEx2::SetProxy method. /// /// Specifies the value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex2-proxyieconfig HRESULT // ProxyIEConfig( long *value ); [DispId(5)] WSManProxyAccessTypeFlags ProxyIEConfig(); /// /// Returns the value of the proxy access type flag WSManProxyWinHttpConfig for use in the accessType parameter of the /// IWSManConnectionOptionsEx2::SetProxy method. /// /// Specifies the value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex2-proxywinhttpconfig // HRESULT ProxyWinHttpConfig( long *value ); [DispId(6)] WSManProxyAccessTypeFlags ProxyWinHttpConfig(); /// /// Returns the value of the proxy access type flag WSManProxyAutoDetect for use in the accessType parameter of the /// IWSManConnectionOptionsEx2::SetProxy method. /// /// Specifies the value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex2-proxyautodetect HRESULT // ProxyAutoDetect( long *value ); [DispId(7)] WSManProxyAccessTypeFlags ProxyAutoDetect(); /// /// Returns the value of the proxy access type flag WSManProxyNoProxyServer for use in the accessType parameter of the /// IWSManConnectionOptionsEx2::SetProxy method. /// /// Specifies the value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex2-proxynoproxyserver // HRESULT ProxyNoProxyServer( long *value ); [DispId(8)] WSManProxyAccessTypeFlags ProxyNoProxyServer(); /// /// Returns the value of the proxy authentication flag WSManFlagProxyAuthenticationUseNegotiate for use in the /// authenticationMechanism parameter of the IWSManConnectionOptionsEx2::SetProxy method. /// /// Specifies the value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex2-proxyauthenticationusenegotiate // HRESULT ProxyAuthenticationUseNegotiate( long *value ); [DispId(9)] WSManProxyAuthenticationFlags ProxyAuthenticationUseNegotiate(); /// /// Returns the value of the proxy authentication flag WSManFlagProxyAuthenticationUseBasic for use in the /// authenticationMechanism parameter of the IWSManConnectionOptionsEx2::SetProxy method. /// /// Specifies the value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex2-proxyauthenticationusebasic // HRESULT ProxyAuthenticationUseBasic( long *value ); [DispId(10)] WSManProxyAuthenticationFlags ProxyAuthenticationUseBasic(); /// /// Returns the value of the proxy authentication flag WSManFlagProxyAuthenticationUseDigest for use in the /// authenticationMechanism parameter of the IWSManConnectionOptionsEx2::SetProxy method. /// /// Specifies the value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanconnectionoptionsex2-proxyauthenticationusedigest // HRESULT ProxyAuthenticationUseDigest( long *value ); [DispId(11)] WSManProxyAuthenticationFlags ProxyAuthenticationUseDigest(); } /// /// Represents a stream of results returned from operations such as a WS-Management protocol WS-Enumeration:Enumerate operation. /// /// /// The corresponding scripting object is Enumerator. /// To limit the number of items that are read, set the IWSManSession::BatchItems property. /// Be aware that freeing the enumeration object clears pending enumeration requests. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmanenumerator [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSManEnumerator")] [ComImport, Guid("F3457CA9-ABB9-4fa5-B850-90E8CA300E7F"), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface IWSManEnumerator { /// Retrieves an item from the resource and returns an XML representation of the item. /// The XML representation of the item. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// To start an enumeration, use IWSManSession.Enumerate. To perform a WS-Eventing:Pull operation that continues reading items /// in the enumeration, use IWSManEnumerator.ReadItem. /// /// To limit the number of items that are read, set the Session.BatchItems property. /// Be aware that freeing the enumeration object clears pending enumeration requests. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanenumerator-readitem HRESULT ReadItem( BSTR // *resource ); [PreserveSig, DispId(1)] HRESULT ReadItem([MarshalAs(UnmanagedType.BStr)] out string resource); /// /// Indicates that the end of items in the IWSManEnumerator object has been reached by calls to IWSManEnumerator::ReadItem. /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanenumerator-get_atendofstream HRESULT // get_AtEndOfStream( VARIANT_BOOL *eos ); [DispId(2)] bool AtEndOfStream { [DispId(2)] get; } /// /// Gets an XML representation of additional error information. /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanenumerator-get_error HRESULT get_Error( BSTR // *value ); [DispId(8)] string Error { [DispId(8)] [return: MarshalAs(UnmanagedType.BStr)] get; } } /// /// Extends the methods and properties of the IWSMan interface to include creating IWSManResourceLocator objects, methods that /// return enumeration and session flag values, and a method to get extended error information. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmanex [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSManEx")] [ComImport, Guid("2D53BDAA-798E-49e6-A1AA-74D01256F411"), InterfaceType(ComInterfaceType.InterfaceIsDual)] [CoClass(typeof(WSMan))] public interface IWSManEx : IWSMan { /// Creates a Session object that can then be used for subsequent network operations. /// /// The protocol and service to connect to, including either IPv4 or IPv6. The format of the connection information is as /// follows: <Transport><Address><Suffix>. For examples, see Remarks. If no connection information is /// provided, the local computer is used. /// /// /// /// The session flags that specify the authentication method, such as Negotiate authentication or Digest authentication, for /// connecting to a remote computer. These flags also specify other session connection information, such as encoding or /// encryption. This parameter must contain one or more of the flags in __WSManSessionFlags for a remote connection. For /// more information, see Session Constants. No flag settings are required for a connection to the WinRM service on the local computer. /// /// /// If no authentication flags are specified, Kerberos is used unless one of the following conditions is true, in which case /// Negotiate is used: /// /// /// /// explicit credentials are supplied and the destination host is trusted /// /// /// the destination host is "localhost", "127.0.0.1" or "[::1]" /// /// /// the client computer is in a workgroup and the destination host is trusted /// /// /// For more information, see /// Authentication for Remote Connections /// and the /// connectionOptions /// parameter. /// /// /// A pointer to an IWSManConnectionOptions object that contains a user name and password. The default is NULL. /// /// A pointer to a new IWSManSession object. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// The following list contains examples of formats used to specify connection information in the connection parameter (when /// creating an HTTPS session, the <Address> field must match the server computer certificate name, otherwise a failure occurs): /// /// /// /// "https://service" /// Uses HTTPS to connect to the default web service location. /// /// /// /// "https://service.corp.com/websvcs/wsman" /// Uses HTTPS to connect to the specific web service location. /// /// /// /// "https://[E3D7:0000:0000:0000:51F4:9BC8:C0A8:6420]" /// Uses HTTPS and IPv6 with the default port. /// /// /// /// "https://[E3D7:0000:0000:0000:51F4:9BC8:C0A8:6420]:9999/wsman" /// Uses HTTPS and IPv6 with the given port. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-createsession HRESULT CreateSession( BSTR // connection, long flags, IDispatch *connectionOptions, IDispatch **session ); [PreserveSig, DispId(1)] new HRESULT CreateSession([MarshalAs(UnmanagedType.BStr)] string connection, [Optional] WSManSessionFlags flags, IWSManConnectionOptions? connectionOptions, out IWSManSession session); /// Creates an IWSManConnectionOptions object that specifies the user name and password used when creating a session. /// A pointer to a new IWSManConnectionOptions object. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-createconnectionoptions HRESULT // CreateConnectionOptions( IDispatch **connectionOptions ); [PreserveSig, DispId(2)] new HRESULT CreateConnectionOptions(out IWSManConnectionOptions connectionOptions); /// /// Gets the command line of the process that loads the automation component. /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/winrm/wsman-commandline WSMan.CommandLine As BSTR [DispId(3)] new string CommandLine { [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// /// /// Gets additional error information, in an XML stream, for the preceding call to an IWSMan method if Windows Remote Management /// service was unable to create an IWSManSession object, an IWSManConnectionOptions object, or an IWSManResourceLocator object. /// /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-get_error HRESULT get_Error( BSTR *value ); [DispId(4)] new string Error { [DispId(4)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// /// Creates a ResourceLocator object that can be used instead of a resource URI in Session object operations such as /// IWSManSession.Get, IWSManSession.Put, or Session.Enumerate. /// /// /// The resource URI for the resource. For more information about URI strings, see Resource URIs. /// /// A pointer to a new instance of IWSManResourceLocator. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// If the FragmentDialect property is not specified in the IWSManResourceLocator object, the default is the XPath 1.0 /// specification. For more information, see http://www.w3.org/TR/xpath. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-createresourcelocator HRESULT // CreateResourceLocator( BSTR strResourceLocator, IDispatch **newResourceLocator ); [PreserveSig, DispId(5)] HRESULT CreateResourceLocator([MarshalAs(UnmanagedType.BStr)] string strResourceLocator, out IWSManResourceLocator newResourceLocator); /// /// /// The WSMan.SessionFlagUTF8 method returns the value of the authentication flag WSManFlagUTF8 for use in the flags /// parameter of IWSMan::CreateSession. /// /// /// WSManFlagUTF8 is a constant in the __WSManSessionFlags enumeration. For more information, see Other Session Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagutf8 HRESULT SessionFlagUTF8( // long *flags ); [DispId(6)] WSManSessionFlags SessionFlagUTF8(); /// /// /// The IWSMan.SessionFlagCredUsernamePassword method returns the value of the authentication flag /// WSManFlagCredUsernamePassword for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagCredUsernamePassword is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagcredusernamepassword HRESULT // SessionFlagCredUsernamePassword( long *flags ); [DispId(7)] WSManSessionFlags SessionFlagCredUsernamePassword(); /// /// /// The WSMan.SessionFlagSkipCACheck method returns the value of the WSManFlagSkipCACheck authentication flag for use in /// the flags parameter of the IWSMan::CreateSession method. /// /// /// WSManFlagSkipCACheck is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagskipcacheck HRESULT // SessionFlagSkipCACheck( long *flags ); [DispId(8)] WSManSessionFlags SessionFlagSkipCACheck(); /// /// /// The WSMan.SessionFlagSkipCNCheck method returns the value of the authentication flag WSManFlagSkipCNCheck for use in /// the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagSkipCNCheck is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagskipcncheck HRESULT // SessionFlagSkipCNCheck( long *flags ); [DispId(9)] WSManSessionFlags SessionFlagSkipCNCheck(); /// /// /// The WSMan.SessionFlagUseDigest method returns the value of the authentication flag WSManFlagUseDigest for use in the /// flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseDigest is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusedigest HRESULT // SessionFlagUseDigest( long *flags ); [DispId(10)] WSManSessionFlags SessionFlagUseDigest(); /// /// /// The WSMan.SessionFlagUseNegotiate method returns the value of the authentication flag WSManFlagUseNegotiate for use /// in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseNegotiate is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusenegotiate HRESULT // SessionFlagUseNegotiate( long *flags ); [DispId(11)] WSManSessionFlags SessionFlagUseNegotiate(); /// /// /// The WSMan.SessionFlagUseBasic method returns the value of the authentication flag WSManFlagUseBasic for use in the /// flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseBasic is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusebasic HRESULT // SessionFlagUseBasic( long *flags ); [DispId(12)] WSManSessionFlags SessionFlagUseBasic(); /// /// /// The WSMan.WSMan.SessionFlagUseKerberos method returns the value of the authentication flag WSManFlagUseKerberos for /// use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseKerberos is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusekerberos HRESULT // SessionFlagUseKerberos( long *flags ); [DispId(13)] WSManSessionFlags SessionFlagUseKerberos(); /// /// /// The WSMan.SessionFlagNoEncryption method returns the value of the authentication flag WSManFlagNoEncryption for use /// in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagNoEncryption is a constant in the __WSManSessionFlags enumeration. For more information, see Other /// Session Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagnoencryption HRESULT // SessionFlagNoEncryption( long *flags ); [DispId(14)] WSManSessionFlags SessionFlagNoEncryption(); /// /// /// The WSMan.SessionFlagEnableSPNServerPort method returns the value of the authentication flag /// WSManFlagEnableSPNServerPort for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagEnableSPNServerPort is a constant in the __WSManSessionFlags enumeration. For more information, see /// Other Session Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagenablespnserverport HRESULT // SessionFlagEnableSPNServerPort( long *flags ); [DispId(15)] WSManSessionFlags SessionFlagEnableSPNServerPort(); /// /// /// The WSMan.SessionFlagUseNoAuthentication method returns the value of the authentication flag /// WSManFlagUseNoAuthentication for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseNoAuthentication is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusenoauthentication HRESULT // SessionFlagUseNoAuthentication( long *flags ); [DispId(16)] WSManSessionFlags SessionFlagUseNoAuthentication(); /// /// /// The IWSManEx::EnumerationFlagNonXmlText method returns the value of the enumeration constant /// WSManFlagNonXmlText for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// WSManFlagNonXmlText is a constant in the __WSManEnumFlags enumeration. For more information, see Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagnonxmltext HRESULT // EnumerationFlagNonXmlText( long *flags ); [DispId(17)] WSManEnumFlags EnumerationFlagNonXmlText(); /// /// /// The IWSManEx::EnumerationFlagReturnEPR method returns the value of the enumeration constant /// EnumerationFlagReturnEPR for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagReturnEPR is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagreturnepr HRESULT // EnumerationFlagReturnEPR( long *flags ); [DispId(18)] WSManEnumFlags EnumerationFlagReturnEPR(); /// /// /// The IWSManEx::EnumerationFlagReturnObjectAndEPR method returns the value of the enumeration constant /// EnumerationFlagReturnObjectAndEPR for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagReturnObjectAndEPR is a constant in the _WSManEnumFlags enumeration and is described in /// Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagreturnobjectandepr HRESULT // EnumerationFlagReturnObjectAndEPR( long *flags ); [DispId(19)] WSManEnumFlags EnumerationFlagReturnObjectAndEPR(); /// /// Returns a formatted string containing the text of an error number. This method performs the same operation as the /// Winrm command-line winrm helpmsg error number. /// /// /// Error message number in decimal or hexadecimal from WinRM, WinHTTP, or other operating system components. /// /// Error message string formatted like messages returned from the Winrm command. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// The corresponding scripting method is WSMan.GetErrorMessage. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-geterrormessage HRESULT GetErrorMessage( // DWORD errorNumber, BSTR *errorMessage ); [PreserveSig, DispId(20)] HRESULT GetErrorMessage(uint errorNumber, [MarshalAs(UnmanagedType.BStr)] out string errorMessage); /// /// /// The IWSManEx::EnumerationFlagHierarchyDeep method returns the value of the enumeration constant /// EnumerationFlagHierarchyDeep for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagHierarchyDeep is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflaghierarchydeep HRESULT // EnumerationFlagHierarchyDeep( long *flags ); [DispId(21)] WSManEnumFlags EnumerationFlagHierarchyDeep(); /// /// /// The IWSManEx::EnumerationFlagHierarchyShallow method returns the value of the enumeration constant /// EnumerationFlagHierarchyShallow for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagHierarchyShallow is a constant in the _WSManEnumFlags enumeration and is described in /// Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflaghierarchyshallow HRESULT // EnumerationFlagHierarchyShallow( long *flags ); [DispId(22)] WSManEnumFlags EnumerationFlagHierarchyShallow(); /// /// /// The IWSManEx::EnumerationFlagHierarchyDeepBasePropsOnly method returns the value of the enumeration constant /// EnumerationFlagHierarchyDeepBasePropsOnly for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagHierarchyDeepBasePropsOnly is a constant in the _WSManEnumFlags enumeration and is described in /// Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflaghierarchydeepbasepropsonly // HRESULT EnumerationFlagHierarchyDeepBasePropsOnly( long *flags ); [DispId(23)] WSManEnumFlags EnumerationFlagHierarchyDeepBasePropsOnly(); /// /// /// The IWSManEx::EnumerationFlagReturnObject method returns the value of the enumeration constant /// EnumerationFlagReturnObject for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagReturnObject is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagreturnobject HRESULT // EnumerationFlagReturnObject( long *flags ); [DispId(24)] WSManEnumFlags EnumerationFlagReturnObject(); } /// /// Extends the methods and properties of the IWSManEx interface to include a method that returns a session flag value related to /// authentication using client certificates. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmanex2 [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSManEx2")] [ComImport, Guid("1D1B5AE0-42D9-4021-8261-3987619512E9"), InterfaceType(ComInterfaceType.InterfaceIsDual)] [CoClass(typeof(WSMan))] public interface IWSManEx2 : IWSManEx { /// Creates a Session object that can then be used for subsequent network operations. /// /// The protocol and service to connect to, including either IPv4 or IPv6. The format of the connection information is as /// follows: <Transport><Address><Suffix>. For examples, see Remarks. If no connection information is /// provided, the local computer is used. /// /// /// /// The session flags that specify the authentication method, such as Negotiate authentication or Digest authentication, for /// connecting to a remote computer. These flags also specify other session connection information, such as encoding or /// encryption. This parameter must contain one or more of the flags in __WSManSessionFlags for a remote connection. For /// more information, see Session Constants. No flag settings are required for a connection to the WinRM service on the local computer. /// /// /// If no authentication flags are specified, Kerberos is used unless one of the following conditions is true, in which case /// Negotiate is used: /// /// /// /// explicit credentials are supplied and the destination host is trusted /// /// /// the destination host is "localhost", "127.0.0.1" or "[::1]" /// /// /// the client computer is in a workgroup and the destination host is trusted /// /// /// For more information, see /// Authentication for Remote Connections /// and the /// connectionOptions /// parameter. /// /// /// A pointer to an IWSManConnectionOptions object that contains a user name and password. The default is NULL. /// /// A pointer to a new IWSManSession object. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// The following list contains examples of formats used to specify connection information in the connection parameter (when /// creating an HTTPS session, the <Address> field must match the server computer certificate name, otherwise a failure occurs): /// /// /// /// "https://service" /// Uses HTTPS to connect to the default web service location. /// /// /// /// "https://service.corp.com/websvcs/wsman" /// Uses HTTPS to connect to the specific web service location. /// /// /// /// "https://[E3D7:0000:0000:0000:51F4:9BC8:C0A8:6420]" /// Uses HTTPS and IPv6 with the default port. /// /// /// /// "https://[E3D7:0000:0000:0000:51F4:9BC8:C0A8:6420]:9999/wsman" /// Uses HTTPS and IPv6 with the given port. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-createsession HRESULT CreateSession( BSTR // connection, long flags, IDispatch *connectionOptions, IDispatch **session ); [PreserveSig, DispId(1)] new HRESULT CreateSession([MarshalAs(UnmanagedType.BStr)] string connection, [Optional] WSManSessionFlags flags, IWSManConnectionOptions? connectionOptions, out IWSManSession session); /// Creates an IWSManConnectionOptions object that specifies the user name and password used when creating a session. /// A pointer to a new IWSManConnectionOptions object. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-createconnectionoptions HRESULT // CreateConnectionOptions( IDispatch **connectionOptions ); [PreserveSig, DispId(2)] new HRESULT CreateConnectionOptions(out IWSManConnectionOptions connectionOptions); /// /// Gets the command line of the process that loads the automation component. /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/winrm/wsman-commandline WSMan.CommandLine As BSTR [DispId(3)] new string CommandLine { [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// /// /// Gets additional error information, in an XML stream, for the preceding call to an IWSMan method if Windows Remote Management /// service was unable to create an IWSManSession object, an IWSManConnectionOptions object, or an IWSManResourceLocator object. /// /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-get_error HRESULT get_Error( BSTR *value ); [DispId(4)] new string Error { [DispId(4)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// /// Creates a ResourceLocator object that can be used instead of a resource URI in Session object operations such as /// IWSManSession.Get, IWSManSession.Put, or Session.Enumerate. /// /// /// The resource URI for the resource. For more information about URI strings, see Resource URIs. /// /// A pointer to a new instance of IWSManResourceLocator. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// If the FragmentDialect property is not specified in the IWSManResourceLocator object, the default is the XPath 1.0 /// specification. For more information, see http://www.w3.org/TR/xpath. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-createresourcelocator HRESULT // CreateResourceLocator( BSTR strResourceLocator, IDispatch **newResourceLocator ); [PreserveSig, DispId(5)] new HRESULT CreateResourceLocator([MarshalAs(UnmanagedType.BStr)] string strResourceLocator, out IWSManResourceLocator newResourceLocator); /// /// /// The WSMan.SessionFlagUTF8 method returns the value of the authentication flag WSManFlagUTF8 for use in the flags /// parameter of IWSMan::CreateSession. /// /// /// WSManFlagUTF8 is a constant in the __WSManSessionFlags enumeration. For more information, see Other Session Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagutf8 HRESULT SessionFlagUTF8( // long *flags ); [DispId(6)] new WSManSessionFlags SessionFlagUTF8(); /// /// /// The IWSMan.SessionFlagCredUsernamePassword method returns the value of the authentication flag /// WSManFlagCredUsernamePassword for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagCredUsernamePassword is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagcredusernamepassword HRESULT // SessionFlagCredUsernamePassword( long *flags ); [DispId(7)] new WSManSessionFlags SessionFlagCredUsernamePassword(); /// /// /// The WSMan.SessionFlagSkipCACheck method returns the value of the WSManFlagSkipCACheck authentication flag for use in /// the flags parameter of the IWSMan::CreateSession method. /// /// /// WSManFlagSkipCACheck is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagskipcacheck HRESULT // SessionFlagSkipCACheck( long *flags ); [DispId(8)] new WSManSessionFlags SessionFlagSkipCACheck(); /// /// /// The WSMan.SessionFlagSkipCNCheck method returns the value of the authentication flag WSManFlagSkipCNCheck for use in /// the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagSkipCNCheck is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagskipcncheck HRESULT // SessionFlagSkipCNCheck( long *flags ); [DispId(9)] new WSManSessionFlags SessionFlagSkipCNCheck(); /// /// /// The WSMan.SessionFlagUseDigest method returns the value of the authentication flag WSManFlagUseDigest for use in the /// flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseDigest is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusedigest HRESULT // SessionFlagUseDigest( long *flags ); [DispId(10)] new WSManSessionFlags SessionFlagUseDigest(); /// /// /// The WSMan.SessionFlagUseNegotiate method returns the value of the authentication flag WSManFlagUseNegotiate for use /// in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseNegotiate is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusenegotiate HRESULT // SessionFlagUseNegotiate( long *flags ); [DispId(11)] new WSManSessionFlags SessionFlagUseNegotiate(); /// /// /// The WSMan.SessionFlagUseBasic method returns the value of the authentication flag WSManFlagUseBasic for use in the /// flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseBasic is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusebasic HRESULT // SessionFlagUseBasic( long *flags ); [DispId(12)] new WSManSessionFlags SessionFlagUseBasic(); /// /// /// The WSMan.WSMan.SessionFlagUseKerberos method returns the value of the authentication flag WSManFlagUseKerberos for /// use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseKerberos is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusekerberos HRESULT // SessionFlagUseKerberos( long *flags ); [DispId(13)] new WSManSessionFlags SessionFlagUseKerberos(); /// /// /// The WSMan.SessionFlagNoEncryption method returns the value of the authentication flag WSManFlagNoEncryption for use /// in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagNoEncryption is a constant in the __WSManSessionFlags enumeration. For more information, see Other /// Session Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagnoencryption HRESULT // SessionFlagNoEncryption( long *flags ); [DispId(14)] new WSManSessionFlags SessionFlagNoEncryption(); /// /// /// The WSMan.SessionFlagEnableSPNServerPort method returns the value of the authentication flag /// WSManFlagEnableSPNServerPort for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagEnableSPNServerPort is a constant in the __WSManSessionFlags enumeration. For more information, see /// Other Session Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagenablespnserverport HRESULT // SessionFlagEnableSPNServerPort( long *flags ); [DispId(15)] new WSManSessionFlags SessionFlagEnableSPNServerPort(); /// /// /// The WSMan.SessionFlagUseNoAuthentication method returns the value of the authentication flag /// WSManFlagUseNoAuthentication for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseNoAuthentication is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusenoauthentication HRESULT // SessionFlagUseNoAuthentication( long *flags ); [DispId(16)] new WSManSessionFlags SessionFlagUseNoAuthentication(); /// /// /// The IWSManEx::EnumerationFlagNonXmlText method returns the value of the enumeration constant /// WSManFlagNonXmlText for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// WSManFlagNonXmlText is a constant in the __WSManEnumFlags enumeration. For more information, see Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagnonxmltext HRESULT // EnumerationFlagNonXmlText( long *flags ); [DispId(17)] new WSManEnumFlags EnumerationFlagNonXmlText(); /// /// /// The IWSManEx::EnumerationFlagReturnEPR method returns the value of the enumeration constant /// EnumerationFlagReturnEPR for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagReturnEPR is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagreturnepr HRESULT // EnumerationFlagReturnEPR( long *flags ); [DispId(18)] new WSManEnumFlags EnumerationFlagReturnEPR(); /// /// /// The IWSManEx::EnumerationFlagReturnObjectAndEPR method returns the value of the enumeration constant /// EnumerationFlagReturnObjectAndEPR for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagReturnObjectAndEPR is a constant in the _WSManEnumFlags enumeration and is described in /// Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagreturnobjectandepr HRESULT // EnumerationFlagReturnObjectAndEPR( long *flags ); [DispId(19)] new WSManEnumFlags EnumerationFlagReturnObjectAndEPR(); /// /// Returns a formatted string containing the text of an error number. This method performs the same operation as the /// Winrm command-line winrm helpmsg error number. /// /// /// Error message number in decimal or hexadecimal from WinRM, WinHTTP, or other operating system components. /// /// Error message string formatted like messages returned from the Winrm command. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// The corresponding scripting method is WSMan.GetErrorMessage. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-geterrormessage HRESULT GetErrorMessage( // DWORD errorNumber, BSTR *errorMessage ); [PreserveSig, DispId(20)] new HRESULT GetErrorMessage(uint errorNumber, [MarshalAs(UnmanagedType.BStr)] out string errorMessage); /// /// /// The IWSManEx::EnumerationFlagHierarchyDeep method returns the value of the enumeration constant /// EnumerationFlagHierarchyDeep for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagHierarchyDeep is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflaghierarchydeep HRESULT // EnumerationFlagHierarchyDeep( long *flags ); [DispId(21)] new WSManEnumFlags EnumerationFlagHierarchyDeep(); /// /// /// The IWSManEx::EnumerationFlagHierarchyShallow method returns the value of the enumeration constant /// EnumerationFlagHierarchyShallow for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagHierarchyShallow is a constant in the _WSManEnumFlags enumeration and is described in /// Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflaghierarchyshallow HRESULT // EnumerationFlagHierarchyShallow( long *flags ); [DispId(22)] new WSManEnumFlags EnumerationFlagHierarchyShallow(); /// /// /// The IWSManEx::EnumerationFlagHierarchyDeepBasePropsOnly method returns the value of the enumeration constant /// EnumerationFlagHierarchyDeepBasePropsOnly for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagHierarchyDeepBasePropsOnly is a constant in the _WSManEnumFlags enumeration and is described in /// Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflaghierarchydeepbasepropsonly // HRESULT EnumerationFlagHierarchyDeepBasePropsOnly( long *flags ); [DispId(23)] new WSManEnumFlags EnumerationFlagHierarchyDeepBasePropsOnly(); /// /// /// The IWSManEx::EnumerationFlagReturnObject method returns the value of the enumeration constant /// EnumerationFlagReturnObject for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagReturnObject is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagreturnobject HRESULT // EnumerationFlagReturnObject( long *flags ); [DispId(24)] new WSManEnumFlags EnumerationFlagReturnObject(); /// /// /// Returns the value of the authentication flag WSManFlagUseClientCertificate for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseClientCertificate is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The session flags to use. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex2-sessionflaguseclientcertificate HRESULT // SessionFlagUseClientCertificate( long *flags ); [DispId(25)] WSManSessionFlags SessionFlagUseClientCertificate(); } /// /// Extends the methods and properties of the IWSManEx interface to include a method that returns a session flag value related to /// authentication using the Credential Security Support Provider (CredSSP). /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmanex3 [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSManEx3")] [ComImport, Guid("6400E966-011D-4eac-8474-049E0848AFAD"), InterfaceType(ComInterfaceType.InterfaceIsDual)] [CoClass(typeof(WSMan))] public interface IWSManEx3 : IWSManEx2 { /// Creates a Session object that can then be used for subsequent network operations. /// /// The protocol and service to connect to, including either IPv4 or IPv6. The format of the connection information is as /// follows: <Transport><Address><Suffix>. For examples, see Remarks. If no connection information is /// provided, the local computer is used. /// /// /// /// The session flags that specify the authentication method, such as Negotiate authentication or Digest authentication, for /// connecting to a remote computer. These flags also specify other session connection information, such as encoding or /// encryption. This parameter must contain one or more of the flags in __WSManSessionFlags for a remote connection. For /// more information, see Session Constants. No flag settings are required for a connection to the WinRM service on the local computer. /// /// /// If no authentication flags are specified, Kerberos is used unless one of the following conditions is true, in which case /// Negotiate is used: /// /// /// /// explicit credentials are supplied and the destination host is trusted /// /// /// the destination host is "localhost", "127.0.0.1" or "[::1]" /// /// /// the client computer is in a workgroup and the destination host is trusted /// /// /// For more information, see /// Authentication for Remote Connections /// and the /// connectionOptions /// parameter. /// /// /// A pointer to an IWSManConnectionOptions object that contains a user name and password. The default is NULL. /// /// A pointer to a new IWSManSession object. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// The following list contains examples of formats used to specify connection information in the connection parameter (when /// creating an HTTPS session, the <Address> field must match the server computer certificate name, otherwise a failure occurs): /// /// /// /// "https://service" /// Uses HTTPS to connect to the default web service location. /// /// /// /// "https://service.corp.com/websvcs/wsman" /// Uses HTTPS to connect to the specific web service location. /// /// /// /// "https://[E3D7:0000:0000:0000:51F4:9BC8:C0A8:6420]" /// Uses HTTPS and IPv6 with the default port. /// /// /// /// "https://[E3D7:0000:0000:0000:51F4:9BC8:C0A8:6420]:9999/wsman" /// Uses HTTPS and IPv6 with the given port. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-createsession HRESULT CreateSession( BSTR // connection, long flags, IDispatch *connectionOptions, IDispatch **session ); [PreserveSig, DispId(1)] new HRESULT CreateSession([MarshalAs(UnmanagedType.BStr)] string connection, [Optional] WSManSessionFlags flags, IWSManConnectionOptions? connectionOptions, out IWSManSession session); /// Creates an IWSManConnectionOptions object that specifies the user name and password used when creating a session. /// A pointer to a new IWSManConnectionOptions object. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-createconnectionoptions HRESULT // CreateConnectionOptions( IDispatch **connectionOptions ); [PreserveSig, DispId(2)] new HRESULT CreateConnectionOptions(out IWSManConnectionOptions connectionOptions); /// /// Gets the command line of the process that loads the automation component. /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/winrm/wsman-commandline WSMan.CommandLine As BSTR [DispId(3)] new string CommandLine { [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// /// /// Gets additional error information, in an XML stream, for the preceding call to an IWSMan method if Windows Remote Management /// service was unable to create an IWSManSession object, an IWSManConnectionOptions object, or an IWSManResourceLocator object. /// /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsman-get_error HRESULT get_Error( BSTR *value ); [DispId(4)] new string Error { [DispId(4)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// /// Creates a ResourceLocator object that can be used instead of a resource URI in Session object operations such as /// IWSManSession.Get, IWSManSession.Put, or Session.Enumerate. /// /// /// The resource URI for the resource. For more information about URI strings, see Resource URIs. /// /// A pointer to a new instance of IWSManResourceLocator. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// If the FragmentDialect property is not specified in the IWSManResourceLocator object, the default is the XPath 1.0 /// specification. For more information, see http://www.w3.org/TR/xpath. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-createresourcelocator HRESULT // CreateResourceLocator( BSTR strResourceLocator, IDispatch **newResourceLocator ); [PreserveSig, DispId(5)] new HRESULT CreateResourceLocator([MarshalAs(UnmanagedType.BStr)] string strResourceLocator, out IWSManResourceLocator newResourceLocator); /// /// /// The WSMan.SessionFlagUTF8 method returns the value of the authentication flag WSManFlagUTF8 for use in the flags /// parameter of IWSMan::CreateSession. /// /// /// WSManFlagUTF8 is a constant in the __WSManSessionFlags enumeration. For more information, see Other Session Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagutf8 HRESULT SessionFlagUTF8( // long *flags ); [DispId(6)] new WSManSessionFlags SessionFlagUTF8(); /// /// /// The IWSMan.SessionFlagCredUsernamePassword method returns the value of the authentication flag /// WSManFlagCredUsernamePassword for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagCredUsernamePassword is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagcredusernamepassword HRESULT // SessionFlagCredUsernamePassword( long *flags ); [DispId(7)] new WSManSessionFlags SessionFlagCredUsernamePassword(); /// /// /// The WSMan.SessionFlagSkipCACheck method returns the value of the WSManFlagSkipCACheck authentication flag for use in /// the flags parameter of the IWSMan::CreateSession method. /// /// /// WSManFlagSkipCACheck is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagskipcacheck HRESULT // SessionFlagSkipCACheck( long *flags ); [DispId(8)] new WSManSessionFlags SessionFlagSkipCACheck(); /// /// /// The WSMan.SessionFlagSkipCNCheck method returns the value of the authentication flag WSManFlagSkipCNCheck for use in /// the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagSkipCNCheck is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagskipcncheck HRESULT // SessionFlagSkipCNCheck( long *flags ); [DispId(9)] new WSManSessionFlags SessionFlagSkipCNCheck(); /// /// /// The WSMan.SessionFlagUseDigest method returns the value of the authentication flag WSManFlagUseDigest for use in the /// flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseDigest is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusedigest HRESULT // SessionFlagUseDigest( long *flags ); [DispId(10)] new WSManSessionFlags SessionFlagUseDigest(); /// /// /// The WSMan.SessionFlagUseNegotiate method returns the value of the authentication flag WSManFlagUseNegotiate for use /// in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseNegotiate is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusenegotiate HRESULT // SessionFlagUseNegotiate( long *flags ); [DispId(11)] new WSManSessionFlags SessionFlagUseNegotiate(); /// /// /// The WSMan.SessionFlagUseBasic method returns the value of the authentication flag WSManFlagUseBasic for use in the /// flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseBasic is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusebasic HRESULT // SessionFlagUseBasic( long *flags ); [DispId(12)] new WSManSessionFlags SessionFlagUseBasic(); /// /// /// The WSMan.WSMan.SessionFlagUseKerberos method returns the value of the authentication flag WSManFlagUseKerberos for /// use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseKerberos is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusekerberos HRESULT // SessionFlagUseKerberos( long *flags ); [DispId(13)] new WSManSessionFlags SessionFlagUseKerberos(); /// /// /// The WSMan.SessionFlagNoEncryption method returns the value of the authentication flag WSManFlagNoEncryption for use /// in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagNoEncryption is a constant in the __WSManSessionFlags enumeration. For more information, see Other /// Session Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagnoencryption HRESULT // SessionFlagNoEncryption( long *flags ); [DispId(14)] new WSManSessionFlags SessionFlagNoEncryption(); /// /// /// The WSMan.SessionFlagEnableSPNServerPort method returns the value of the authentication flag /// WSManFlagEnableSPNServerPort for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagEnableSPNServerPort is a constant in the __WSManSessionFlags enumeration. For more information, see /// Other Session Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagenablespnserverport HRESULT // SessionFlagEnableSPNServerPort( long *flags ); [DispId(15)] new WSManSessionFlags SessionFlagEnableSPNServerPort(); /// /// /// The WSMan.SessionFlagUseNoAuthentication method returns the value of the authentication flag /// WSManFlagUseNoAuthentication for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseNoAuthentication is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-sessionflagusenoauthentication HRESULT // SessionFlagUseNoAuthentication( long *flags ); [DispId(16)] new WSManSessionFlags SessionFlagUseNoAuthentication(); /// /// /// The IWSManEx::EnumerationFlagNonXmlText method returns the value of the enumeration constant /// WSManFlagNonXmlText for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// WSManFlagNonXmlText is a constant in the __WSManEnumFlags enumeration. For more information, see Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagnonxmltext HRESULT // EnumerationFlagNonXmlText( long *flags ); [DispId(17)] new WSManEnumFlags EnumerationFlagNonXmlText(); /// /// /// The IWSManEx::EnumerationFlagReturnEPR method returns the value of the enumeration constant /// EnumerationFlagReturnEPR for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagReturnEPR is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagreturnepr HRESULT // EnumerationFlagReturnEPR( long *flags ); [DispId(18)] new WSManEnumFlags EnumerationFlagReturnEPR(); /// /// /// The IWSManEx::EnumerationFlagReturnObjectAndEPR method returns the value of the enumeration constant /// EnumerationFlagReturnObjectAndEPR for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagReturnObjectAndEPR is a constant in the _WSManEnumFlags enumeration and is described in /// Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagreturnobjectandepr HRESULT // EnumerationFlagReturnObjectAndEPR( long *flags ); [DispId(19)] new WSManEnumFlags EnumerationFlagReturnObjectAndEPR(); /// /// Returns a formatted string containing the text of an error number. This method performs the same operation as the /// Winrm command-line winrm helpmsg error number. /// /// /// Error message number in decimal or hexadecimal from WinRM, WinHTTP, or other operating system components. /// /// Error message string formatted like messages returned from the Winrm command. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// The corresponding scripting method is WSMan.GetErrorMessage. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-geterrormessage HRESULT GetErrorMessage( // DWORD errorNumber, BSTR *errorMessage ); [PreserveSig, DispId(20)] new HRESULT GetErrorMessage(uint errorNumber, [MarshalAs(UnmanagedType.BStr)] out string errorMessage); /// /// /// The IWSManEx::EnumerationFlagHierarchyDeep method returns the value of the enumeration constant /// EnumerationFlagHierarchyDeep for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagHierarchyDeep is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflaghierarchydeep HRESULT // EnumerationFlagHierarchyDeep( long *flags ); [DispId(21)] new WSManEnumFlags EnumerationFlagHierarchyDeep(); /// /// /// The IWSManEx::EnumerationFlagHierarchyShallow method returns the value of the enumeration constant /// EnumerationFlagHierarchyShallow for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagHierarchyShallow is a constant in the _WSManEnumFlags enumeration and is described in /// Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflaghierarchyshallow HRESULT // EnumerationFlagHierarchyShallow( long *flags ); [DispId(22)] new WSManEnumFlags EnumerationFlagHierarchyShallow(); /// /// /// The IWSManEx::EnumerationFlagHierarchyDeepBasePropsOnly method returns the value of the enumeration constant /// EnumerationFlagHierarchyDeepBasePropsOnly for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagHierarchyDeepBasePropsOnly is a constant in the _WSManEnumFlags enumeration and is described in /// Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflaghierarchydeepbasepropsonly // HRESULT EnumerationFlagHierarchyDeepBasePropsOnly( long *flags ); [DispId(23)] new WSManEnumFlags EnumerationFlagHierarchyDeepBasePropsOnly(); /// /// /// The IWSManEx::EnumerationFlagReturnObject method returns the value of the enumeration constant /// EnumerationFlagReturnObject for use in the flags parameter of the IWSManSession::Enumerate method. /// /// /// EnumerationFlagReturnObject is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex-enumerationflagreturnobject HRESULT // EnumerationFlagReturnObject( long *flags ); [DispId(24)] new WSManEnumFlags EnumerationFlagReturnObject(); /// /// /// Returns the value of the authentication flag WSManFlagUseClientCertificate for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagUseClientCertificate is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The session flags to use. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex2-sessionflaguseclientcertificate HRESULT // SessionFlagUseClientCertificate( long *flags ); [DispId(25)] new WSManSessionFlags SessionFlagUseClientCertificate(); /// /// /// The WSMan.SessionFlagUTF16 method returns the value of the authentication flag WSManFlagUTF16 for use in the flags /// parameter of IWSMan::CreateSession. /// /// /// WSManFlagUTF16 is a constant in the __WSManSessionFlags enumeration. For more information, see Other Session Constants. /// /// /// The value of the constant. [DispId(26)] WSManSessionFlags SessionFlagUTF16(); /// /// Returns the value of the authentication flag WSManFlagUseCredSsp for use in the flags parameter of IWSMan::CreateSession. /// /// WSManFlagUseCredSsp is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanex3-sessionflagusecredssp HRESULT // SessionFlagUseCredSsp( long *flags ); [DispId(27)] WSManSessionFlags SessionFlagUseCredSsp(); /// /// /// Returns the value of the enumeration constant WSManFlagAssociationInstance for use in the flags parameter of the /// IWSManSession::Enumerate method. /// /// /// WSManFlagAssociationInstance is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. [DispId(28)] WSManEnumFlags EnumerationFlagAssociationInstance(); /// /// /// Returns the value of the enumeration constant WSManFlagAssociatedInstance for use in the flags parameter of the /// IWSManSession::Enumerate method. /// /// /// WSManFlagAssociatedInstance is a constant in the _WSManEnumFlags enumeration and is described in Enumeration Constants. /// /// /// The value of the constant. [DispId(29)] WSManEnumFlags EnumerationFlagAssociatedInstance(); /// /// /// Returns the value of the authentication flag WSManFlagSkipRevocationCheck for use in the flags parameter of IWSMan::CreateSession. /// /// /// WSManFlagSkipRevocationCheck is a constant in the __WSManSessionFlags enumeration. For more information, see /// Authentication Constants. /// /// /// The value of the constant. [DispId(30)] WSManSessionFlags SessionFlagSkipRevocationCheck(); /// /// /// Returns the value of the authentication flag WSManFlagAllowNegotiateImplicitCredentials for use in the flags /// parameter of IWSMan::CreateSession. /// /// /// WSManFlagAllowNegotiateImplicitCredentials is a constant in the __WSManSessionFlags enumeration. For more /// information, see Authentication Constants. /// /// /// The value of the constant. [DispId(31)] WSManSessionFlags SessionFlagAllowNegotiateImplicitCredentials(); /// /// Returns the value of the authentication flag WSManFlagUseSsl for use in the flags parameter of IWSMan::CreateSession. /// /// WSManFlagUseSsl is a constant in the __WSManSessionFlags enumeration. For more information, see Authentication Constants. /// /// /// The value of the constant. [DispId(32)] WSManSessionFlags SessionFlagUseSsl(); } /// /// Supplies the path to a resource. You can use an IWSManResourceLocator object instead of a resource URI in IWSManSession /// object operations such as IWSManSession.Get, IWSManSession.Put, or IWSManSession.Enumerate. /// /// The corresponding scripting object is ResourceLocator. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmanresourcelocator [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSManResourceLocator")] [ComImport, Guid("A7A1BA28-DE41-466a-AD0A-C4059EAD7428"), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface IWSManResourceLocator { /// /// /// The resource URI of the requested resource. This property can contain only the path, not a query string for specific instances. /// /// This property is read/write. /// /// /// The following is an example of a proper path for ResourceURI. /// /// "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service" /// /// /// The following path does not work because it contains a key for a specific instance. Use the /// ResourceLocator.AddSelector method to specify a particular instance. /// /// /// "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service?Name=winmgmt" /// /// IWSManResourceLocator::ResourceURI is the corresponding C++ method. /// // https://docs.microsoft.com/en-us/windows/win32/winrm/resourcelocator-resourceuri ResourceLocator.ResourceURI As string [DispId(1)] string ResourceUri { [DispId(1)] [return: MarshalAs(UnmanagedType.BStr)] get; [DispId(1)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } /// /// Adds a selector to the ResourceLocator object. The selector specifies a particular instance of a resource. You can provide /// an IWSManResourceLocator object instead of specifying a resource URI in IWSManSession object operations such as Get, Put, or Enumerate. /// /// /// The selector name. For example, when requesting WMI data, this parameter is the key property for a WMI class. /// /// /// The selector value. For example, for WMI data, this parameter contains a value for a key property that identifies a specific instance. /// /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanresourcelocator-addselector HRESULT // AddSelector( BSTR resourceSelName, VARIANT selValue ); [PreserveSig, DispId(2)] HRESULT AddSelector([MarshalAs(UnmanagedType.BStr)] string resourceSelName, [In, MarshalAs(UnmanagedType.Struct)] object selValue); /// /// Removes all the selectors from a ResourceLocator object. You can provide a ResourceLocator object instead of specifying a /// resource URI in IWSManSession object operations such as Get, Put, or Enumerate. /// /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanresourcelocator-clearselectors HRESULT ClearSelectors(); [PreserveSig, DispId(3)] HRESULT ClearSelectors(); /// /// /// Gets or sets the path for a resource fragment or property when ResourceLocator is used in Session object /// operations such as Session.Get, Session.Put, or Session.Enumerate. /// /// This property is read/write. /// /// /// IWSManResourceLocator::FragmentPath is the corresponding C++ property. /// /// You can specify one element of an array property by supplying the array index as shown in the following example. Be aware /// that array indexing starts with 1 rather than 0. /// /// /// Const Uri = "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_NetworkAdapterConfiguration" Const FragmentPath = "DNSServerSearchOrder[1]" /// /// To get the whole array, specify the array property name as shown in the following example. /// /// Const Uri = "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_NetworkAdapterConfiguration" Const FragmentPath = "DNSServerSearchOrder" /// /// // https://docs.microsoft.com/en-us/windows/win32/winrm/resourcelocator-fragmentpath ResourceLocator.FragmentPath [DispId(4)] string FragmentPath { [DispId(4)] [return: MarshalAs(UnmanagedType.BStr)] get; [DispId(4)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } /// /// /// Gets or sets the language dialect for a resource fragment dialect when ResourceLocator is used in Session /// object operations such as Session.Get, Session.Put, or Session.Enumerate. A fragment represents one /// property or part of a resource. You can provide a ResourceLocator object instead of specifying a resource URI in /// Session object operations. The dialect indicates what XML language describes the fragment to the service that /// implements the WS-Management Protocol and receives the request. /// /// This property is read/write. /// /// IWSManResourceLocator::FragmentDialect is the corresponding C++ property. // https://docs.microsoft.com/en-us/windows/win32/winrm/resourcelocator-fragmentdialect ResourceLocator.FragmentDialect As string [DispId(5)] string FragmentDialect { [DispId(5)] [return: MarshalAs(UnmanagedType.BStr)] get; [DispId(5)] [param: In, MarshalAs(UnmanagedType.BStr)] set; } /// /// Adds data required to process the request. For example, some WMI providers may require an IWbemContext or SWbemNamedValueSet /// object with provider-specific information. You can provide a ResourceLocator object instead of specifying a resource URI in /// IWSManSession object operations such as Get, Put, or Enumerate. /// /// The name of the optional data object. /// A value supplied for the optional data object. /// A flag that indicates the option must be processed. The default is False (0). /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanresourcelocator-addoption HRESULT AddOption( // BSTR OptionName, VARIANT OptionValue, BOOL mustComply ); [PreserveSig, DispId(6)] HRESULT AddOption([MarshalAs(UnmanagedType.BStr)] string OptionName, [In, MarshalAs(UnmanagedType.Struct)] object OptionValue, [MarshalAs(UnmanagedType.Bool)] bool mustComply); /// /// /// Gets or sets the MustUnderstandOptions value for the ResourceLocator object. You can provide an IWSManResourceLocator /// object instead of specifying a resource URI in IWSManSession object operations such as Get, Put, or Enumerate. /// /// This property is read/write. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanresourcelocator-put_mustunderstandoptions // HRESULT put_MustUnderstandOptions( BOOL mustUnderstand ); [DispId(7)] bool MustUnderstandOptions { [DispId(7)] [return: MarshalAs(UnmanagedType.Bool)] get; [DispId(7)] [param: In, MarshalAs(UnmanagedType.Bool)] set; } /// /// Removes any options from the ResourceLocator object. You can provide a ResourceLocator object instead of specifying a /// resource URI in IWSManSession object operations such as Get, Put, or Enumerate. /// /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanresourcelocator-clearoptions HRESULT ClearOptions(); [PreserveSig, DispId(8)] HRESULT ClearOptions(); /// /// Gets an XML representation of additional error information. /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmanresourcelocator-get_error HRESULT get_Error( // BSTR *value ); [DispId(9)] string Error { [DispId(9)] [return: MarshalAs(UnmanagedType.BStr)] get; } } /// /// Defines operations and session settings. Any Windows Remote Management operations require creation of an IWSManSession /// object that connects to a remote computer, base management controller (BMC), or the local computer. WinRM network operations /// include getting, writing, enumerating data, or invoking methods. The methods of the IWSManSession object mirror the basic /// operations defined in the WS-Management protocol. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmansession [PInvokeData("wsmandisp.h", MSDNShortId = "NN:wsmandisp.IWSManSession")] [ComImport, Guid("FC84FC58-1286-40c4-9DA0-C8EF6EC241E0"), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface IWSManSession { /// /// Retrieves the resource specified by the URI and returns an XML representation of the current instance of the resource. /// /// /// The identifier of the resource to be retrieved. /// This parameter can contain one of the following: /// /// /// /// URI with or without selectors. When calling the Get method to obtain a WMI resource, use the key property or properties of /// the object. /// /// /// /// ResourceLocator object which may contain selectors, fragments, or options. /// /// /// /// WS-Addressing endpoint reference as described in the WS-Management protocol standard. For more information about the public /// specification for the WS-Management protocol, see Management Specifications Index Page. /// /// /// /// /// Reserved for future use. Must be set to 0. /// A value that, upon success, is an XML representation of the resource. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmansession-get HRESULT Get( VARIANT resourceUri, // long flags, BSTR *resource ); [PreserveSig, DispId(1)] HRESULT Get([In, MarshalAs(UnmanagedType.Struct)] object resourceUri, [Optional] int flags, [MarshalAs(UnmanagedType.BStr)] out string resource); /// Updates a resource. /// /// The identifier of the resource to be updated. /// This parameter can contain one of the following: /// /// /// /// URI with or without selectors. When calling the Put method to obtain a WMI resource, use the key property or /// properties of the object. /// /// /// /// ResourceLocator object which may contain selectors, fragments, or options. /// /// /// /// WS-Addressing endpoint reference as described in the WS-Management protocol standard. For more information about the public /// specification for the WS-Management protocol, see Management Specifications Index Page. /// /// /// /// /// The updated resource content. /// Reserved for future use. Must be set to 0. /// The XML stream that contains the updated resource content. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmansession-put HRESULT Put( VARIANT resourceUri, // BSTR resource, long flags, BSTR *resultResource ); [PreserveSig, DispId(2)] HRESULT Put([In, MarshalAs(UnmanagedType.Struct)] object resourceUri, [MarshalAs(UnmanagedType.BStr)] string resource, [Optional] int flags, [MarshalAs(UnmanagedType.BStr)] out string resultResource); /// Creates a new instance of a resource and returns the endpoint reference (EPR) of the new object. /// /// The identifier of the resource to create. /// This parameter can contain one of the following: /// /// /// /// URI with one or more selectors. Be aware that the WMI plug-in does not support creating any resource other than a /// WS-Management protocol listener. /// /// /// /// ResourceLocator object which may contain selectors, fragments, or options. /// /// /// /// WS-Addressing endpoint reference as described in the WS-Management protocol standard. For more information about the public /// specification for the WS-Management protocol, see Management Specifications Index Page. /// /// /// /// /// An XML string that contains resource content. /// Reserved. Must be set to 0. /// The EPR of the new resource. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// IWSManSession::Create is only used for creating new instances of a resource. Use the IWSManSession::Put method to /// update existing instances of a resource. After you obtain the new resource URI, you can call IWSManSession::Get to retrieve /// the new object. The new object contains any properties that the resource provider assigns when creating the new object. For /// example, if you create a new WS-Management protocollistener and retrieve the listener object using Session.Get, then you /// also obtain the Port, Enabled, and ListeningOn properties. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmansession-create HRESULT Create( VARIANT // resourceUri, BSTR resource, long flags, BSTR *newUri ); [PreserveSig, DispId(3)] HRESULT Create([In, MarshalAs(UnmanagedType.Struct)] object resourceUri, [MarshalAs(UnmanagedType.BStr)] string resource, [Optional] int flags, [MarshalAs(UnmanagedType.BStr)] out string newUri); /// Deletes the resource specified in the resource URI. /// /// The URI of the resource to be deleted. You can also use an IWSManResourceLocator object to specify the resource. /// /// Reserved for future use. Must be set to 0. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmansession-delete HRESULT Delete( VARIANT // resourceUri, long flags ); [PreserveSig, DispId(4)] HRESULT Delete([In, MarshalAs(UnmanagedType.Struct)] object resourceUri, [Optional] int flags); /// Invokes a method and returns the results of the method call. /// The URI of the method to invoke. /// /// The identifier of the resource to invoke a method. /// This parameter can contain one of the following: /// /// /// URI with or without selectors. /// /// /// ResourceLocator object which may contain selectors, fragments, or options. /// /// /// /// WS-Addressing endpoint reference as described in the WS-Management protocol standard. For more information about the public /// specification for the WS-Management protocol, see Management Specifications Index Page. /// /// /// /// /// /// An XML representation of the input for the method. This string must be supplied or this method will fail. /// /// Reserved for future use. Must be set to 0. /// An XML representation of the method output. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmansession-invoke HRESULT Invoke( BSTR // actionUri, VARIANT resourceUri, BSTR parameters, long flags, BSTR *result ); [PreserveSig, DispId(5)] HRESULT Invoke([MarshalAs(UnmanagedType.BStr)] string actionUri, [In, MarshalAs(UnmanagedType.Struct)] object resourceUri, [MarshalAs(UnmanagedType.BStr)] string parameters, [Optional] int flags, [MarshalAs(UnmanagedType.BStr)] out string result); /// /// Enumerates a table, data collection, or log resource. To create a query, include a filter parameter and a dialect parameter /// in an enumeration. You can also use an IWSManResourceLocator object to create queries. For more information, see Enumerating /// or Listing All the Instances of a Resource. /// /// /// The identifier of the resource to be retrieved. /// The following list contains identifiers that this parameter can contain: /// /// /// /// URI with one or more selectors. When calling the Enumerate method to obtain a WMI resource, use the key property or /// properties of the object. /// /// /// /// You can use selectors, fragments, or options. For more information, see IWSManResourceLocator. /// /// /// /// WS-Addressing endpoint reference as described in the WS-Management protocol standard. For more information about the public /// specification for the WS-Management protocol, see the Management Specifications Index Page. /// /// /// /// /// /// /// A filter that defines what items in the resource are returned by the enumeration. When the resource is enumerated, only /// those items that match the filter criteria are returned. Including a filter parameter and a dialect parameter in an /// enumeration converts the enumeration into a query. /// /// /// If you have an IWSManResourceLocator object for the resourceURI parameter, then this parameter should not be used. Instead, /// use the selector and fragment functionality of IWSManResourceLocator. /// /// /// /// The language used by the filter. WQL, a subset of SQL used by WMI, is the only language supported. /// /// If you have a IWSManResourceLocator object for the resourceURI parameter, then this parameter should not be used. Instead, /// use the selector and fragment functionality of IWSManResourceLocator. /// /// /// /// This parameter must contain a flag in the __WSManEnumFlags enumeration. For more information, see Enumeration Constants. /// /// An IWSManEnumerator object that contains the results of the enumeration. /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// Call IWSManSession::Enumerate to start an enumeration operation. Thereafter, call IWSManEnumerator::ReadItem using /// the returned IWSManEnumerator object until the end of items is indicated by the AtEndOfStream property. /// /// /// Be aware that if the flags include the Enumeration Constants WSManFlagHierarchyDeepBasePropsOnly or /// WSManFlagHierarchyShallow then Windows Remote Management service returns the error code ERROR_WSMAN_POLYMORPHISM_MODE_UNSUPPORTED. /// /// For more information about limiting network calls during an enumeration, see the BatchItems property. /// /// If a filter is specified, it must be a valid document with respect to the schema of the resource. The dialect parameter is /// optional. However, if the filter string begins with <, but is not an XML fragment, then either include the dialect /// parameter or set the WSManFlagNonXmlText flag in the flags parameter. For more information, see Enumeration Constants. /// /// The corresponding scripting method is Session.Enumerate. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmansession-enumerate HRESULT Enumerate( VARIANT // resourceUri, BSTR filter, BSTR dialect, long flags, IDispatch **resultSet ); [PreserveSig, DispId(6)] HRESULT Enumerate([In, MarshalAs(UnmanagedType.Struct)] object resourceUri, [MarshalAs(UnmanagedType.BStr)] string filter, [MarshalAs(UnmanagedType.BStr)] string? dialect, WSManEnumFlags flags, out IWSManEnumerator resultSet); /// /// The IWSManSession::Identify method queries a remote computer to determine if it supports the WS-Management protocol. /// For more information, see Detecting Whether a Remote Computer Supports WS-Management Protocol. /// /// The only flag that is accepted is WSManFlagUseNoAuthentication. /// /// A value that, upon success, is an XML string that specifies the WS-Management protocol version, the operating system vendor /// and, if the request was sent authenticated, the operating system version. /// /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmansession-identify HRESULT Identify( long // flags, BSTR *result ); [PreserveSig, DispId(7)] HRESULT Identify(WSManSessionFlags flags, [MarshalAs(UnmanagedType.BStr)] out string result); /// /// Gets additional error information in an XML stream for the preceding call to an IWSManSession object method. /// This property is read-only. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nf-wsmandisp-iwsmansession-get_error HRESULT get_Error( BSTR // *value ); [DispId(8)] string Error { [DispId(8)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// /// /// Sets and gets the number of items in each enumeration batch. This value cannot be changed during an enumeration. The /// resource provider may set a limit. /// /// This property is read-write. /// // https://docs.microsoft.com/en-us/windows/win32/api/wsmandisp/nn-wsmandisp-iwsmanenumerator [DispId(9)] int BatchItems { [DispId(9)] get; [DispId(9)] [param: In] set; } /// /// /// Sets and gets the maximum amount of time, in milliseconds, that the client application waits for Windows Remote Management /// to complete its operations. /// /// This property is read-write. /// [DispId(10)] int Timeout { [DispId(10)] get; [DispId(10)] [param: In] set; } } /// Provides methods and properties used to create a session, represented by a Session object. Any Windows Remote Management operations require creation of a Session that connects to a remote computer, base management controller (BMC), or the local computer. Operations include getting, writing, enumerating data, or invoking methods. /// The WSMan object corresponds to the IWSMan and IWSManEx interfaces. WSMan is the only object that can be created directly using CreateObject. // https://docs.microsoft.com/en-us/windows/win32/winrm/wsman [PInvokeData("wsmandisp.h")] [ComImport, Guid("BCED617B-EC03-420b-8508-977DC7A686BD"), ClassInterface(ClassInterfaceType.None)] public class WSMan { } }