Quantcast
Channel: VMware Communities : Popular Discussions - vCloud Director PowerCLI
Viewing all 13334 articles
Browse latest View live

Unable to connect to VCloud Director 5.1 build 5.1.1.868405

$
0
0

Hi.

 

We are not able to connect to a VCloud Director ver. 5.1.1 868405.  When we try a: connect-ciserver   we get the following error:

 

  Connect-CIServer        The underlying connection was closed: The connection was closed unexpectedly.

At line:1 char:17

+ Connect-CIServer <<<<  vclouddirector03.cloud.agesic.local

    + CategoryInfo          : NotSpecified: (:) [Connect-CIServer], CIException

    + FullyQualifiedErrorId : Cloud_ConnectivityServiceImpl_ConnectCloudServer_ConnectError,VMware.VimAutomation.Cloud.Commands.Cmdlets.ConnectCIServer

 

 

We are able to connect to a VCloud Director build  1.5 and also  the connect-viserver is working ok. The problem seems to be only with the VCloud Director 5.1.

 

We are using the latest version of PowerCLi 5.1 Release 2.

 

The error does not  give as much info.  Any one con give us some hints, were to start looking (logs etc.)

 

Thanks.


Setting Guest Customization Section Fails in 5.5

$
0
0

Hi,

 

Since migrating to vCloud 5.5 the following script fails which worked in 5.1:

 

$CIVMs = get-CIvApp $CIvAppName | get-civm
Foreach ($vm in $CIVMs) {
write-host "Customizing" $vm.name
$GuestCustomization = $vm.ExtensionData.GetGuestCustomizationSection()
$GuestCustomization.Enabled = $true
$GuestCustomization.ChangeSid = $false
$GuestCustomization.ComputerName = $vm.name
$GuestCustomization.ResetPasswordRequired = $false
$GuestCustomization.AdminPasswordEnabled = $false
$GuestCustomization.UpdateServerData()
}

 

The error is the following:

 

Exception calling "UpdateServerData" with "0" argument(s): "Bad request  - Unexpected JAXB Exception  -

cvc-complex-type.2.4.a: Invalid content was found starting with element 'AdminAutoLogonEnabled'. One of

'{"http://www.vmware.com/vcloud/v1.5":Link, WC[##other:"http://www.vmware.com/vcloud/v1.5"]}' is expected."

At line:10 char:1

+ $GuestCustomization.UpdateServerData()

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

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : CloudException

 

 

Any ideas?

 

Thanks!

Get metadata from VM within vAppTemplate

$
0
0

I am trying to obtain the MetaData currently created on a VM within a vAppTemplate in a vCloud Catalog.

 

 

If the vApp is deployed to my cloud I can get the metadata without issues with the below code:

 

$Sourcetemplate = Get-CIVM -name $SourceVM

$DestinationTemplate = get-CIVM -name $DestinationVM

$metadata = $sourceVM.ExtensionData.GetMetadata()

$DestinationVM.ExtensionData.CreateMetaData($metadata)


But I'd like to skip the deployment of the vApp just to get it's metadata. I know I can make a REST call to get the info but I'd like to stick solely within powershell. Anyone have any thoughts?


Thanks

Mav

Build URLs for: VM Console, vCloud Director vApp, VM properties in vSphere

$
0
0

Hi all

 

I made a script to generate URLs for the following access:

- Open a VM's Console in vSphere Web Client

- Open vApp (to which the VM corresponds to) in vCloud Director

- Open the VM's Summary Tab in vSphere Web Client

 

I used that to generate a list of all my VMs within vCloud Director. Makes it much easier to manage if I have direct links to the Console and the vApp. Hope this might be of interest for some of you.

 

Cheers

Chrigoli

 

-----------------------------------

#Variables

$vCenterName = "your vCenter like vc1.domain.com"

$vCloudDirName = "your vCloud Director like cell1.domain.com"

 

#Connect to vCloud Cell and vCenter

Connect-CIServer -Server $vCloudDirName

Connect-VIServer -Server $vCenterName

 

#vCenterInstance ID

$vCenterInstanceID =  $DefaultVIServers[0].InstanceUuid

 

#Objects

$vivm = "My VM, could be f.e. while looping through a list of all VMs"

$vApp = "The vApp in vCloud Director"

 

#VM MoRef -> required for Console URL and vSphere Summary URL

$vmMoRef = $vivm.ExtensionData.MoRef.ToString()

