Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

vRO 7 and Powershell 4

$
0
0

This is a small PS script I am trying to use to add servers to DNS as they are built. When I call the script from my PS server it runs with no errors.

 

[CmdletBinding()]

Param(

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

    [string]$nHost,

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

    [string]$nIP

)

$vcUser = "basspro\svcvra"

$cred = New-Object –TypeName "System.Management.Automation.PSCredential" –ArgumentList $vcUser, (Get-Content ||UNC PATH\password.txt | ConvertTo-SecureString)

$session = new-pssession -computername XXXXXXX -credential $cred

Enter-PSSession -session $session

Invoke-Command -ScriptBlock {dnscmd XXXXXXt /recordadd basspro.net $args[0] A $args[1]} -ArgumentList ($nHost, $nIP) -Session $session

exit-pssession

Remove-PSSession -Session $session

 

However, when I call the script from vRO I get an error regarding the password being NULL.  Below is the error that vRO throws.  I have verified that the arguement variables are correct.  When I take that variable and paste it into the PS script on the PS server like this:  .\ADDDNS.ps1 servername IP

 

Error in (Dynamic Script Module name : invokeScript#14) PowerShellInvocationError: Errors found while executing script

System.Management.Automation.MethodInvocationException: Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument "password" is null. Change the value of argument "password" to a non-null value." ---> System.Management.Automation.PSArgumentNullException: Cannot process argument because the value of argument "password" is null. Change the value of argument "password" to a non-null value.

   at System.Management.Automation.PSCredential..ctor(String userName, SecureString password)

   --- End of inner exception stack trace ---

   at System.Management.Automation.DotNetAdapter.AuxiliaryConstructorInvoke(MethodInformation methodInformation, Object[] arguments, Object[] originalArguments)

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

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

ConvertTo-SecureString : Key not valid for use in specified state.

 

 

At C:\scripts\BPSDNSAdd.ps1:11 char:156

+ ... password.txt | ConvertTo-SecureString)

+                    ~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [ConvertTo-SecureString], C

   ryptographicException

    + FullyQualifiedErrorId : ImportSecureString_InvalidArgument_Cryptographic

   Error,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand

 

 

 

[2016-08-12 08:35:15.077] [E] Workfow execution stack:

***

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

System.Management.Automation.MethodInvocationException: Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument "password" is null. Change the value of argument "password" to a non-null value." ---> System.Management.Automation.PSArgumentNullException: Cannot process argument because the value of argument "password" is null. Change the value of argument "password" to a non-null value.

   at System.Management.Automation.PSCredential..ctor(String userName, SecureString password)

   --- End of inner exception stack trace ---

   at System.Management.Automation.DotNetAdapter.AuxiliaryConstructorInvoke(MethodInformation methodInformation, Object[] arguments, Object[] originalArguments)

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

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

ConvertTo-SecureString : Key not valid for use in specified state.

 

 

At C:\scripts\BPSDNSAdd.ps1:11 char:156

+ ... password.txt | ConvertTo-SecureString)

+                    ~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [ConvertTo-SecureString], C

   ryptographicException

    + FullyQualifiedErrorId : ImportSecureString_InvalidArgument_Cryptographic

   Error,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand

 

