ActiveX コントロール SetACL.ocx があります。私のシステムに登録されており、C# (Visual Studio 2010) から問題なく使用できます。Visual Studio のオブジェクト ブラウザには、すべてのメソッドが表示されます。
ただし、PowerShell では、約 3 分の 1 のメソッドが表示されません。不足しているメソッドの 1 つを呼び出そうとすると、MethodNotFound が返されます。
PS C:\> $setacl = New-Object -ComObject setacl.setaclctrl.1
PS C:\> $setacl | Get-Member
TypeName: System.__ComObject#{85869435-0ee3-440b-bf69-6c52c6638073}
Name MemberType Definition
---- ---------- ----------
AddACE Method int AddACE (string, bool, string, int, bool, int, int)
AddDomain Method int AddDomain (string, string, int, bool, bool)
AddTrustee Method int AddTrustee (string, string, bool, bool, int, bool, bool)
GetLastAPIError Method int GetLastAPIError ()
GetLastAPIErrorMessage Method string ()
GetLastListOutput Method string GetLastListOutput ()
GetResourceString Method string GetResourceString (int)
Reset Method void Reset ()
Run Method int Run ()
SetAction Method int SetAction (int)
SetListOptions Method int SetListOptions (int, int, bool, int)
SetLogFile Method int SetLogFile (string)
SetOwner Method int SetOwner (string, bool)
SetPrimaryGroup Method int SetPrimaryGroup (string, bool)
PS C:\> $setacl.SetObject("test", 1)
Method invocation failed because [System.__ComObject#{85869435-0ee3-440b-bf69-6c52c6638073}] doesn't contain a method named 'SetObject'.
At line:1 char:18
+ $setacl.SetObject <<<< ("test", 1)
+ CategoryInfo : InvalidOperation: (SetObject:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
PowerShell では使用可能なすべてのメソッドが表示されないのに、Visual Studio のオブジェクト ブラウザーでは表示される理由の手がかりはありますか?
PowerShell の 32 ビット バージョンと 64 ビット バージョンの両方を試しました。
更新 1:
以下は、ODL ファイルに含まれていないメソッドの 1 つの署名です (はい、OCX の完全なソース コードを持っています。私はその作成者です)。
[id(2), helpstring ("Set the object on which all actions are to be performed")]
LONG SetObject(BSTR sObjectPath, LONG nObjectType);
更新 2:
これは OCXのソース コードで、 sourceforge で直接閲覧できます。
更新 3:
OCX はsourceforge からダウンロードできます。ファイル SetACL 2.2.0.zip に含まれています。
更新 4 - 考えられる解決策:
DISPID 1 ~ 7 のメソッドをより高い DISPIDS に変更し、DISPIDS 1 ~ 7 の 7 つの新しいダミー メソッドを導入すると、うまくいくようです。これで、ダミー メソッドを除くすべてが PoSh に表示されます。
誰もこれについて説明がありますか?