$vmMoRef = $vmMoRef.Substring(15,$vmMoRef.Length-15)

 

#vAppMoRef and OrgMoRef, required for the vCloud Director vApp URL

$vAppMoRef = $vApp.Id

$vAppMoRef = $vAppMoRef.Substring(16,$vAppMoRef.Length-16)

$OrgMoRef = $vApp.Org.Id

$OrgMoRef = $OrgMoRef.Substring(15,$OrgMoRef.Length-15)

 

#Console URL

$ConsoleURL = "https://" + $vCenterName + ":9443/vsphere-client/vmrc/vmrc.jsp?vm=urn:vmomi:VirtualMachine:" + $vmMoRef + ":" + $vCenterInstanceID.ToUpper()

                       

#vCloud vApp URL

$vcloudURL = "https://" + $vCloudDirName + "/cloud/#/vAppDiagram?vapp=" + $vAppMoRef + "&org=" + $OrgMoRef                     

                       

#vSphere Summary URL

$vsphereURL = "https://" + $vCenterURL + ":9443/vsphere-client/#extensionId=vsphere.core.vm.summary;context=com.vmware.core.model%3A%3AServerObjectRef~" + $vCenterInstanceID.ToUpper() + "%3AVirtualMachine%3A" + $vmMoRef + "~core"

Verify CPULimit and MemoryLimit for each VM in vCloud

$
0
0

Discovered someone added CPU and RAM to VM's using vCenter instead of vCD. Now I am wondering how this will affect performance. Anyone?

As a result, I have started crafting PowerCLI one-liners to compare what vCD and vCenter thinks it has for available resources.

 

THanks,

 

Jason

Add Firewall Rules to all vApps (or even one!)

$
0
0

Hi,

 

Hoping someone can help, I need to add 2x firewall rules to all vApps in preparation for an environment change. I'm trying to test the following script on one vApp (the rules are just examples), it passes through without error but doesn't apply. Any advice would be much appreciated!


--------------------------


Connect-CIServer -Server vcloud -Username administrator -Password XXXXX

 

$vAppNet = Get-CIVAPP "TEMP 2012 R2 Multi" | Get-CIVAppNetwork "vApp Network"

$vApp = Get-CIVAPP "TEMP 2012 R2 Multi"

$networkConfigSection = (Get-CIVapp "TEMP 2012 R2 Multi").extensiondata.GetNetworkConfigSection()

$vAppNetwork = $networkConfigSection.NetworkConfig | where {$_.networkName -eq "vApp Network"}

 

 

$fwService = New-Object vmware.vimautomation.cloud.views.firewallservice

$fwService.DefaultAction = "drop"

$fwService.LogDefaultAction = $false

$fwService.IsEnabled = $true

$fwService.FirewallRule = New-Object vmware.vimautomation.cloud.views.firewallrule

$fwService.FirewallRule += New-Object vmware.vimautomation.cloud.views.firewallrule

 

 

#First Rule

$fwService.FirewallRule[0].isenabled = $true

$fwService.FirewallRule[0].description = "Test1"

$fwService.FirewallRule[0].protocols = New-Object vmware.vimautomation.cloud.views.firewallRuleTypeProtocols

$fwService.FirewallRule[0].protocols.ANY = $true

$fwService.FirewallRule[0].policy = "allow"

$fwService.FirewallRule[0].destinationIp = "external"

$fwService.FirewallRule[0].sourceip = "internal"

 

 

#Second Rule

$fwService.FirewallRule[1].isenabled = $true

$fwService.FirewallRule[1].description = "Test2"

$fwService.FirewallRule[1].protocols = New-Object vmware.vimautomation.cloud.views.firewallRuleTypeProtocols

$fwService.FirewallRule[1].protocols.tcp = $true

$fwService.FirewallRule[1].policy = "allow"

$fwService.FirewallRule[1].port = "3389"

$fwService.FirewallRule[1].destinationIp = "Any"

$fwService.FirewallRule[1].sourceport = "3389"

$fwService.FirewallRule[1].sourceip = "192.168.1.81-192.168.1.89"

 

 

$vAppNetwork.Configuration.Features = $vAppNetwork.Configuration.Features | where {!($_ -is [vmware.vimautomation.cloud.views.firewallservice])}

$vAppNetwork.configuration.features += $fwService

$networkConfigSection.UpdateServerData()

 

---------------------------------

