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

vCloud: vShield Edge FW Rules

$
0
0

Hi all

 

I'm looking for a way to get and set firewall rules on a vShield Edge firewall in a vCloud environment.  My final target is to write two scripts; one that will export the firewall rules from a given vShield Edge firewall to CSV and another script that will import them from CSV into another vShield Edge firewall.  This is to help with a DR scenario where we'll shift a public IP block from a public facing vShield Edge in one vCloud environment to one in another environment.

 

I need to do this through the vCloud API or PowerCLI because, if I do it directly at the vShield Manager, vCloud won't know about the changes that have been made.  I'm not a Powershell expert by any means but I'm picking things up as I have a need for them.  I've looked through several blog posts people have written and it looks as though I need to dig down into ExtensionData as there aren't get and sets for the info I'm after.  I've found some info which is really close to what I'm after in this post:

Deepdive: vCloud vApp Networks | Geek after Five

 

This covers pulling the information from the GetNetworkConfigSection method in the Extensiondata of a vApp.  The issue I have is that the vShield Edge / network I'm after information from, isn't actually in a vApp.  It's a bit of a funny setup but I've got a vShield Edge firewall connected to the Internet and to an Org Network.  No VMs or vApps are connected to the Org Network.  Instead, I have about a dozen vApps, each with a vApp network and a vShield Edge connecting the vApp network to the Org Network.  This was a strategy recommended by VMware to overcome the limitation of 10 networks on the public facing vShield Edge and works brilliantly in that respect.  However... the public facing vShield Edge and Org Network are not in a vApp I can't use $vapp.ExtensionData.GetNetworkConfigSection()

Thinking about it while writing this, I guess one option would be to create another vApp and add the Org Network to it, then I might be able to get the info using GetNetworkConfigSection() but I wonder if there is a better/proper/prettier way to do it.

 

thanks in advance!

 

Dave


VMware.VimAutomation.Logging.SoapInterceptor not found

$
0
0

Hi,

 

I'm trying to reboot a VM with PowerCli and then wait until the vm is running. I user this command for this:

 

Get-CIVM -VApp $VCloudVappName -Name $VCloudVmName | Restart-CIVMGuest -Confirm:$false -WhatIf | Wait-Tools

 

This works at least the last command. Wait-Tools every time gets an error

 

Connect-VIServer : Die Datei oder Assembly "VMware.VimAutomation.Logging.SoapInterceptor, Version=1.0.0.646, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
In C:\tmp\reboot.ps1:13 Zeichen:1
+ Connect-VIServer -Server $VCloudHost -Credential $mycredsVCloud
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [Connect-VIServer], FileNotFoundException    + FullyQualifiedErrorId : System.IO.FileNotFoundException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

Wait-Tools : Die Datei oder Assembly "VMware.VimAutomation.Logging.SoapInterceptor, Version=1.0.0.646, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
In C:\tmp\reboot.ps1:15 Zeichen:104
+ ... VCloudVmName | Restart-CIVMGuest -Confirm:$false -WhatIf | Wait-Tools
+                                                                ~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [Wait-Tools], FileNotFoundException    + FullyQualifiedErrorId : System.IO.FileNotFoundException,VMware.VimAutomation.ViCore.Cmdlets.Commands.WaitTools

It's a german error message, but it says something like "File or assembly ... or a dependency not found. The system can not find the specified file.

 

I have PowerCli Version 6.5.1, the latest VIX Tools, and I already restarted my Computer

Can someone help me?

Deleting CIVM from a CIvApp

$
0
0

Hi,

 

I would like to remove a specific CIVM from a CIvApp. The CIvApp is stopped and powered off. The following bit of code works but performance is inconsistent. Sometimes it takes a few seconds, sometimes it takes extremely long to do 1 VM (1min 15 seconds). Even with the PowerCLI XmlSerializers installed. It's more than like it's because I'm using Get-CIVM.

 

Works:

$civapp = "Test"
$civm = Get-CIVM -vApp $civapp -Name "VM1"
$civm.ExtensionData.Delete()

 

 

I've tried using Search-Cloud but it appears I can't do anything with the object once I found it:

