What am I missing ??
best regards,
Steen Tųttrup
----------------------
ManagementPath Path = new ManagementPath();
Path.ClassName = "MicrosoftDNS_ResourceRecord";
Path.NamespacePath = "\\\\server\\root\\microsoftdns";
ManagementClass Class = new ManagementClass(Path);
ManagementObject oManObject = Class.CreateInstance();
string sLocalPrimary = sPrimaryName;
if (!sLocalPrimary.EndsWith(".")) {
sLocalPrimary += ".";
}
oManObject["ContainerName"] = "test.dk.";
oManObject["DnsServerName"] = "server.test.dk";
oManObject["DomainName"] = "test.dk";
oManObject["OwnerName"] = "www.test.dk";
oManObject["RecordData"] = "test.dk.";
oManObject["TextRepresentation"] = "www.test.dk IN CNAME test.dk.";
oManObject["TTL"] = 3600;
oManObject.Put();
"Steen Tøttrup" <som...@somewhere.co> wrote in message news:#fub0B2C...@TK2MSFTNGP12.phx.gbl...
I'm really stuck here, and hope somebody can help me!!
I've figured out how to change and delete existing records, but can't get
the last bit right.
This is how I expected it to work, but I get "Invalid operation" when
calling Put on the MangementObject.
What am I missing ??
best regards,
Steen Tøttrup
string sPath =
"\\\\server\\root\\microsoftdns:MicrosoftDNS_ResourceRecord.DnsServerName=\"
" + sServer + "\"";
ManagementObject oManObject = new ManagementObject(sPath);
InvokeMethodOptions Options = new InvokeMethodOptions();
Options.Context.Add("DnsServerName", sServer);
Options.Context.Add("ContainerName", sDomainName);
Options.Context.Add("TextRepresentation", sTextRepresentation);
ManagementBaseObject oOutput =
oManObject.InvokeMethod("CreateInstanceFromTextRepresentation", oManObject,
Options);
Yes, I had a try with this, but it leaves me with an "Invalid object path"
error in the InvokeMethod call.
If I leave the "DnsServerName=" out of the path, I get an error in the new
ManagementObject line..
Any ideas as to what I'm doing wrong ??
best regards,
Steen
ManagementClass dnsRRClass = new ManagementClass(
@"\\ServerNameHere\root\MicrosoftDNS",
"MicrosoftDNS_ResourceRecord",
null);
ManagementBaseObject inParams
=
dnsRRClass.GetMethodParameters("CreateInstanceFromTextRepresentation");
inParams["DnsServerName"]
= sServer;
inParams["ContainerName"] =
sDomainName;
inParams["TextRepresentation"] =
sTextRepresentation;
ManagementBaseObject outParams =
dnsRRClass.InvokeMethod("CreateInstanceFromTextRepresentation", inParams,
null);
Console.WriteLine("Executing the method returns {0}",
outParams["ReturnValue"]);
"Steen Tøttrup" <som...@somewhere.co> wrote in message news:uJw0KymD...@TK2MSFTNGP10.phx.gbl...
best regards,
Steen Tųttrup
"Andy Cheung [MSFT]" <ha...@online.microsoft.com> wrote in message
news:OyfPR3nD...@TK2MSFTNGP12.phx.gbl...
"Steen Tųttrup" <som...@somewhere.co> wrote in message
Can this be done using WMIC???
Thomas
--
Thomas Lee
(t...@psp.co.uk)
"Thomas Lee" <t...@psp.co.uk> wrote in message news:gCvEJqW+...@qa.com...