Snapshots with vCloud Director 5.1 & PowerCLI 5.1

$
0
0

(cross-post from vCloud forum)

 

Now that vCloud Director 5.1 supports snapshots, I am looking at the  PowerCLI 5.1 cmdlets and cannot find a way to create/manage/revert  snapshots.  I see it is there in the API, but don't see a way to  interface via PowerCLI.  Any ideas?

How to change Storage Profile of VM in vAppTemplate?

$
0
0

Hi everyone,

 

I've got a project in front of me to migrate existing VMs from an existing storage profile or the * profile to a newly created storage profile.  I've determined how to get this done for VMs in vApps already and am able to update the storage profiles for those VMs and see them migrate to the datastores associated with the new storage profile.  I'm currently stuck trying to figure out how to update the VMs in vApp Templates.  I can retrieve the vApp Template using Get-CIVAppTemplate, but I'm not able to iterate through the VMs contained within.

 

So, my question is:  How can I operate on the VMs in a vApp Template to be able to change the storage profile?

 

Alternatively, is there a method for achieving my goal (move everything to a new storage profile) that I'm not seeing?  I am concerned that I'm going to make a mess of things in the storage by updating VMs individually.  If there was a way to lift and move a whole tree (similar to SSMove from Lab Manager), that would be great!

 

Thanks,

Jason


Add new NIC to VM (like New-CINetworkAdapter)

$
0
0

Hi all

 

I'm trying to find out how to simply add a new NIC to a VM within a vApp.

 

Something like "New-CINetworkAdapter" would be great, but unfortunately does not exist..

 

Anyone some experience or tipps for me on how to add a NIC to a VM within vCloud Director?

 

Have already tried to create the NIC via New-NetworkAdapter in vSphere (which actually works), but then vCloud Director does not recognize the NIC and still thinks the VM has no NIC.

 

Thanks and cheers

Chrigoli

Trouble adding more "CIVM" to a "CIVApp" in vCloud via PowerCLI 5.5

$
0
0

Hi All,

I am having trouble performing some tasks in PowerCLI that I can do easily in the GUI.

 

Firstly, in the vCloud Director GUI, I can create a new vApp from a template that has one machine in it. I can also do that task from PowerCLI with something like the following code:

  Connect-CIServer -server x.x.x.x -user ***** -org org-development -Password *****
  $myVappName = 'TestApp03'
  $myTemplate = Get-CIVAppTemplate -Name 'vWin2012-Template'
  $myOrgVdc = Get-OrgVdc -Name 'vOrgDevelopment'
  New-CIVApp -Name $myVappName -Description "Testonly." -OrgVdc $myOrgVdc -VAppTemplate $myTemplate
 
If I want to add some more VM's to this newly create vApp 'TestApp03', I can do it easily in the vCloud Director web GUI by browsing to the Virtual machines for the vApp, then on the actions click "add VM".  I can then add several more copies of the VM from the template.


My problem is how do I perform this same action in PowerCLI ?  How to add more machines from an existing template into an existing vApp ?

 

I want to only use "CI" type cmdlets and avoid having to "Connect-VIServer".
The version of PowerCLI that I have installed is "VMware-PowerCLI-5.5.0-1295336.exe"

 

Any insights or assistance is greatly appreciated.

Sample Script: Creating an Empty vApp with vCloud PowerCLI

$
0
0

Hi Everyone,

 

The New-CIVApp cmdlet does not allow us to create empty vApps (which can be useful when templating out network configurations, for example). This shortcoming can be overcome by calling the "ComposeVApp" method of a vDC directly. In case anybody else runs into this same problem, I've included my script. Note that it uses the first created organization vDC, so ymmv.

 

I also realize that I could probably get the vDC directly instead of going through ExtensionData, but I think that this illustrates that "otherwise hidden" parameters can be discovered rather easily through this object ("Get-Member" is your friend!)

 

$newvapp = New-Object VMware.VimAutomation.Cloud.Views.ComposeVAppParams

$newvapp.Name = "My New vApp"

$newvapp.Description = "An empty vApp"

$result = (DefaultCIServers[0].ExtensionData.OrganizationReferences.OrganizationReference | Where-Object {$_.Name -like "organization name"}).GetCIView().VDCs.VDC[0].GetCIView().ComposeVApp($newvapp)

$result.tasks.task.wait($null)

Write-Host "$($result.tasks.task.Operation) $($result.tasks.task.status)

Export all vCloud Edge Gateway rules to CSV file