No ExtensionData property:

$civm2 = Search-Cloud -QueryType AdminVM -Filter "ContainerName==Test;Name==VM2"

 

I also thought about using Get-CIView and then using RecomposeVApp but I'm not sure what to pass that to delete a VM:

 

$civapp = "Test"
$ciview = "get-ciview -ID $civApp.Id"
$ciview.RecomposeVApp("VM2" ,deleteItem) //Not sure what to do here.

 

 

Or does anyone know of another method to delete CIVM's from a CIvApp via the SDK perhaps? Or maybe those mystical cloud views?


Thanks!

Disable TLS 1.0 in vCloud Director 5.6.x

$
0
0

Has anyone been able to disable TLS 1.0 for cell servers in vCloud Director 5.6.x?   The documentation for 5.5.x is the only reference I can find, but the command argument listed no longer exists in 5.6.x as referenced in the following KB article:

Managing the List of SSL Protocols Allowed by vCloud Director (2112282) | VMware KB

The "ssl-protocols" command argument as part of "./cell-management-tool ssl-protocols -l" no longer exists.

 

Any help is appreciated. -John.

The remote server returned an error: (406) Not Acceptable

$
0
0

Hi all,

 

I'm new with Cloud Director and PowerCLI and I would like connect my vCD to create some stuffs.  But when I try to connect my vCD, I receive the following error:

Connect-CisServer The remote server returned an error: (406) Not Acceptable.. vmware

 

Executed command :

Connect-CIsServer -server xyz.com

 

Any idea is welcome...

 

Thx

External Networks

$
0
0

Does anyone know of a way to create external networks with PowerCLI?

Working with vCloud Metadata in PowerCLI

$
0
0

Based on Jake Robinson's post at GeekAfterFive - Infrastructure as Code, it seems the sample scripts in Alan Renouf's March 30, 2012 post to the VMware PowerCLI Blog, Working with vCloud Metadata in PowerCLI, will not work with vCloud Director 5.1. Has anyone modified the Get-CIMetaData function to return the Value from the TypedValue element? After removing the Select-Object Cmdlet (to select all properties and see what came back):

 

PS> Get-Org -Name CloudSandbox | Get-CIVM | Get-CIMetaData

 

Domain          : VMware.VimAutomation.Cloud.Views.MetadataDomainTag

Key             : Test Key

Value           :

TypedValue      : VMware.VimAutomation.Cloud.Views.MetadataStringValue

Client          : VMware.VimAutomation.Cloud.Views.CloudClient

Href            : [removed]/metadata/SYSTEM/Test%20Key

Type            : application/vnd.vmware.vcloud.metadata.value+xml

Link            : {, , }

AnyAttr         :

VCloudExtension :

 

The type of the value is provided (MetadataStringValue), however thus far I haven't been able to get the Value from the TypedValue element. What am I missing?

Get-CIRole/Get-CIUser not working?

$
0
0

Hi,

 

I have a problem with some scripts, that used to work and now stop functioning. While investigating I found that Get-CIRole and/or Get-CIUser are no longer working as expected, and I do not know why.

 

I try and get the "organization administrators" of some VDC and inform them by e-Mail about some non-optimum VMs (no VMware tools, wrong NIC ...). This used to work that way:

 

$ORG=$VDC.Org

$ORGADMINROLE=(Get-CIRole -Name "Organization Administrator")

$ORGADMINs=(Get-CIUser -Org $ORG -Role $ORGADMINROLE | sort | Get-Unique)

 

But now in any case $ORGADMINs is empty. If I query an administrator directly, I get an error (though documentation says it should work that way):

 

PowerCLI C:\> Get-CIUser -Org $ORG -Name "myadminname"

 

Name                           External Locked DeployedVMCount StoredVMCount   Org

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

myadminname                    False    False  1               4               managedhosting

 

 

PowerCLI C:\> Get-CIUser -Org $ORG -Name "myadminname" | Get-CIRole

Get-CIRole : 17.09.2018 14:35:27    Get-CIRole        Object reference not set to an instance of an object.

At line:1 char:46

