I've created a small site which pragmatically creates DNS NS records. When I execute my code in PS (on my site.com server) it works perfectly, but when I run it from the website (hosted on my site.com server) it fails with the error: "Error creating IP 1.1.1.1. Error: Failed to get the zone information for site.com on server myServer"
My PS script is:
Add-DnsServerZoneDelegation site.com –childzonename lab00012 –IPAddress 1.1.1.1 –nameserver 1.1.1.1
My C# code is:
var labString = "lab" + tenantString;
var scriptText = "Add-DnsServerZoneDelegation site.com –childzonename " + labString
+ " –IPAddress " + ipAddress + " –nameserver " + ipAddress;
using (var runspace = RunspaceFactory.CreateRunspace())
{
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(scriptText);
var results = pipeline.Invoke();;
}
I've confirmed that the site will run PS commands such as
Get-WmiObject Win32_BIOS -Namespace 'root\\CIMV2' -computername .
without an issue.
Powershell version is 3.0, server is Windows Server 2012 running IIS 6.2.
Any help is greately appreciated, thanks in advance.