$
0
0

Hi,

 

For documenation purposes, I need to make a list of all vCloud firewall rules. Specifically, I am looking for Edge name, Rule ID, name, source, source port, destination, destination port, protocol, action, log, enabled/disabled

 

While I am terrible at any kind of scripting, I believe PowerCLI can accomplish this. Does anyone have a script or know where I can find one to obtain this info?

 

Thanks in advance!

Want to Link vApp Networks with the vSphere VDPortgroup Created when network is powered up

$
0
0

Hello

 

I am needing to get a listing of vApp Networks, via "Get-civappnetwork" and compare this to the networks created in vSphere, when these virtual networks are powered up.


You can see the vSphere Virtual Distributed Port group created by doing a "Get-VDPortgroup".

 

example:

vApp network                     vSphere VDPortgroup

(Get-civappnetwork)          (Get-VDPortgroup)           

 

 

network-1a                         vxw-dvs-51-virtualwire-150-sid-8003-dvs.VCDVS[network-1a]-[numbers and letters]     example ( -64723045-353d-d45g-33434)

network-2a                         vxw-dvs-51-virtualwire-150-sid-8003-dvs.VCDVS[network-2a]-[numbers and letters]

 

as you can see from above, the vApp network name appears in the vSphere VDPortgroup name, but the vSphere VDPortgroup name has an unknown quantity of numbers, letters and dashes at the end of the string.

 

I would like to be able to get the vApp Network name, and find the corresponding VDPortGroup name, or vice versa.

 

thanks

David

VcloudAir freeppace on guests

$
0
0

We are vcloud Air Customers and we also use vcloud Director in our private cloud.

I have a powercli script that I use in my private cloud to obtain guest free space on VCD vms.   

Unfortunately, the private cloud script takes the guid from VCD vms and  gets the disk space info from Virtual center.

This process will not work on Vcloud Air  as I do not have access to virtual center.

 

Does anyone know how to get disk information from vcloud air

Is there a way to get memory and CPU utilization report for a VM in vcloud director ?

$
0
0

Is there a way to get memory and CPU utilization report for a VM in vcloud director against the assigned cpu and memory using powercli ?


Get-ProviderVdc returns Null values for StorageUsedGB StorageAllocatedGB and 0 (zero) for StorageTotalGB

$
0
0

Has anyone else seen this?  The Get-OrgVdc does return Storage information but I want to collect it from the Provider VDC

PowerCLI C:\Scripts\vmware> Get-ProviderVdc moc-vmcl1101-pvdc

 

Name                           Status          Enabled CpuUsedGhz      MemoryUsedGB    StorageUsedGB

----                           ------          ------- ----------      ------------    -------------

moc-vmcl1101-pvdc              Ready           True    173.67 (65.9%)  816.980 (82.4%)

 

 

 

PowerCLI Version

----------------

   VMware vSphere PowerCLI 5.5 Release 1 build 1295336

---------------

Snapin Versions

---------------

   VMWare AutoDeploy PowerCLI Component 5.5 build 1262826

   VMWare ImageBuilder PowerCLI Component 5.5 build 1262826

   VMware vCloud Director PowerCLI Component 5.5 build 1295337

   VMware License PowerCLI Component 5.5 build 1265954

   VMware VDS PowerCLI Component 5.5 build 1295334

   VMware vSphere PowerCLI Component 5.5 build 1295334

   VMware vSphere Update Manager PowerCLI 5.0 build 432001

PowerCLI 5.0.1 vCloud cmdlets: get-orgvdc bug, ProviderVdcReference.id attribute blank

$
0
0

Hi,

 

1) Get-OrgVdc bug

 

If your vDC name contains space (e.g. "my vDC"), the following command will fail because the REST API call is not urlencoded (%20 instead of space):

$all_powered_on_vms = Search-Cloud -QueryType adminVM -Filter "IsVAppTemplate==False;status==POWERED_ON"

$vm = $all_powered_on_vms[0]

$vdc = Get-OrgVdc -Id $vm.Vdc     <--- fail

 

with the following GET url request:

Get-OrgVdc        The specified Href 'https://vcloud/api/query?type=adminOrgVdc&format=idrecords&filter=isSystemVdc==false;(name==my VDC)&pageSize=128' is not valid.

 

After having tested with the java restclient, it works if urlencoded.

 

So the workaround is to use Get-CIView.

 