+ Get-CIUser -Org $ORG -Name "myadminname" | Get-CIRole

+                                              ~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-CIRole], VimException

    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.Cloud.Commands.Cmdlets.GetCIRole

 

 

We use vCloud Director 8.20. Any help is really appreciated, since I am quite lost.

 

Regards, Tom.


"Power On and Force Recustomization" PowerCLI

$
0
0

 

 


Hi Guys!

 

 

 

I cannot find any solution for recustomization VM in vCloud 5.5.

 

 

 

The sample of script:

 

       $VM_GL = Get-CIVM -Name VMachine -Org $OrgName -OrgVdc $OrgVdcName -VApp $New_Clone        $GuestCustomization = $VM_GL.ExtensionData.GetGuestCustomizationSection()        $GuestCustomization.Enabled = $true        $GuestCustomization.ResetPasswordRequired = $false        $GuestCustomization.AdminAutoLogonEnabled = $false        $GuestCustomization.AdminAutoLogonCount = 0        $GuestCustomization.CustomizationScript = $CustomizationScript_GL        $GuestCustomization.UpdateServerData()        $VM_GL.ExtensionData.NeedsCustomization = $true        $VM_GL.ExtensionData.UpdateServerData()        Start-CIVM -VM $VM_GL -Confirm:$false

 


In this way only network settings and hostname has changed, but customization script is not running. If i do not start machine in PowerShell and run it in Web-interface trough "Power On and Force Recustomization" the script is running and make changes.

External IP not getting assigned using New-CIvApp and Start-CIvApp

$
0
0

I have created a new vApp with...

Get-CIVAppTemplate -Name $myTemplate -Catalog $catalog  | New-CIVApp -Name $newvapp -Description "This vApp is created from the vApp template named MySourceTemplate." -OrgVdc $myOrgVdc

 

Then I set the vApp network with...

$myVApp = Get-CIVapp -Name $newvapp 

$myOrgNetwork = Get-OrgNetwork -Name 'DEV_TC_TEA_Routed_Network'

Get-CIVAppNetwork -VApp $myVApp -Name 'vAppNet-vAppNet' | Set-CIVAppNetwork -FirewallEnabled:$false -NatEnabled:$true -ParentOrgNetwork $myOrgNetwork

 

Then I start the vApp with...

$myVApp | Start-CIVApp

 

But the External IP (which is configured based on the routed network) is not assigned. Any ideas?

 

I tried using the CustomizeOnInstantiate option as follows...

New-CIVApp -Name $newvapp -Description "This vApp is created from the vApp template named MySourceTemplate." -OrgVdc $myOrgVdc -CustomizeOnInstantiate

 

 

...but I get an error stating CustomizeOnInstantiate is an unknown option

 

New-CIVApp : A parameter cannot be found that matches parameter name

'CustomizeOnInstantiate'.

At D:\apps\vCloud\Scripts\Catalog-Clone-Start_DEV_TC_AUTO.ps1:22 char:186

+ ... gVdc $myOrgVdc -CustomizeOnInstantiate:$true

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

    + CategoryInfo          : InvalidArgument: (:) [New-CIVApp], ParameterBind

   ingException

    + FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.Clou

   d.Commands.Cmdlets.NewCIVApp

Gateway IP sub-allocation --can I list these contents?

$
0
0

All,

Just getting into powercli for vcloud...wondering if there is a command that will list the IP range of all the gateways.  The field I want in the gui is under manage and monitor, cloud resources, external networks, gateway ip sub-allocation tab.  I am looking the range of all IPs I have assigned or perhaps an easy way to export this list in GUI would also work, but haven't found that yet.  I just want to get a handle on what IPs are assigned on the network so I can cross reference what we have available. 

Is this something I can get with the get-externalnetwork cmdlet?

 

Thanks all!!

Issue with Importing VM from vsphere into Vapp

$
0
0

I've the issue with importing vm from vsphere into existing vapp in vcloud director (8.0)

the following message error when i use import-civapp ...


Import-CIVApp, the vSphere server with UUID ...... is not found on this cloud Instance.

 

And yet I am sure that the vCenter I use is good

 

