VMware Cloud Community
wwstreet
Enthusiast
Enthusiast

Modifying DNS using DNSCmd through vRO

I have a small VB script that asks for the host name and IP then adds the server to DNS.  When I run the PS script through the PS editor it runs clean and adds the server to DNS.  When I added the script to vRO, it also looks to run cleanly and comes back saying it ran fine but does not add the server to DNS.  I can also run the script through the command line with the same arguments from vRO (literally cut and pasted from the arguments output) and it runs fine.

:smileyconfused:

Reply
0 Kudos
5 Replies
iiliev
VMware Employee
VMware Employee

Could you provide more info; eg. the script itself, how do you run it in vRO, what is the output of the run, etc.?

Reply
0 Kudos
wwstreet
Enthusiast
Enthusiast

Here is the script.

[CmdletBinding()]

Param(

    [Parameter(Mandatory=$True,Position=1)]

    [string]$nHost,

    [Parameter(Mandatory=$True,Position=2)]

    [string]$nIP

    )

echo ("Adding " + $nHost + " with the IP of " + $nIP + " to DNS")

dnscmd srvftwdc02 /RecordAdd XXXXXXX $nHost A $nIP

echo "Record Added"

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

OK, I assume you are seeing the output of the echo statements at the end of the script and the logged parameters look fine. But it's possible that dnscmd command between the echos has failed for some reason.

Is there evidence that the command has been executed successfully; eg. is there some related entries in Windows Event Viewer? Also, try to make a command that should fail (eg. by changing /RecordAdd to /Record123) - does your script report an error, or still completes successfully?

Reply
0 Kudos
wwstreet
Enthusiast
Enthusiast

It is definitely failing.  I go to DNS and I cannot find an entry.  However, when I run the script locally on my PS host, it does create the entry.  The only thing I could think of are permissions.  When I run it from the local PS host, I am running as a domain admin.  When its being ran from the vRO appliance it is not.  I tried to add this in, but once again vRO was not happy.

$password = Get-Content \\xxxxx\scripts$\Password.txt | ConvertTo-SecureString

$MyCrdential = new-object -typename System.Management.Automation.PSCredential -argumentlist xxxxxx, $password

New-PSSession -Authentication Kerberos -ComputerName xxxxxx -Credential $MyCrdential

What vRO thinks of those lines.

[2016-08-01 10:35:49.497] [E] Error in (Dynamic Script Module name : invokeScript#14) PowerShellInvocationError: Errors found while executing script

System.Management.Automation.MethodException: Cannot find an overload for "PSCredential" and the argument count: "2".

  at System.Management.Automation.Adapter.GetBestMethodAndArguments(String methodName, MethodInformation[] methods, PSMethodInvocationConstraints invocationConstraints, Object[] arguments, Object[]& newArguments)

  at System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(Type type, ConstructorInfo[] constructors, Object[] arguments)

  at Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[] args)

[2016-08-01 10:35:49.576] [E] Workfow execution stack:

***

item: 'Add to DNS/item0', state: 'failed', business state: 'null', exception: 'PowerShellInvocationError: Errors found while executing script

System.Management.Automation.MethodException: Cannot find an overload for "PSCredential" and the argument count: "2".

  at System.Management.Automation.Adapter.GetBestMethodAndArguments(String methodName, MethodInformation[] methods, PSMethodInvocationConstraints invocationConstraints, Object[] arguments, Object[]& newArguments)

  at System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(Type type, ConstructorInfo[] constructors, Object[] arguments)

  at Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[] args)

(Dynamic Script Module name : invokeScript#14)'

workflow: 'Add to DNS' (5a556062-d7d9-44b0-994f-98d223f62cc5)

|  'attribute': name=host type=PowerShell:PowerShellHost value=dunes://service.dunes.ch/CustomSDKObject?id='0bb36d0c-6921-4bf8-8f23-fbcd7a90666c'&dunesName='PowerShell:PowerShellHost'

|  'attribute': name=externalScript type=string value=C:\scripts\BPSDNSAdd.ps1

|  'attribute': name=arguments type=string value=zzz1 1.1.1.1

|  'input': name=nHost type=string value=zzz1

|  'input': name=nIP type=string value=1.1.1.1

|  'output': name=output type=PowerShell:PowerShellRemotePSObject value=null

*** End of execution stack.




Now, I did not add the $password or $MyCredential to vRO as I am not passing anything to them.

Reply
0 Kudos
jacksonecac
Enthusiast
Enthusiast

You could always use guest tools to call that PS server and execute the script on that PS server and pass the parameters through.

Reply
0 Kudos