2) ProviderVdcReference lacks Id attribute

 

Let's say that you retrieve your vDC with this code:

$vdc = Get-CIView -Id $vm.vdc

$vdc.ProviderVdcReference.Id is blank

 

The workaround is to compute it with the href attribute:

$pvdc_id = $vdc.ProviderVdcReference.href.split('/')[-1]

$pvdc_urn = "urn:vcloud:providervdc:" + $pvdc_id

$pvdc = Get-ProviderVdc -id $pvdc_urn

Weird error with Search-Cloud...

$
0
0

I ran thw Search-Cloud command for the first time and got error stating it didn't know what "Type" was. So I ran the help and checked the online version of help too and example 2 has the following:

 

-------------- Example 2 --------------

Search-Cloud -Type vAppTemplate

Searches the cloud server for virtual appliance templates. The user is  connected as a cloud user.

 

If I ran that exact command as is and I get the following error:

 

PS C:\> Search-Cloud -Type vAppTemplate

Search-Cloud : A parameter cannot be found that matches parameter name 'Type'.
At line:1 char:19
+ Search-Cloud -Type <<<<  vAppTemplate
    + CategoryInfo          : InvalidArgument: (:) [Search-Cloud], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.Cloud.Commands.Cmdlets.SearchCloud

 

 

Yet if I leave out "Type" I get the expected results...

 

PS C:\> Search-Cloud vAppTemplate

 

OwnerName    : system
CatalogName  : Build 60.00 (LC1)
IsPublished  : True
Name         :  Workspace 60.00
Vdc          : urn:vcloud:vdc:fe195c89-b533-4e06-8aa8-1a7b37161802
VdcName      : My_vDC
Org          : urn:vcloud:org:900c1326-586a-4a9b-ba00-b64dcca88fc0
CreationDate : 3/22/2012 4:30:11 PM
IsBusy       : False
IsGoldMaster : False
IsEnabled    : True
Status       : RESOLVED
IsDeployed   : False
Href         :
Id           : urn:vcloud:vapptemplate:1be79364-793a-41f8-bf85-b8c1e2296863
Type         :
AnyAttr      : {cpuAllocationMhz, isInCatalog, task, numberOfShadowVMs...}
Link         :

 

This is not a major issue, but it's not the only issue I've picked up with Search-Cloud, If I try filter by CatalogName I get and error too...

 

PS C:\> Search-Cloud VAppTemplate -filter 'CatalogName==Build 60.00 (LC4)'


Search-Cloud : 3/25/2012 4:18:59 PM    Search-Cloud        The specified Href 'https://10.1.101.181/api/query?type=vAppTemplate&format=idrecords
&filter=catalogName==Build 60.00 (LC4)&pageSize=128' is not valid.
At line:1 char:13
+ Search-Cloud <<<<  VAppTemplate -filter 'CatalogName==Build 60.00 (LC4)'
    + CategoryInfo          : NotSpecified: (:) [Search-Cloud], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.Cloud.Commands.Cmdlets.SearchCloud

 

 

Here are my versions:

 

PS C:\> Get-PowerCLIVersion

 

PowerCLI Version
----------------
   VMware vSphere PowerCLI 5.0.1 build 581491
---------------
Snapin Versions
---------------
   VMware AutoDeploy PowerCLI Component 5.0 build 544967
   VMware ImageBuilder PowerCLI Component 5.0 build 544967
   VMware vCloud Director PowerCLI Component 1.5 build 581492
   VMware License PowerCLI Component 5.0 build 544881
   VMware vSphere PowerCLI Component 5.0 build 581435

 

 

Anyone get the same error?

Vcloud PowerCLI - Email whole Org

$
0
0

Hi CLIers.

 

In vclouds UI we see there is a button to email all available email addresses in that certain vCloud Org.

 

Is there some call that can be made from PowerCLI to perform this Action?

 

Say I want to notify how a whole Org that they have X number of VMs.

 

Thanks for your help in advance,

 

-Joel

Accessing vCloud REST API with Powershell

$
0
0

Hello,

 

     I have come to the conclusion that the new vCLoud cmdlets are not enough for what I plan on doing, and I plan to extend upon the cmdlets by using the API via REST. I have been fiddling with Invoke-RestMethod a bit, but I cannot seem to get the syntax to work despite reading the pdf regarding vCloud API Programming. Can anyone give me a generic start into this? Thanks!

Viewing all 13334 articles
Browse latest View live


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