Any Idea ?

 

 

 

 

Code:

Connect-VIserver .... 
Connect-CIServer ... 
$vm=Get-VM test

Get-CIVapp $vappName | Import-CIVApp $vm

Useful Scripts

$
0
0

Being new to PowerCLI cmdlets, I have come to love managing vSphere and vCloud through Powershell scripts.

 

So much that I wanted to share some scripts that I made for daily tasks and encourage others to post some of their favorite scripts.

 

The first (CreateAndStart.ps1) is what I use to test our system's resilience to predicted work loads by making and starting multiple vApps from a given vAppTemplate.

 

The second (Cleanup.ps1) is a script to stop and remove all vApps from a particular organization, cleaning up the mess from the previous script.

 

Both scripts are attached.

 

Hope you guys find these useful!

Help!!required a script to find vCloud Chain Length and Linked Clone Mappings

$
0
0

Hi

 

Can I get help on Vcloud as I didn't find any reference script to find the chain length and what are the linked cloned vm's list in vCloud powercli community.

Here is my requirement,

My vCloud Version: 8.x

In vcloud director, in a particular team or group, let us consider vm1 has been deployed from a base template t1. Vm2 has been cloned from vm1. And this linked clones continued for whatever count it supports. Now I want to find the chain , I.e., a tree that shows something like below-

T1(uuid)

Vm1(uuid)

Vm2(uuid)

  Vm3(uuid)

  ......so on

Note: uuid is nothing but the complete name of the vm in vcloud along with unique identifier.

 

I need something like this..This was taken using lctree but I did notice that LCTREE works upto vCloud Director 5.x versions only. This was not working with vCloud Director 8.x versions.

vCloud Director 5.5 PowerCLI issue with vApp and VM names with +, & and #

$
0
0

Hi all,

 

I get an "ObjectNotFound" error while trying to get vApps and VMs using Get-CIvApp, Get-CIvAppTemplate, or Get-CIVM for vApps and VMs that have +, &, or # in their name.

 

If I rename the vApp or VM and replace these characters, by say, a dash, there's no problem.  Also, if I try to get the vApp for a VM using (get-civm vmname).vapp, it doesn't return anything if the vApp name has +, &, or #. 

 

This is with the latest release of PowerCLI.  Has anyone else seen this, and is there a solution other than us renaming all such vApps and VMs?

 

In the vCloud Director GUI, if you search with these characters, press back arrow and then front arrow, these characters get replaced by Percent Encoding in the search box, e.g. + gets replaced by %2B.

 

Thanks,

Khare

 

E.g. We have a vApp with a '+' in its name: "KTA 7.3.1 + SP", and it has a VM "SharePoint_2013".

 

========================= Before renaming: ============================

 

We see the VM.

PS>get-civm Sharepoint_2013

 

Name Status GuestOSFullName CpuCount MemoryGB

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

