VMware Cloud Community
stevejohnson66
Contributor
Contributor

Executing powershell through VRO yields different results vs running powershell directly

Hello!

  I'm trying to run a powershell script that deletes an entry upon VM disposing. The script runs fine when I run it directly, using the same username/password as what is setup in VRO PSHost:

PS C:\Users\rpcvpshost> D:\steve\remove-dns.ps1 serverName1.as 10.0.0.1 89.10.in-addr.arpa

DNSName is: serverName1.as

DNSServer is: 10.0.0.1

Check for existing DNS record(s) of serverName1.as

Using Get-DnsServerResourceRecord -ZoneName redactedname.com -ComputerName 10.0.0.1 -Node serverName1.as -RRType A -ErrorAction SilentlyContinue

An A-record found to be: DnsServerResourceRecord

IPAddress is: 10.89.28.50

Querying with Get-DnsServerResourceRecord -ZoneName 0.10.in-addr.arpa -ComputerName 10.0.0.1 -Node 50.28 -RRType Ptr -ErrorAction SilentlyContinue

Value of NodePTRRecord is: DnsServerResourceRecord

Remove-DnsServerResourceRecord -ZoneName 0.10.in-addr.arpa -ComputerName 10.0.0.1 -RRtype

PTR -Node 50.28 -RecordData serverName1.as.redactedname.com.  -Force

PTR gone: 50.28

A-record has been removed: serverName1.as

But when I kick-off the same powershell script, I get the following error. I don't believe it's a network issue or permission issue, because I can run the script directly on the PSHost server, with same user/pass, and it works. ** Note, ignore if the IPs don't 100% matchup in the errors pasted here... I just did a quick search-replace so I'm not putting too much personal server information on the web 🙂

[2019-05-30 10:24:50.702] [E] (com.vmware.library.powershell/invokeScript) Error in (Dynamic Script Module name : invokeScript#14) PowerShellInvocationError: Errors found while executing script

Microsoft.Management.Infrastructure.CimException: Failed to get the zone information for redactedname.com on server 10.0.0.1.

   at Microsoft.Management.Infrastructure.Internal.Operations.CimAsyncObserverProxyBase`1.ProcessNativeCallback(OperationCallbackProcessingContext callbackProcessingContext, T currentItem, Boolean moreResults, MiResult operationResult, String errorMessage, InstanceHandle errorDetailsHandle)

[2019-05-30 10:24:50.760] [E] Workflow execution stack:

***

item: 'Invoke an external script/item0', state: 'failed', business state: 'null', exception: 'PowerShellInvocationError: Errors found while executing script

Microsoft.Management.Infrastructure.CimException: Failed to get the zone information for redactedname.com on server 10.0.0.1.

Reply
0 Kudos
1 Reply
eoinbyrne
Expert
Expert

It's important to note that running the script as a fully logged in (Desktop) user in Windows can be very different from running it as a remote user via WinRM (which is what vRO does).

Have a look at Spas Kaloferov's blog - http://kaloferov.com/blog/  - He covers this really well and his posts will most likely sort out whatever issue you're having.

One last suggestion I'd make would be can you run the script on the target box using a PowerShell remote session? If that can be made to work (even from one Windows machine to another) then you should be OK to get vRO doing it too

HTH

Reply
0 Kudos