其中 BRIVWTDC2 是我的 DC
$rec = [WmiClass]"\\BRIVWTDC2\root\MicrosoftDNS:MicrosoftDNS_ResourceRecord"
$rec | get-member -membertype method
给我:
TypeName: System.Management.ManagementClass#ROOT\MicrosoftDNS\MicrosoftDNS_ResourceRecord
Name MemberType Definition
---- ---------- ----------
CreateInstanceFromTextRepresentation Method System.Management.ManagementBaseObject CreateInstanceFromTextRepresentation(System.String DnsServe...
GetObjectByTextRepresentation Method System.Management.ManagementBaseObject GetObjectByTextRepresentation(System.String DnsServerName, ...
和
$rec.CreateInstanceFromTextRepresentation
给我:
PS C:\Windows\system32> $rec.CreateInstanceFromTextRepresentation
MemberType : Method
OverloadDefinitions : {System.Management.ManagementBaseObject CreateInstanceFromTextRepresentation(System.String DnsServerName, System.String Contain
erName, System.String TextRepresentation)}
TypeNameOfValue : System.Management.Automation.PSMethod
Value : System.Management.ManagementBaseObject CreateInstanceFromTextRepresentation(System.String DnsServerName, System.String Containe
rName, System.String TextRepresentation)
Name : CreateInstanceFromTextRepresentation
IsInstance : True
那为什么我不能
$rec.CreateInstanceFromTextRepresentation("BRIVWTDC2", "stage.testdmc.com", "SECARC in CNAME BRIVWTARC2.stage.testdmc.com")
其中 arg 是 DC,arg 2 是区域,arg 3 是文本表示 = 让我成为 RIVWTARC2.stage.testdmc.com 的别名 SECARC
我只是得到:
Exception calling "CreateInstanceFromTextRepresentation" : "Generic failure "
At line:1 char:42
+ $rec.CreateInstanceFromTextRepresentation <<<< ("BRIVWTDC2", "stage.testdmc.com", "'SECARC' in CNAME 'BRIVWTARC2.stage.testdmc.com'")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WMIMethodException
这说明我在做一些根本上愚蠢的事情......
帮助