SharePoint_2013 Suspended Microsoft Windows Server 2008 R2 (64-... 1        4.000

 

 

We try to get its vApp, but it returns nothing.

 

PS>(get-civm Sharepoint_2013).vapp

 

Try looking for the vApp itself that has a '+' in its name, nothing is returned.

PS>Get-CIVApp "KTA 7.3.1 + SP"

Get-CIVApp : 6/28/2017 7:59:11 AM    Get-CIVApp CIVApp with name 'KTA 7.3.1 + SP' was not found using the specifi

At line:1 char:1

+ Get-CIVApp "KTA 7.3.1 + SP"

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

    + CategoryInfo          : ObjectNotFound: (:) [Get-CIVApp], VimException

    + FullyQualifiedErrorId : Core_OutputHelper_WriteNotFoundError,VMware.VimAutomation.Cloud.Commands.Cmdlets.GetCIVApp

 

========================= After renaming + to - : ============================

 

Look for the vApp, now we find it.

PS>Get-CIVApp "KTA 7.3.1 - SP"

 

Name Enabled InMaintenanceMode    Owner

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

KTA 7.3.1 - SP True False conor.callan

 

 

Look for the VM’s vApp, we find it this way as well.

PS>(get-civm Sharepoint_2013).vapp

 

Name Enabled InMaintenanceMode    Owner

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

KTA 7.3.1 - SP True False conor.callan


Obtain next available external network IP

$
0
0

Hello,

 

I am trying to automate the rollout of nested environments that will require external network connections. I'm looking for a way to determine the next available free IP from a given external networks IP pool. I can get the list of IP's from the pool, the total number used and total number free but have been unable to locate a method to show what's free next.

 

There must be a way to obtain this information as deploying a new Edge on an external network grabs the next available free IP.

 

Anyone have luck with this???

Setting properties of VMs in a vApp

$
0
0

I have a few vApps with 25 VMs each in vCloud Director and would like to set a few properties to on / off with PowerCLI as the gui is a mission. These options include:

 

Set "Enable guest customization" to yes, "Change SID" to no and "Password Reset" to no.

 

I looked at the avaliable command-lets with "get-command -Module vmware.vimautomation.cloud" but I see nothing that allows manipulation of a VMs in a vApp.

 

Would I be able to make these changes with PowerCLI?

 

Thanks!

Remove a CIUser

$
0
0

Greetings everyone!

I already did a brief research on the matter, but failed to find a question, so if this question has already been answered I am sorry for the re-post.

 

My main problem is the following:

I am using PowerCLI version 5.1 release 2 to write scripts and manage my vCloud Director.

I have found a way to add Users into an Organization using the following script:

 

$role = Search-Cloud -QueryType Role -Name "Organization Administrator" | Get-CIView

$org = Get-Org -Name OrgName

$user = New-Object VMware.VimAutomation.Cloud.Views.User

$user.Name ="UserName"

$user.Password = "Password"

$user.Role = $role.href

$user.IsEnabled = $true 

$org.ExtensionData.createUser($user)

 

The user is created using the vCloud Director, inside the required organization.

 

However, I have not yet found a way how to remove a user from the vCloud using the PowerCLI environment.

 

If anyone has any idea on how to do that, please do tell!

 

Thanks a lot in advance!

VMware.VimAutomation.Logging.SoapInterceptor not found

$
0
0

Hi,

 

I'm trying to reboot a VM with PowerCli and then wait until the vm is running. I user this command for this:

 

Get-CIVM -VApp $VCloudVappName -Name $VCloudVmName | Restart-CIVMGuest -Confirm:$false -WhatIf | Wait-Tools

 

This works at least the last command. Wait-Tools every time gets an error

 

Connect-VIServer : Die Datei oder Assembly "VMware.VimAutomation.Logging.SoapInterceptor, Version=1.0.0.646, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
In C:\tmp\reboot.ps1:13 Zeichen:1
+ Connect-VIServer -Server $VCloudHost -Credential $mycredsVCloud
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [Connect-VIServer], FileNotFoundException    + FullyQualifiedErrorId : System.IO.FileNotFoundException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

Wait-Tools : Die Datei oder Assembly "VMware.VimAutomation.Logging.SoapInterceptor, Version=1.0.0.646, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
In C:\tmp\reboot.ps1:15 Zeichen:104
+ ... VCloudVmName | Restart-CIVMGuest -Confirm:$false -WhatIf | Wait-Tools
+                                                                ~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [Wait-Tools], FileNotFoundException    + FullyQualifiedErrorId : System.IO.FileNotFoundException,VMware.VimAutomation.ViCore.Cmdlets.Commands.WaitTools

It's a german error message, but it says something like "File or assembly ... or a dependency not found. The system can not find the specified file.

 

I have PowerCli Version 6.5.1, the latest VIX Tools, and I already restarted my Computer

Can someone help me?

Set Mac address of vCloud VM

$
0
0

Hi

 

For a customer I need to regularly clone a production VM into vCloud for a test-environment. The VM needs to have an identical Mac Address because of some old-fashioned licenses. After cloning, the Is there a way I can easily set the Mac address of the VM to the original Mac Address? Even if the VMs is in the same vCenter environment, but different cluster of ESXi hosts.

 

Gabrie

Viewing all 13334 articles
Browse latest View live


Latest Images

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