// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Management.Automation; using System.Management.Automation.Provider; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Xml; #pragma warning disable 1591 namespace Microsoft.WSMan.Management { #region "public Api" #region WsManEnumFlags /// _WSManEnumFlags enumeration. [SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] [TypeLibType((short)0)] public enum WSManEnumFlags { /// WSManFlagNonXmlText constant of _WSManEnumFlags enumeration. Constant value is 1. WSManFlagNonXmlText = 1, /// WSManFlagReturnObject constant of _WSManEnumFlags enumeration. Constant value is 0. WSManFlagReturnObject = 0, /// WSManFlagReturnEPR constant of _WSManEnumFlags enumeration. Constant value is 2. [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "EPR")] WSManFlagReturnEPR = 2, /// WSManFlagReturnObjectAndEPR constant of _WSManEnumFlags enumeration. Constant value is 4. [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "EPR")] WSManFlagReturnObjectAndEPR = 4, /// WSManFlagHierarchyDeep constant of _WSManEnumFlags enumeration. Constant value is 0. WSManFlagHierarchyDeep = 0, /// WSManFlagHierarchyShallow constant of _WSManEnumFlags enumeration. Constant value is 32. WSManFlagHierarchyShallow = 32, /// WSManFlagHierarchyDeepBasePropsOnly constant of _WSManEnumFlags enumeration. Constant value is 64. WSManFlagHierarchyDeepBasePropsOnly = 64, /// WSManFlagAssociationInstance constant of _WSManEnumFlags enumeration. Constant value is 64. WSManFlagAssociationInstance = 128 } #endregion WsManEnumFlags #region WsManSessionFlags /// WSManSessionFlags enumeration. [SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] [TypeLibType((short)0)] public enum WSManSessionFlags { /// no flag constant of _WSManSessionFlags enumeration. Constant value is 1. WSManNone = 0, /// WSManFlagUTF8 constant of _WSManSessionFlags enumeration. Constant value is 1. WSManFlagUtf8 = 1, /// WSManFlagCredUsernamePassword constant of _WSManSessionFlags enumeration. Constant value is 4096. [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cred")] WSManFlagCredUserNamePassword = 4096, /// WSManFlagSkipCACheck constant of _WSManSessionFlags enumeration. Constant value is 8192. WSManFlagSkipCACheck = 8192, /// WSManFlagSkipCNCheck constant of _WSManSessionFlags enumeration. Constant value is 16384. WSManFlagSkipCNCheck = 16384, /// WSManFlagUseNoAuthentication constant of _WSManSessionFlags enumeration. Constant value is 32768. WSManFlagUseNoAuthentication = 32768, /// WSManFlagUseDigest constant of _WSManSessionFlags enumeration. Constant value is 65536. WSManFlagUseDigest = 65536, /// WSManFlagUseNegotiate constant of _WSManSessionFlags enumeration. Constant value is 131072. WSManFlagUseNegotiate = 131072, /// WSManFlagUseBasic constant of _WSManSessionFlags enumeration. Constant value is 262144. WSManFlagUseBasic = 262144, /// WSManFlagUseKerberos constant of _WSManSessionFlags enumeration. Constant value is 524288. WSManFlagUseKerberos = 524288, /// WSManFlagNoEncryption constant of _WSManSessionFlags enumeration. Constant value is 1048576. WSManFlagNoEncryption = 1048576, /// WSManFlagEnableSPNServerPort constant of _WSManSessionFlags enumeration. Constant value is 4194304. [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Spn")] WSManFlagEnableSpnServerPort = 4194304, /// WSManFlagUTF16 constant of _WSManSessionFlags enumeration. Constant value is 8388608. WSManFlagUtf16 = 8388608, /// WSManFlagUseCredSsp constant of _WSManSessionFlags enumeration. Constant value is 16777216. [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ssp")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cred")] WSManFlagUseCredSsp = 16777216, /// WSManFlagUseClientCertificate constant of _WSManSessionFlags enumeration. Constant value is 2097152. WSManFlagUseClientCertificate = 2097152, /// WSManFlagSkipRevocationCheck constant of _WSManSessionFlags enumeration. Constant value is 33554432. WSManFlagSkipRevocationCheck = 33554432, /// WSManFlagAllowNegotiateImplicitCredentials constant of _WSManSessionFlags enumeration. Constant value is 67108864. WSManFlagAllowNegotiateImplicitCredentials = 67108864, /// WSManFlagUseSsl constant of _WSManSessionFlags enumeration. Constant value is 134217728. WSManFlagUseSsl = 134217728 } #endregion WsManSessionFlags #region AuthenticationMechanism /// WSManEnumFlags enumeration [SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] public enum AuthenticationMechanism { /// /// Use no authentication. /// None = 0x0, /// /// Use Default authentication. /// Default = 0x1, /// /// Use digest authentication for a remote operation. /// Digest = 0x2, /// /// Use negotiate authentication for a remote operation (may use kerberos or ntlm) /// Negotiate = 0x4, /// /// Use basic authentication for a remote operation. /// Basic = 0x8, /// /// Use kerberos authentication for a remote operation. /// Kerberos = 0x10, /// /// Use client certificate authentication for a remote operation. /// ClientCertificate = 0x20, /// /// Use CredSSP authentication for a remote operation. /// [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Credssp")] Credssp = 0x80, } #endregion AuthenticationMechanism #region IWsMan /// IWSMan interface. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] [Guid("190D8637-5CD3-496D-AD24-69636BB5A3B5")] [ComImport] [TypeLibType((short)4304)] #if CORECLR [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] #else [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)] #endif public interface IWSMan { #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfoCount(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfo(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetIDsOfNames(); [return: MarshalAs(UnmanagedType.IUnknown)] object Invoke(); #endif /// CreateSession method of IWSMan interface. /// An original IDL definition of CreateSession method was the following: HRESULT CreateSession ([optional, defaultvalue(string.Empty)] BSTR connection, [optional, defaultvalue(0)] long flags, [optional] IDispatch* connectionOptions, [out, retval] IDispatch** ReturnValue); // IDL: HRESULT CreateSession ([optional, defaultvalue(string.Empty)] BSTR connection, [optional, defaultvalue(0)] long flags, [optional] IDispatch* connectionOptions, [out, retval] IDispatch** ReturnValue); [DispId(1)] #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] object CreateSession([MarshalAs(UnmanagedType.BStr)] string connection, int flags, [MarshalAs(UnmanagedType.IUnknown)] object connectionOptions); #else [return: MarshalAs(UnmanagedType.IDispatch)] object CreateSession([MarshalAs(UnmanagedType.BStr)] string connection, int flags, [MarshalAs(UnmanagedType.IDispatch)] object connectionOptions); #endif /// CreateConnectionOptions method of IWSMan interface. /// An original IDL definition of CreateConnectionOptions method was the following: HRESULT CreateConnectionOptions ([out, retval] IDispatch** ReturnValue); // IDL: HRESULT CreateConnectionOptions ([out, retval] IDispatch** ReturnValue); // [DispId(2)] #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] #else [return: MarshalAs(UnmanagedType.IDispatch)] #endif object CreateConnectionOptions(); /// CommandLine property of IWSMan interface. /// An original IDL definition of CommandLine property was the following: BSTR CommandLine; // IDL: BSTR CommandLine; // string CommandLine { // IDL: HRESULT CommandLine ([out, retval] BSTR* ReturnValue); [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// Error property of IWSMan interface. /// An original IDL definition of Error property was the following: BSTR Error; // IDL: BSTR Error; // [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] string Error { // IDL: HRESULT Error ([out, retval] BSTR* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] [DispId(4)] [return: MarshalAs(UnmanagedType.BStr)] get; } } #endregion IWsMan #region IWSManConnectionOptions /// IWSManConnectionOptions interface. [Guid("F704E861-9E52-464F-B786-DA5EB2320FDD")] [ComImport] [TypeLibType((short)4288)] #if CORECLR [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] #else [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)] #endif [SuppressMessage("Microsoft.Design", "CA1044:PropertiesShouldNotBeWriteOnly")] public interface IWSManConnectionOptions { #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfoCount(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfo(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetIDsOfNames(); [return: MarshalAs(UnmanagedType.IUnknown)] object Invoke(); #endif /// UserName property of IWSManConnectionOptions interface. /// An original IDL definition of UserName property was the following: BSTR UserName; // IDL: BSTR UserName; string UserName { // IDL: HRESULT UserName ([out, retval] BSTR* ReturnValue); [DispId(1)] [return: MarshalAs(UnmanagedType.BStr)] get; // IDL: HRESULT UserName (BSTR value); [DispId(1)] set; } /// Password property of IWSManConnectionOptions interface. /// An original IDL definition of Password property was the following: BSTR Password; // IDL: BSTR Password; [SuppressMessage("Microsoft.Design", "CA1044:PropertiesShouldNotBeWriteOnly")] string Password { // IDL: HRESULT Password (BSTR value); [SuppressMessage("Microsoft.Design", "CA1044:PropertiesShouldNotBeWriteOnly")] [DispId(2)] set; } } /// IWSManConnectionOptions interface. [Guid("EF43EDF7-2A48-4d93-9526-8BD6AB6D4A6B")] [ComImport] [TypeLibType((short)4288)] #if CORECLR [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] #else [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)] #endif [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] public interface IWSManConnectionOptionsEx : IWSManConnectionOptions { /// CertificateThumbprint property of IWSManConnectionOptionsEx interface. string CertificateThumbprint { [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] get; [DispId(1)] set; } } /// IWSManConnectionOptions interface. [Guid("F500C9EC-24EE-48ab-B38D-FC9A164C658E")] [ComImport] [TypeLibType((short)4288)] #if CORECLR [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] #else [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)] #endif public interface IWSManConnectionOptionsEx2 : IWSManConnectionOptionsEx { /// SetProxy method of IWSManConnectionOptionsEx2 interface. [DispId(4)] void SetProxy(int accessType, int authenticationMechanism, [In, MarshalAs(UnmanagedType.BStr)] string userName, [In, MarshalAs(UnmanagedType.BStr)] string password); /// ProxyIEConfig method of IWSManConnectionOptionsEx2 interface. [DispId(5)] int ProxyIEConfig(); /// ProxyWinHttpConfig method of IWSManConnectionOptionsEx2 interface. [DispId(6)] int ProxyWinHttpConfig(); /// ProxyAutoDetect method of IWSManConnectionOptionsEx2 interface. [DispId(7)] int ProxyAutoDetect(); /// ProxyNoProxyServer method of IWSManConnectionOptionsEx2 interface. [DispId(8)] int ProxyNoProxyServer(); /// ProxyAuthenticationUseNegotiate method of IWSManConnectionOptionsEx2 interface. [DispId(9)] int ProxyAuthenticationUseNegotiate(); /// ProxyAuthenticationUseBasic method of IWSManConnectionOptionsEx2 interface. [DispId(10)] int ProxyAuthenticationUseBasic(); /// ProxyAuthenticationUseDigest method of IWSManConnectionOptionsEx2 interface. [DispId(11)] int ProxyAuthenticationUseDigest(); }; #endregion IWSManConnectionOptions #region IWSManEnumerator /// IWSManEnumerator interface. [Guid("F3457CA9-ABB9-4FA5-B850-90E8CA300E7F")] [ComImport] [TypeLibType((short)4288)] #if CORECLR [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] #else [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)] #endif public interface IWSManEnumerator { #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfoCount(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfo(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetIDsOfNames(); [return: MarshalAs(UnmanagedType.IUnknown)] object Invoke(); #endif /// ReadItem method of IWSManEnumerator interface. /// An original IDL definition of ReadItem method was the following: HRESULT ReadItem ([out, retval] BSTR* ReturnValue); // IDL: HRESULT ReadItem ([out, retval] BSTR* ReturnValue); [DispId(1)] [return: MarshalAs(UnmanagedType.BStr)] string ReadItem(); /// AtEndOfStream property of IWSManEnumerator interface. /// An original IDL definition of AtEndOfStream property was the following: BOOL AtEndOfStream; // IDL: BOOL AtEndOfStream; bool AtEndOfStream { // IDL: HRESULT AtEndOfStream ([out, retval] BOOL* ReturnValue); [DispId(2)] [return: MarshalAs(UnmanagedType.Bool)] get; } /// Error property of IWSManEnumerator interface. /// An original IDL definition of Error property was the following: BSTR Error; // IDL: BSTR Error; [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] string Error { // IDL: HRESULT Error ([out, retval] BSTR* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] [DispId(8)] [return: MarshalAs(UnmanagedType.BStr)] get; } } #endregion IWSManEnumerator #region IWSManEx /// IWSManEx interface. [Guid("2D53BDAA-798E-49E6-A1AA-74D01256F411")] [ComImport] [TypeLibType((short)4304)] [SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] #if CORECLR [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] #else [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)] #endif [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "str")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cred")] [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Username")] [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] public interface IWSManEx { #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfoCount(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfo(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetIDsOfNames(); [return: MarshalAs(UnmanagedType.IUnknown)] object Invoke(); #endif /// CreateSession method of IWSManEx interface. /// An original IDL definition of CreateSession method was the following: HRESULT CreateSession ([optional, defaultvalue(string.Empty)] BSTR connection, [optional, defaultvalue(0)] long flags, [optional] IDispatch* connectionOptions, [out, retval] IDispatch** ReturnValue); // IDL: HRESULT CreateSession ([optional, defaultvalue(string.Empty)] BSTR connection, [optional, defaultvalue(0)] long flags, [optional] IDispatch* connectionOptions, [out, retval] IDispatch** ReturnValue); [DispId(1)] #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] object CreateSession([MarshalAs(UnmanagedType.BStr)] string connection, int flags, [MarshalAs(UnmanagedType.IUnknown)] object connectionOptions); #else [return: MarshalAs(UnmanagedType.IDispatch)] object CreateSession([MarshalAs(UnmanagedType.BStr)] string connection, int flags, [MarshalAs(UnmanagedType.IDispatch)] object connectionOptions); #endif /// CreateConnectionOptions method of IWSManEx interface. /// An original IDL definition of CreateConnectionOptions method was the following: HRESULT CreateConnectionOptions ([out, retval] IDispatch** ReturnValue); // IDL: HRESULT CreateConnectionOptions ([out, retval] IDispatch** ReturnValue); [DispId(2)] #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] #else [return: MarshalAs(UnmanagedType.IDispatch)] #endif object CreateConnectionOptions(); /// /// /// string CommandLine { // IDL: HRESULT CommandLine ([out, retval] BSTR* ReturnValue); [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// Error property of IWSManEx interface. /// An original IDL definition of Error property was the following: BSTR Error; // IDL: BSTR Error; [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] string Error { // IDL: HRESULT Error ([out, retval] BSTR* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] [DispId(4)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// CreateResourceLocator method of IWSManEx interface. /// An original IDL definition of CreateResourceLocator method was the following: HRESULT CreateResourceLocator ([optional, defaultvalue(string.Empty)] BSTR strResourceLocator, [out, retval] IDispatch** ReturnValue); // IDL: HRESULT CreateResourceLocator ([optional, defaultvalue(string.Empty)] BSTR strResourceLocator, [out, retval] IDispatch** ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "str")] [DispId(5)] #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] #else [return: MarshalAs(UnmanagedType.IDispatch)] #endif object CreateResourceLocator([MarshalAs(UnmanagedType.BStr)] string strResourceLocator); /// SessionFlagUTF8 method of IWSManEx interface. /// An original IDL definition of SessionFlagUTF8 method was the following: HRESULT SessionFlagUTF8 ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagUTF8 ([out, retval] long* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "UTF")] [DispId(6)] int SessionFlagUTF8(); /// SessionFlagCredUsernamePassword method of IWSManEx interface. /// An original IDL definition of SessionFlagCredUsernamePassword method was the following: HRESULT SessionFlagCredUsernamePassword ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagCredUsernamePassword ([out, retval] long* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Username")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cred")] [DispId(7)] int SessionFlagCredUsernamePassword(); /// SessionFlagSkipCACheck method of IWSManEx interface. /// An original IDL definition of SessionFlagSkipCACheck method was the following: HRESULT SessionFlagSkipCACheck ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagSkipCACheck ([out, retval] long* ReturnValue); [DispId(8)] int SessionFlagSkipCACheck(); /// SessionFlagSkipCNCheck method of IWSManEx interface. /// An original IDL definition of SessionFlagSkipCNCheck method was the following: HRESULT SessionFlagSkipCNCheck ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagSkipCNCheck ([out, retval] long* ReturnValue); [DispId(9)] int SessionFlagSkipCNCheck(); /// SessionFlagUseDigest method of IWSManEx interface. /// An original IDL definition of SessionFlagUseDigest method was the following: HRESULT SessionFlagUseDigest ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagUseDigest ([out, retval] long* ReturnValue); [DispId(10)] int SessionFlagUseDigest(); /// SessionFlagUseNegotiate method of IWSManEx interface. /// An original IDL definition of SessionFlagUseNegotiate method was the following: HRESULT SessionFlagUseNegotiate ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagUseNegotiate ([out, retval] long* ReturnValue); [DispId(11)] int SessionFlagUseNegotiate(); /// SessionFlagUseBasic method of IWSManEx interface. /// An original IDL definition of SessionFlagUseBasic method was the following: HRESULT SessionFlagUseBasic ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagUseBasic ([out, retval] long* ReturnValue); [DispId(12)] int SessionFlagUseBasic(); /// SessionFlagUseKerberos method of IWSManEx interface. /// An original IDL definition of SessionFlagUseKerberos method was the following: HRESULT SessionFlagUseKerberos ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagUseKerberos ([out, retval] long* ReturnValue); [DispId(13)] int SessionFlagUseKerberos(); /// SessionFlagNoEncryption method of IWSManEx interface. /// An original IDL definition of SessionFlagNoEncryption method was the following: HRESULT SessionFlagNoEncryption ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagNoEncryption ([out, retval] long* ReturnValue); [DispId(14)] int SessionFlagNoEncryption(); /// SessionFlagEnableSPNServerPort method of IWSManEx interface. /// An original IDL definition of SessionFlagEnableSPNServerPort method was the following: HRESULT SessionFlagEnableSPNServerPort ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagEnableSPNServerPort ([out, retval] long* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SPN")] [DispId(15)] int SessionFlagEnableSPNServerPort(); /// SessionFlagUseNoAuthentication method of IWSManEx interface. /// An original IDL definition of SessionFlagUseNoAuthentication method was the following: HRESULT SessionFlagUseNoAuthentication ([out, retval] long* ReturnValue); // IDL: HRESULT SessionFlagUseNoAuthentication ([out, retval] long* ReturnValue); [DispId(16)] int SessionFlagUseNoAuthentication(); /// EnumerationFlagNonXmlText method of IWSManEx interface. /// An original IDL definition of EnumerationFlagNonXmlText method was the following: HRESULT EnumerationFlagNonXmlText ([out, retval] long* ReturnValue); // IDL: HRESULT EnumerationFlagNonXmlText ([out, retval] long* ReturnValue); [DispId(17)] int EnumerationFlagNonXmlText(); /// EnumerationFlagReturnEPR method of IWSManEx interface. /// An original IDL definition of EnumerationFlagReturnEPR method was the following: HRESULT EnumerationFlagReturnEPR ([out, retval] long* ReturnValue); // IDL: HRESULT EnumerationFlagReturnEPR ([out, retval] long* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "EPR")] [DispId(18)] int EnumerationFlagReturnEPR(); /// EnumerationFlagReturnObjectAndEPR method of IWSManEx interface. /// An original IDL definition of EnumerationFlagReturnObjectAndEPR method was the following: HRESULT EnumerationFlagReturnObjectAndEPR ([out, retval] long* ReturnValue); // IDL: HRESULT EnumerationFlagReturnObjectAndEPR ([out, retval] long* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "EPR")] [DispId(19)] int EnumerationFlagReturnObjectAndEPR(); /// GetErrorMessage method of IWSManEx interface. /// An original IDL definition of GetErrorMessage method was the following: HRESULT GetErrorMessage (unsigned long errorNumber, [out, retval] BSTR* ReturnValue); // IDL: HRESULT GetErrorMessage (unsigned long errorNumber, [out, retval] BSTR* ReturnValue); [DispId(20)] [return: MarshalAs(UnmanagedType.BStr)] string GetErrorMessage(uint errorNumber); /// EnumerationFlagHierarchyDeep method of IWSManEx interface. /// An original IDL definition of EnumerationFlagHierarchyDeep method was the following: HRESULT EnumerationFlagHierarchyDeep ([out, retval] long* ReturnValue); // IDL: HRESULT EnumerationFlagHierarchyDeep ([out, retval] long* ReturnValue); [DispId(21)] int EnumerationFlagHierarchyDeep(); /// EnumerationFlagHierarchyShallow method of IWSManEx interface. /// An original IDL definition of EnumerationFlagHierarchyShallow method was the following: HRESULT EnumerationFlagHierarchyShallow ([out, retval] long* ReturnValue); // IDL: HRESULT EnumerationFlagHierarchyShallow ([out, retval] long* ReturnValue); [DispId(22)] int EnumerationFlagHierarchyShallow(); /// EnumerationFlagHierarchyDeepBasePropsOnly method of IWSManEx interface. /// An original IDL definition of EnumerationFlagHierarchyDeepBasePropsOnly method was the following: HRESULT EnumerationFlagHierarchyDeepBasePropsOnly ([out, retval] long* ReturnValue); // IDL: HRESULT EnumerationFlagHierarchyDeepBasePropsOnly ([out, retval] long* ReturnValue); [DispId(23)] int EnumerationFlagHierarchyDeepBasePropsOnly(); /// EnumerationFlagReturnObject method of IWSManEx interface. /// An original IDL definition of EnumerationFlagReturnObject method was the following: HRESULT EnumerationFlagReturnObject ([out, retval] long* ReturnValue); // IDL: HRESULT EnumerationFlagReturnObject ([out, retval] long* ReturnValue); [DispId(24)] int EnumerationFlagReturnObject(); /// CommandLine property of IWSManEx interface. /// An original IDL definition of CommandLine property was the following: BSTR CommandLine; // IDL: BSTR CommandLine; [DispId(28)] int EnumerationFlagAssociationInstance(); /// CommandLine property of IWSManEx interface. /// An original IDL definition of CommandLine property was the following: BSTR CommandLine; // IDL: BSTR CommandLine; [DispId(29)] int EnumerationFlagAssociatedInstance(); } #endregion IWsManEx #region IWsManResourceLocator /// IWSManResourceLocator interface. [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")] [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sel")] [Guid("A7A1BA28-DE41-466A-AD0A-C4059EAD7428")] [ComImport] [TypeLibType((short)4288)] #if CORECLR [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] #else [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)] #endif public interface IWSManResourceLocator { #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfoCount(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfo(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetIDsOfNames(); [return: MarshalAs(UnmanagedType.IUnknown)] object Invoke(); #endif /// resourceUri property of IWSManResourceLocator interface. Set the resource URI. Must contain path only -- query string is not allowed here. /// An original IDL definition of resourceUri property was the following: BSTR resourceUri; // Set the resource URI. Must contain path only -- query string is not allowed here. // IDL: BSTR resourceUri; [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "resource")] [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] string ResourceUri { // IDL: HRESULT resourceUri (BSTR value); [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "resource")] [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] [DispId(1)] set; // IDL: HRESULT resourceUri ([out, retval] BSTR* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "resource")] [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")] [DispId(1)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// AddSelector method of IWSManResourceLocator interface. Add selector to resource locator /// An original IDL definition of AddSelector method was the following: HRESULT AddSelector (BSTR resourceSelName, VARIANT selValue); // Add selector to resource locator // IDL: HRESULT AddSelector (BSTR resourceSelName, VARIANT selValue); [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "resource")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "sel")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sel")] [DispId(2)] void AddSelector([MarshalAs(UnmanagedType.BStr)] string resourceSelName, object selValue); /// ClearSelectors method of IWSManResourceLocator interface. Clear all selectors /// An original IDL definition of ClearSelectors method was the following: HRESULT ClearSelectors (void); // Clear all selectors // IDL: HRESULT ClearSelectors (void); [DispId(3)] void ClearSelectors(); /// FragmentPath property of IWSManResourceLocator interface. Gets the fragment path /// An original IDL definition of FragmentPath property was the following: BSTR FragmentPath; // Gets the fragment path // IDL: BSTR FragmentPath; string FragmentPath { // IDL: HRESULT FragmentPath ([out, retval] BSTR* ReturnValue); [DispId(4)] [return: MarshalAs(UnmanagedType.BStr)] get; // IDL: HRESULT FragmentPath (BSTR value); [DispId(4)] set; } /// FragmentDialect property of IWSManResourceLocator interface. Gets the Fragment dialect /// An original IDL definition of FragmentDialect property was the following: BSTR FragmentDialect; // Gets the Fragment dialect // IDL: BSTR FragmentDialect; string FragmentDialect { // IDL: HRESULT FragmentDialect ([out, retval] BSTR* ReturnValue); [DispId(5)] [return: MarshalAs(UnmanagedType.BStr)] get; // IDL: HRESULT FragmentDialect (BSTR value); [DispId(5)] set; } /// AddOption method of IWSManResourceLocator interface. Add option to resource locator /// An original IDL definition of AddOption method was the following: HRESULT AddOption (BSTR OptionName, VARIANT OptionValue, [optional, defaultvalue(0)] long mustComply); // Add option to resource locator // IDL: HRESULT AddOption (BSTR OptionName, VARIANT OptionValue, [optional, defaultvalue(0)] long mustComply); [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Option")] [DispId(6)] void AddOption([MarshalAs(UnmanagedType.BStr)] string OptionName, object OptionValue, int mustComply); /// MustUnderstandOptions property of IWSManResourceLocator interface. Sets the MustUnderstandOptions value /// An original IDL definition of MustUnderstandOptions property was the following: long MustUnderstandOptions; // Sets the MustUnderstandOptions value // IDL: long MustUnderstandOptions; int MustUnderstandOptions { // IDL: HRESULT MustUnderstandOptions ([out, retval] long* ReturnValue); [DispId(7)] get; // IDL: HRESULT MustUnderstandOptions (long value); [DispId(7)] set; } /// ClearOptions method of IWSManResourceLocator interface. Clear all options /// An original IDL definition of ClearOptions method was the following: HRESULT ClearOptions (void); // Clear all options // IDL: HRESULT ClearOptions (void); [DispId(8)] void ClearOptions(); /// Error property of IWSManResourceLocator interface. /// An original IDL definition of Error property was the following: BSTR Error; // IDL: BSTR Error; [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] string Error { // IDL: HRESULT Error ([out, retval] BSTR* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] [DispId(9)] [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] [return: MarshalAs(UnmanagedType.BStr)] get; } } #endregion IWsManResourceLocator #region IWSManSession /// IWSManSession interface. [Guid("FC84FC58-1286-40C4-9DA0-C8EF6EC241E0")] [ComImport] [TypeLibType((short)4288)] #if CORECLR [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] #else [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)] #endif [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#")] [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "URI")] public interface IWSManSession { #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfoCount(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfo(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetIDsOfNames(); [return: MarshalAs(UnmanagedType.IUnknown)] object Invoke(); #endif /// Get method of IWSManSession interface. /// An original IDL definition of Get method was the following: HRESULT Get (VARIANT resourceUri, [optional, defaultvalue(0)] long flags, [out, retval] BSTR* ReturnValue); // IDL: HRESULT Get (VARIANT resourceUri, [optional, defaultvalue(0)] long flags, [out, retval] BSTR* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")] [DispId(1)] [return: MarshalAs(UnmanagedType.BStr)] string Get(object resourceUri, int flags); /// Put method of IWSManSession interface. /// An original IDL definition of Put method was the following: HRESULT Put (VARIANT resourceUri, BSTR resource, [optional, defaultvalue(0)] long flags, [out, retval] BSTR* ReturnValue); // IDL: HRESULT Put (VARIANT resourceUri, BSTR resource, [optional, defaultvalue(0)] long flags, [out, retval] BSTR* ReturnValue); [DispId(2)] [return: MarshalAs(UnmanagedType.BStr)] string Put(object resourceUri, [MarshalAs(UnmanagedType.BStr)] string resource, int flags); /// Create method of IWSManSession interface. /// An original IDL definition of Create method was the following: HRESULT Create (VARIANT resourceUri, BSTR resource, [optional, defaultvalue(0)] long flags, [out, retval] BSTR* ReturnValue); // IDL: HRESULT Create (VARIANT resourceUri, BSTR resource, [optional, defaultvalue(0)] long flags, [out, retval] BSTR* ReturnValue); [DispId(3)] [return: MarshalAs(UnmanagedType.BStr)] string Create(object resourceUri, [MarshalAs(UnmanagedType.BStr)] string resource, int flags); /// Delete method of IWSManSession interface. /// An original IDL definition of Delete method was the following: HRESULT Delete (VARIANT resourceUri, [optional, defaultvalue(0)] long flags); // IDL: HRESULT Delete (VARIANT resourceUri, [optional, defaultvalue(0)] long flags); [DispId(4)] void Delete(object resourceUri, int flags); /// /// /// /// /// /// /// [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "URI")] [SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "0#")] [DispId(5)] string Invoke([MarshalAs(UnmanagedType.BStr)] string actionURI, [In] object resourceUri, [MarshalAs(UnmanagedType.BStr)] string parameters, [In] int flags); /// Enumerate method of IWSManSession interface. /// An original IDL definition of Enumerate method was the following: HRESULT Enumerate (VARIANT resourceUri, [optional, defaultvalue(string.Empty)] BSTR filter, [optional, defaultvalue(string.Empty)] BSTR dialect, [optional, defaultvalue(0)] long flags, [out, retval] IDispatch** ReturnValue); // IDL: HRESULT Enumerate (VARIANT resourceUri, [optional, defaultvalue(string.Empty)] BSTR filter, [optional, defaultvalue(string.Empty)] BSTR dialect, [optional, defaultvalue(0)] long flags, [out, retval] IDispatch** ReturnValue); [DispId(6)] #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] #else [return: MarshalAs(UnmanagedType.IDispatch)] #endif object Enumerate(object resourceUri, [MarshalAs(UnmanagedType.BStr)] string filter, [MarshalAs(UnmanagedType.BStr)] string dialect, int flags); /// Identify method of IWSManSession interface. /// An original IDL definition of Identify method was the following: HRESULT Identify ([optional, defaultvalue(0)] long flags, [out, retval] BSTR* ReturnValue); // IDL: HRESULT Identify ([optional, defaultvalue(0)] long flags, [out, retval] BSTR* ReturnValue); [DispId(7)] [return: MarshalAs(UnmanagedType.BStr)] string Identify(int flags); /// Error property of IWSManSession interface. /// An original IDL definition of Error property was the following: BSTR Error; // IDL: BSTR Error; [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] string Error { // IDL: HRESULT Error ([out, retval] BSTR* ReturnValue); [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Error")] [DispId(8)] [return: MarshalAs(UnmanagedType.BStr)] get; } /// BatchItems property of IWSManSession interface. /// An original IDL definition of BatchItems property was the following: long BatchItems; // IDL: long BatchItems; int BatchItems { // IDL: HRESULT BatchItems ([out, retval] long* ReturnValue); [DispId(9)] get; // IDL: HRESULT BatchItems (long value); [DispId(9)] set; } /// Timeout property of IWSManSession interface. /// An original IDL definition of Timeout property was the following: long Timeout; // IDL: long Timeout; int Timeout { // IDL: HRESULT Timeout ([out, retval] long* ReturnValue); [DispId(10)] get; // IDL: HRESULT Timeout (long value); [DispId(10)] set; } } #endregion IWSManSession #region IWSManResourceLocatorInternal /// IWSManResourceLocatorInternal interface. [Guid("EFFAEAD7-7EC8-4716-B9BE-F2E7E9FB4ADB")] [ComImport] [TypeLibType((short)400)] #if CORECLR [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] #else [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)] #endif [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")] public interface IWSManResourceLocatorInternal { #if CORECLR [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfoCount(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetTypeInfo(); [return: MarshalAs(UnmanagedType.IUnknown)] object GetIDsOfNames(); [return: MarshalAs(UnmanagedType.IUnknown)] object Invoke(); #endif } #endregion IWSManResourceLocatorInternal /// WSMan interface. [Guid("BCED617B-EC03-420b-8508-977DC7A686BD")] [ComImport] #if CORECLR [ClassInterface(ClassInterfaceType.None)] #else [ClassInterface(ClassInterfaceType.AutoDual)] #endif public class WSManClass { } #region IGroupPolicyObject /// GPClass interface. [Guid("EA502722-A23D-11d1-A7D3-0000F87571E3")] [ComImport] [ClassInterface(ClassInterfaceType.None)] public class GPClass { } [ComImport, Guid("EA502723-A23D-11d1-A7D3-0000F87571E3"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IGroupPolicyObject { void New( [MarshalAs(UnmanagedType.LPWStr)] string pszDomainName, [MarshalAs(UnmanagedType.LPWStr)] string pszDisplayName, uint dwFlags); void OpenDSGPO( [MarshalAs(UnmanagedType.LPWStr)] string pszPath, uint dwFlags); void OpenLocalMachineGPO(uint dwFlags); void OpenRemoteMachineGPO( [MarshalAs(UnmanagedType.LPWStr)] string pszComputerName, uint dwFlags); void Save( [MarshalAs(UnmanagedType.Bool)] bool bMachine, [MarshalAs(UnmanagedType.Bool)] bool bAdd, [MarshalAs(UnmanagedType.LPStruct)] Guid pGuidExtension, [MarshalAs(UnmanagedType.LPStruct)] Guid pGuid); void Delete(); void GetName( [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxLength); void GetDisplayName( [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxLength); void SetDisplayName( [MarshalAs(UnmanagedType.LPWStr)] string pszName); void GetPath( [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPath, int cchMaxPath); void GetDSPath( uint dwSection, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPath, int cchMaxPath); void GetFileSysPath( uint dwSection, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPath, int cchMaxPath); IntPtr GetRegistryKey(uint dwSection); uint GetOptions(); void SetOptions(uint dwOptions, uint dwMask); void GetMachineName( [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxLength); uint GetPropertySheetPages(out IntPtr hPages); } #endregion IGroupPolicyObject /// GpoNativeApi public sealed class GpoNativeApi { private GpoNativeApi() { } [DllImport("Userenv.dll", CharSet = CharSet.Unicode, SetLastError = true)] internal static extern System.IntPtr EnterCriticalPolicySection( [In, MarshalAs(UnmanagedType.Bool)] bool bMachine); [DllImport("Userenv.dll", CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool LeaveCriticalPolicySection( [In] System.IntPtr hSection); } #endregion } #pragma warning restore 1591