where BRIVWTDC2 is my DC
$rec = [WmiClass]"\\BRIVWTDC2\root\MicrosoftDNS:MicrosoftDNS_ResourceRecord"
$rec | get-member -membertype method
Gives me:
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, ...
and
$rec.CreateInstanceFromTextRepresentation
Gives me:
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
So why can’t I do
$rec.CreateInstanceFromTextRepresentation("BRIVWTDC2", "stage.testdmc.com", "SECARC in CNAME BRIVWTARC2.stage.testdmc.com")
where arg is is DC, arg 2 is zone and arg 3 is textual representation = make me an alias called SECARC for RIVWTARC2.stage.testdmc.com
I just get:
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
Which says I am doing something fundamentally stupid….
help
It is permissions, we need to be someone who can change DNS ( Heads and Brick Walls 🙁 )
the following example creates a DNS Alias, must be run as Admin or a a user who can change DNS