我在哪里可以找到二进制DSC资源的dll?

时间:2015-05-15 15:57:26

标签: powershell dsc powershell-module

我想扩展原始File DSC资源以添加support for ensuring that files not present in the source are deleted in the destination。要做到这一点,我想知道至少如何通过在反汇编程序上检查它的代码来实现原始代码,或者尝试在像ReferenceSource这样的地方找到它的实现,但我不能为我的生活找到实现资源的dll在我的计算机上的位置。

当我在PowerShell中发出Get-DscResource File命令时,Module属性为空。然后我尝试检查对象本身以查看是否有任何问题,但Path属性也是空的,而ParentPath属性指向C:\Windows\system32\Configuration\Schema\MSFT_FileDirectoryConfiguration,它只包含元数据文件而不是二进制dll。

我知道我可以使用我链接的其他问题中描述的方法解决这个问题,但我们需要很多具有此行为的文件夹,维护这些脚本会有问题。

理想情况下,可以扩展原始类并将此行为添加到其中,但我并不指望这是可能的。我只想将原始实现作为添加此功能的基线。

考虑到所有这些,我在哪里可以找到实现给定二进制DSC资源功能的实际dll?

1 个答案:

答案 0 :(得分:2)

我已经做了一些挖掘,除非我错过了一些非常明显的东西,我认为文件资源存在于" C:\ Windows \ System32 \ DscCoreConfProv.dll&#34 ;

您已经找到了 MSFT_FileDirectoryConfiguration - 它的WMI类位于root \ Microsoft \ Windows \ DesiredStateConfiguration命名空间中:

> Get-WmiObject -Namespace "root\Microsoft\Windows\DesiredStateConfiguration" -List | `
  Where-Object { $_.Name -eq "MSFT_FileDirectoryConfiguration" } | `
  ft

   NameSpace: ROOT\Microsoft\Windows\DesiredStateConfiguration

Name                                Methods              Properties
----                                -------              ----------
MSFT_FileDirectoryConfiguration     {GetTargetResourc... {Attributes,     Checksum, Contents, CreatedDate...}

dsccore DSCCoreProviders WMI提供商处理:

> Get-WmiObject -Namespace "root\Microsoft\Windows\DesiredStateConfiguration" -Class "__Win32Provider" | `
  Select-Object @( "Name", "CLSID" ) | `
  ft *

Name             CLSID
----             -----
dsccore          {BADCC35D-8542-4A5C-A457-0ECCCF62508A}
DSCCoreProviders {F04C3F9B-20B3-40E1-A824-3A41FE3D7931}

假设它是 DSCCoreProviders 提供商,请找到CLSID背后的dll:

> New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT"
> (Get-ItemProperty -LiteralPath "HKCR:\CLSID\{F04C3F9B-20B3-40E1-A824-3A41FE3D7931}\InProcServer32")."(default)"

C:\Windows\system32\DscCoreConfProv.dll

然而,毕竟,该文件不是.NET Framework DLL,因此您可能无法拆解它。