(Dynamic Script Module name : invokeScript#14)'

workflow: 'Add to BPS 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=wsdinfsql09 172.24.74.24

|  'input': name=payload type=Properties value=#[#workflow.execution.id#=#string#2c98828a5628092f0156760050672196#+#workflow.execution.endDate#=#Date#20160810144908-0500#+#lifecycleState#=#Properties##[#phase#=#string#POST#+#state#=#string#VMPSMasterWorkflow32.MachineProvisioned#]##+#componentId#=#string#tier1w2k8s#+#blueprintName#=#string#_Software Testing - W2K8 BP#+#componentTypeId#=#string#Infrastructure.CatalogItem.Machine.Virtual.vSphere#+#IaaSTimeoutId#=#number#8286.0#+#requestId#=#string#d5a5b051-fadc-401a-990a-5b348cc41038#+#endpointId#=#string#c39838f0-76b8-45a2-872a-b80b7b511436#+#machine#=#Properties##[#externalReference#=#string#vm-11512#+#owner#=#string#WWSda@basspro.net#+#name#=#string#wsdinfsql09#+#id#=#string#aa853952-1d9e-4646-abc3-c2c2dcf4ff57#+#type#=#number#0.0#+#properties#=#Properties##[#VirtualMachine.Storage.Cluster.Name#=#string#PROD_DATASTORE_CLUSTER_FTW_LOCAL#+#VirtualMachine.Cafe.Blueprint.Id#=#string#W2K8SoftwareTesting#+#VirtualMachine.Disk0.Name#=#string#Hard disk 1#+#__InterfaceType#=#string#vSphere#+#VirtualMachine.Network0.PrimaryDns#=#string#172.24.37.101#+#VirtualMachine.Network0.DnsSuffix#=#string#basspro.net#+#tstpTime#=#string#mstp.1300#+#__VirtualMachine.Allocation.InitialMachineState#=#string#SubmittingRequest#+#VirtualMachine.Cafe.Blueprint.Component.TypeId#=#string#Infrastructure.CatalogItem.Machine.Virtual.vSphere#+#VirtualMachine.Admin.UUID#=#string#501fbb34-e7d0-399e-4595-693ab8cf0f60#+#bps.os#=#string#ws#+#__api.request.id#=#string#d5a5b051-fadc-401a-990a-5b348cc41038#+#Custom.ComponentMachine.NoIndexOnFirst#=#string#false#+#VirtualMachine.Disk0.Size#=#string#50#+#targetVM#=#string##+#bps.srvrfunct#=#string##+#Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.Requested#=#string#*#+#Custom.ComponentMachine.HostnameScheme#=#string#{bps.os}{bps.env}{bpsApp}{bps.mw}{bps.srvrfunct}{##}#+#__api.request.callback.service.id#=#string#260b0a87-4c85-46d9-ac51-c6e74463ca11#+#Custom.Hostname.OwnerShortNameIdentifier#=#string#USR#+#__DailyCost#=#string#{"type":"moneyTimeRate","cost":{"type":"money","currencyCode":"USD","amount":1.39},"basis":{"type":"timeSpan","unit":4,"amount":1}}#+#Hostname#=#string#wsdinfsql09#+#VirtualMachine.Cafe.Blueprint.Name#=#string#_Software Testing - W2K8 BP#+#Cafe.Shim.VirtualMachine.TotalStorageSize#=#string#50#+#VirtualMachine.Storage.Cluster.Automation.Behavior#=#string#manual#+#__Legacy.Workflow.ImpersonatingUser#=#string##+#__Legacy.Workflow.User#=#string#WWSda@basspro.net#+#__VirtualMachine.ProvisioningWorkflowName#=#string#CloneWorkflow#+#VirtualMachine.Storage.Cluster.Automation.Enabled#=#string#True#+#VirtualMachine.Network0.DnsSearchSuffixes#=#string#basspro.net#+#VirtualMachine.Network0.NetworkProfileName#=#string#vRA Prod#+#VirtualMachine.Network0.SecondaryWins#=#string##+#VirtualMachine.Network0.SubnetMask#=#string#255.255.255.0#+#VirtualMachine.Network0.SecondaryDns#=#string#10.33.80.103#+#tApp#=#string##+#Extensibility.Lifecycle.Properties.VMPSMasterWorkflow32.MachineProvisioned#=#string#*#+#VirtualMachine.Disk0.ExternalID#=#string#6000C290-eb82-8d02-558d-7a42cc09c183#+#VirtualMachine.Disk0.Storage.Cluster.ExternalReferenceId#=#string#group-p3288#+#VirtualMachine.Network0.AddressType#=#string#Static#+#__Cafe.Request.VM.LeaseDays#=#string#1#+#__request_reason#=#string##+#__Cafe.Root.Request.Id#=#string#447b424c-90fc-4d7e-bacd-2dc091d11ea6#+#_number_of_instances#=#string#1#+#Custom.Deployment.NoIndexOnFirst#=#string#true#+#VirtualMachine.Admin.AgentID#=#string#03b21f42-ca0f-801a-2dd5-260aa701c713#+#VirtualMachine.Disk0.IsClone#=#string#true#+#VirtualMachine.Network0.MacAddress#=#string#00:50:56:9f:33:e9#+#__Cafe.Request.VM.ArchiveDays#=#string#45#+#__Cafe.Request.VM.HostnamePrefix#=#string#SRV#+#VirtualMachine.Disk0.DeviceID#=#string#SCSI (0:0)#+#bps.env#=#string#d#+#__Cafe.Request.BlueprintType#=#string#1#+#bps.mw#=#string#sql#+#__Notes#=#string#Tier 1

Windows 2008 R2 Standard#+#tStakeHolder#=#string#IT.Server.Windows#+#tstrtTime#=#string#mstrt.0800#+#VirtualMachine.Memory.Size#=#string#4096#+#bps.dept#=#string#it#+#VirtualMachine.Cafe.Blueprint.Component.Cluster.Index#=#string#0#+#VirtualMachine.CPU.Count#=#string#1#+#__Clone_Type#=#string#CloneWorkflow#+#__clonespec#=#string##+#VirtualMachine.Admin.TotalDiskUsage#=#string#51200#+#VirtualMachine.Disk0.Label#=#string#Hard disk 1#+#Custom.SetCustomHostname.Execute#=#string#true#+#bpsApp#=#string#inf#+#__trace_id#=#string#lzURVjR0#+#vcServer#=#string#srvvcsitftw00.basspro.net#+#__iaas_request_binding_id#=#string#2717c342-69b0-4058-b9c1-d8187a45a538#+#VirtualMachine.Cafe.Blueprint.Component.Id#=#string#tier1w2k8s#+#VirtualMachine.Network0.Address#=#string#172.24.74.24#+#osfamily#=#string#Windows#+#VirtualMachine.Network0.PrimaryWins#=#string##+#VirtualMachine.Disk0.Storage.Cluster.Name#=#string#PROD_DATASTORE_CLUSTER_FTW_LOCAL#+#VirtualMachine.Storage.Cluster.ExternalReferenceId#=#string#group-p3288#+#Custom.Deployment.HostnameScheme#=#string##+#VirtualMachine.Disk0.Storage#=#string#PROD_DATASTORE_CLUSTER_FTW_LOCAL#+#tmDay#=#string#m.Sunday#+#Vrm.ProxyAgent.Uri#=#string#https://itmgma.basspro.net/VMPS2Proxy#+#__reservationPolicyID#=#string#7956ac63-f0e5-4d92-826d-0ba81535c61d#+#tPatchDay#=#string#p.Thursday#+#VirtualMachine.Storage.Name#=#string#PROD_DATASTORE_CLUSTER_FTW_LOCAL#+#__clonefrom#=#string#TMPL_W2K8 Standard#+#tTier#=#string#'Tier 4'#+#VirtualMachine.Network0.Gateway#=#string#172.24.74.1#+#VirtualMachine.Network0.Name#=#string#INT-VRA-PROD_VLAN74#+#VirtualMachine.Disk0.IsFixed#=#string#False#]##]##+#workflow.execution.state#=#string#COMPLETED#+#workflow.execution.startDate#=#Date#20160810144907-0500#]#

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

*** End of execution stack.


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>