IP pools, creating with PowerCLI

So I was delving into the documentation and others, and I can't understand how the script to create a Pool of IP (with the appropriate settings) for my data using PowerCLI centers.  Someone at - it no picture of it?

A function would be nice if I had the time but the underside is more portable, it is just to change the name of the RODC to yours on the code below:

    $dcSelection = Get-Datacenter MyDatacenter
    $dc = $dcSelection.ExtensionData.MoRef
    $pool = New-Object VMware.Vim.IpPool
    $pool.name = "MyIPPool1"
    $pool.ipv4Config = New-Object VMware.Vim.IpPoolIpPoolConfigInfo
    $pool.ipv4Config.subnetAddress = "192.168.1.0"
    $pool.ipv4Config.netmask = "255.255.255.0"
    $pool.ipv4Config.gateway = "192.168.1.1"
    $pool.ipv4Config.range = "192.168.1.10#1"
    $pool.ipv4Config.dns = New-Object System.String[] (1)
    $pool.ipv4Config.dns[0] = ""
    $pool.ipv4Config.dhcpServerAvailable = $false
    $pool.ipv4Config.ipPoolEnabled = $true
    $pool.ipv6Config = New-Object VMware.Vim.IpPoolIpPoolConfigInfo
    $pool.ipv6Config.subnetAddress = ""
    $pool.ipv6Config.netmask = "ffff:ffff:ffff:ffff:ffff:ffff::"
    $pool.ipv6Config.gateway = ""
    $pool.ipv6Config.dns = New-Object System.String[] (1)
    $pool.ipv6Config.dns[0] = ""
    $pool.ipv6Config.dhcpServerAvailable = $false
    $pool.ipv6Config.ipPoolEnabled = $false
    $pool.dnsDomain = ""
    $pool.dnsSearchPath = ""
    $pool.hostPrefix = ""
    $pool.httpProxy = ""
    $pool.networkAssociation = New-Object VMware.Vim.IpPoolAssociation[] (1)
    $pool.networkAssociation[0] = New-Object VMware.Vim.IpPoolAssociation
    $pool.networkAssociation[0].network = New-Object VMware.Vim.ManagedObjectReference
    $pool.networkAssociation[0].network.type = "DistributedVirtualPortgroup"
    $pool.networkAssociation[0].network.Value = "dvportgroup-178"
    $pool.networkAssociation[0].networkName = ""
    $PoolManager = Get-View -Id 'IpPoolManager-IpPoolManager'
    $PoolManager.CreateIpPool($dc, $pool)

Tags: VMware

Similar Questions

  • Adding a paralytic to the catalog in vCD with PowerCLI

    I would add a paralytic to a catalog via PowerCLI. I see not all the methods under the the VAPP extensiondata that allow this.

    Then I thought that maybe I need to look at the catalog and couldn't find CatalogItems in the GetCIView() of the org and don't know how to edit:

    $ciorg. ExtensionData.Catalogs.CatalogReference [0]. GetCIView(). CatalogItems

    Then I tried to script on the creation of a new catalog... It works but I still don't know to go to add vApps.

    $ciorg = get - org "Org name"

    $cat = New-Object vmware.vimautomation.cloud.views.AdminCatalog
    $cat. Owner = New-Object VMware.VimAutomation.Cloud.Views.Owner
    $cat. Owner.User = New-Object VMware.VimAutomation.Cloud.Views.Reference
    $cat. Owner.User = (get - org). ExtensionData.Users.UserReference [0]
    $cat. CatalogItems = New-Object VMware.VimAutomation.Cloud.Views.CatalogItems
    $cat. IsPublished = $True
    $cat. Name = "catalog name.
    $cat. Description = "created with PowerCLI.
    $ciorg. ExtensionData.CreateCatalog ($cat)

    * Entries in bold must refine. Didn't know how to find a specific user so I used the first input that is mine in the user table.

    So currently, I'm puzzled. Alan, LucD or Jake... Ideas?

    Thank you!

    The ExtensionData and Get-CIView expose the vCloud API REST. The documentation is available here: https://www.vmware.com/support/vcd/doc/rest-api-doc-1.5-html/index.html. What PowerCLI exposes them, however, are slightly different. We will publish a separate documentation to another point that would be more accurate.

    Note the PowerCLI interface exposes to .net is not the same as the c# SDK for vCloud.

    To access the documentation for the 2 operations, you should define the scope of research on all operations and the search for InstantiateVAppTemplate or ComposeVApp, follow the link of type Input to InstantiateVAppTemplateParams/ComposeVAppParams.

    Creating a vApp on a vApp model is done with InstantiateVAppTemplate. ComposeVApp is for the creation of a paralytic from scratch.

    Just an aside: take a look at the CIVApp import and import-CIVAppTemplate, those who are able to "register" a virtual machine of vSphere in vCloud. Maybe it's a quicker way of migration of machines virtual vSphere to vCloud VAPP model that they can do the conversion without facing the virtual machine.

  • Export all the objects with PowerCli

    Hello

    I'm not in VSphere or vmware but a Director of SCOM and I am currently working on a solution to monitor our VCenter with SCOM server. To be able to automatically resolve alerts, I would need to find a way to export a list with all the objects of the VCenter server to create them as instances in SCOM and map the error directly state events to these objects.

    I think that this should be possible with PowerCli so the plan was to have a script export this list frequently and run a discovery of the SCOM Agent Script to automatically create related instances. Does anyone know how this export could be made with PowerCli? Since I'm not in vmware / vsphere and we don't have a test environment, but only the Production System in our office, I am somewhat limited in trying just by the cmdlets to discover this.

    No matter what pointer in the right direction which cmdlets can achieve this is as welcome as script ideas that could help me out here.

    Thanks and greetings

    Marco

    OK, I see.

    When you want to display a map, it is better to load the objects requested in advance and update them regularly.

    Have you ever thought about what you want to see on the map?

    A hierarchy of the sample could be

    vCenter(s)                                     <- in $defaultVIServer after a Connect-VICenter
      datacenter(s)                              <- Get-Datacenter -Server 
       cluster(s)                                   <- Get-Cluster -Server 
          resource pool(s)                     <- Get-Resourcepool -Location (Get-Cluster )
             guest(s)                               <- Get-VM -Location (Get-Resourcepool )
          vmhost(s)                               <- Get-VmHost -Location (Get-Cluster 
             datastores                           <- Get-Datastore -Location (Get-VMHost )
             network
                vswitches                         <- Get-VirtualSwitch -VMHost (Get-VMHost )
                    portgroup(s)                 <- Get-VirtualPortgroup -VMHost (Get-VMHost )
       standalone host(s)
          guest(s)
          datastores
          network
             vswitches
                 portgroup(s)
    

    I added some of the cmdlets that you can use to get items for a specific branch of the hierarchy.

    ____________

    Blog: LucD notes

    Twitter: lucd22

  • Unable to connect to vCD with PowerCLI

    Hi, can you help me with troubleshooting problem with connecting in vCD using PowerCLI.

    When I log in using my system administrator account

    Connect-CIServer vcdCell01 - User "username-password"pass"

    I get:

    Connect-CIServer: 11/30/2015 connect 12:19:21 AM-CIServer the

    Server returned "Unauthorized" with the status of the authorized 401 - no code.

    On line: 1 char: 1

    + Connect CIServer vcdCell01 - User "username-password 'pass' '.

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

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

    + FullyQualifiedErrorId: Cloud_ConnectivityServiceImpl_ConnectCloudServer

    _ConnectError, VMware.VimAutomation.Cloud.Commands.cmdlets.ConnectCIServer

    I can connect to the Web user interface using the same system administrator account.

    The only way I can connect with PowerCLI is when I create the local account in one of the organizations and Add - Org to order

    Connect-CIServer vcdCell01-user "localuser" - password 'localpass' - 'org' Org

    Help, please.

    I used a few tricks of Python to connect to vCD. To connect as a system administrator, I had to use "Administrator@System" as the user.

    Maybe it will work for you if you use '-Org system?

  • Moving a hard drive with PowerCLI

    I have a vm with several discs. I have create a new virtual machine, to attach a disk of the virtual machine first to this hard new using New-disk and passing the path to the vmdk.

    The final bit, that I need is to remove the disc from the first virtual machine so that I can turn on the second. I can't work out how to do this with powerCLI, of course, it is quite easy using the GUI.

    Any ideas?

    Hello, Deanb61-

    Decent docs: Yes, VMware support site has legitimate documentation: https://www.vmware.com/support/developer/PowerCLI/.  From there, you can see the documentation for the desired version of PowerCLI.  Of course, check the latest version the most up-to-date docs/features/etc.  Particular, Get-disk hard Ref is currently at http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.powercli.cmdletref.doc/Get-HardDisk.html.

    You can find the name of the hard disk on the original VM with the first bit below and use that name, then remove the disk said.  Or, the second line of code just relies on the way to the store of data (filename) from the drive and deletes the given virtual machine disk.

    ## get the VM's disks and their names, so as to use its name laterGet-HardDisk -VM myVM | select Name,Filename,CapacityGB
    
    ## or, just get the hard disk with the given filename, and remove itGet-HardDisk -VM myVM | Where-Object {$_.Filename -eq "[myDStore0] myVM/myVM1.vmdk"} | Remove-HardDisk -DeletePermanently:$false
    

    What to do for you?

  • Complete the VI Client with PowerCLI Script idle Sessions

    Hello gurus PowerCLI

    I searched the net for a script PowerCLI that would end all the VI client sessions that have been inactive for x period of time.  I found a post on the forums of VMware (http://communities.vmware.com/message/914858?z=zI0r8n) but had no luck with it.  I also found a script created by A.Mikkelsen, to http://www.amikkelsen.com/?p=384 , but that one does not work either.

    Here's the actual script by A.Mikkelsen that is based on code by LucD in the forum mentioned previously.

    BEGINNING

    ##################################################################################
    # The script terminates all sessions if idle idle user for more than xx #.
    #                             #
    # Created by: Anders Mikkelsen, 2010 #.
    ##################################################################################
    Claire
    # Add - PSSnapin VMware.VimAutomation.Core

    # $server = "vcenter server.
    # $user = "vcenter username.
    # $pwd = "password of vcenter.

    # Add 1 extra hour when, due to the difference of timestamp between MSSQL and Windows.
    # slow down time 5 hours = 360
    # 10 hours slowed = 660
    $intOlderThan = 60

    # Connect-VIServer $server - user $user-password $pwd
    # Connect-VIServer $server

    $svcRef = new-object VMware.Vim.ManagedObjectReference
    $svcRef.Type = 'ServiceInstance.
    $svcRef.Value = 'ServiceInstance.
    $serviceInstance = get-views $svcRef

    $sessMgr = get-view $serviceInstance.Content.sessionManager
    $oldSessions = @)
    {foreach ($sess in $sessMgr.SessionList)}
    If (($sess.)) (LastActiveTime) .addminutes ($intOlderThan) - lt (Get-Date)) {}
    $oldSessions += $sess. Key
    #write "$($sess.)". User name)'
    }
    }

    # Session terminal that are inactive for more than approved ($intOlderThan)
    $sessMgr.TerminateSession ($oldSessions)

    Disconnect-VIServer *-confirm: $false

    END

    The error message I get is:

    BEGINNING

    Exception calling 'TerminateSession' with '1' or the arguments: "it was not correct to specified parameters.

    "

    D:\Scripts\vc_terminate_idle_sessions.ps1:36 char: 26

    + $sessMgr.TerminateSession < < < < ($oldSessions)

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

    + FullyQualifiedErrorId: DotNetMethodException

    END

    I should mention that my knowledge of PowerCLI is almost nothing, so any help in tweaking this script to make it work with PowerCLI 5.1 Release 2 and VC 5 U2 would be much appreciated.

    The error is caused by the fact that you are trying to kill your own session (if it was started long time ago).

    Apparently in vSphere 5. they included a security mechanism integrated to avoid this.

    You can take this by adding a simple test.

    ## max number of idle minutes for sessions to keep$intOlderThan = 60$serviceInstance = Get-View 'ServiceInstance'## get the session manager object$sessMgr = Get-View $serviceInstance.Content.sessionManager## array to hold info about stale sessions$oldSessions = @()foreach ($sess in $sessMgr.SessionList){    if (($sess.LastActiveTime).addminutes($intOlderThan) -lt (Get-Date) -and          $sess.Key -ne $sessMgr.CurrentSession.Key){        $oldSessions += $sess.Key    } ## end if} ## end foreach
    
    ## if there are any old sessions, terminate them; else, just write message to the Warning streamif (($oldSessions | Measure-Object).Count -gt 0) {    ## Terminate sessions than are idle for longer than approved ($intOlderThan)    $sessMgr.TerminateSession($oldSessions)} ## end ifelse {Write-Warning "No sessions that have been idle for more than '$intOlderThan' minutes; no action taken"}
    
  • How to manage the Tags with PowerCli

    Hello

    I'm trying to find examples how to manage Customs 'Tags' in vSphere 5.1. This new feature is only used in the web client.

    I would like to create, delete, and associate tags with PowerCli objects.

    Is someone can tell me the basic commands?

    Thank you.

    Karl


    Currently, there are no PowerCLI cmdlets to manage the tags.

    But take a look at Create/Set TAGs via PowerCLI

  • I need help, how to configure virtual machines with PowerCLI IP addresses

    Hi all

    I open this topic because I really need your help.

    I wrote a script that can automatically create 10 VMs on my ESX Server.

    I run the script with PowerCLI.

    I want now to help script, give the ip on the 10 machines created settings.

    I don't know how, can you enlighten me on this subject?

    Is there a script that can do this?

    Thank you very much.

    Isn't the "0.2 | ForEach-Object {"a loop for? IMHO, it is a loop in the PowerShell way.

  • Removal of pool made with bad credentials

    If I have a pool built with credentials that do not seem to work, how I like another admin delete this pool? I have the VM to deleted vsphere, but need to remove the empty pool. This is the error I get whe I'll remove the bad pool.

    "The view composer URL is not correct. Check the VC configuration settings. »

    I am able to create and delete new basins. But can't erase the old basin.

    All ideas

    That will probably ask you to remove the VMS in the ADAM and composer databases (if you use linked clones).    Here's a knockout that tells of the to do it manually.

    http://KB.VMware.com/kb/1008658

  • While the MBP for repair, I downloaded FCP 10.2.3 to a computer lent. Back on my own machine, FCPro borrowed machine library will not be opened because it was created with a newer version of the CPF App Store not 10.2.3 full download

    While my MacBook Pro for the repair, I downloaded FCPX to a computer lent 10.2.3. Back on my own machine, library of FCPX of the borrowed machine will not open because it was created with a newer version of FCPX. And the App Store won't let me finish a 10.2.3 download because the FCC is already on my computer - and he says that no update is available.

    FWIW - MBP 15 "beginning 2011, running OS 10.11.6 Beta (15G7b)

    Any ideas that can help me to keep the day of the Assembly, I did on the other machine?

    Move the application to the trash and try to download it from the shopping page.

  • Import a CA certificate file created with OpenSSL

    I am trying to import a CA file, I created with the CA.sh of OpenSSL utility. Firefox does not see as valid well: when I try and import the cacert.pem I get the error "is not a certificate authority certificate, so it cannot be imported into the certificate authority list.
    I tried to delete all the text before - START CERTIFICATE - but it does not help.
    What Miss me?

    Maybe try here: http://groups.google.com/group/mozilla.dev.tech.crypto?lnk=

  • 5.5.3 pages does not open files created with pages 5.6.1

    Hello

    I have a problem, one of my computers I have Pages 5.6.1. I have many files created with the most recent version of the Pages 5.6.1.

    The problem is that I can not open files created with Pages 5.6.1 use another computer with Pages 5.6.1.

    These files are not compatible? I get an error or anything like that, they simply do not open (nothing happens).

    Thank you

    This is a known issue. Update both machines to v5.6.1 Pages (providing you have Yosemite 10.10.4 or later). Unfortunately, v5.6.1 Pages can also forget open documents of his own creation.

  • Conversion/appeal of an application created with CVI in Labview

    Hello

    I have a third-party application code created with labwindows CVI (attachment: scissor lift CVI code.rar) which is used for our control of movement of CT scans. I want to serve the Labview 8.6 my main software for data acquisition and software interface for my development. My idea is to create a dll from this CVI code and called the dll with Labview library import function is shared.

    My problem is that I am no expert in CVI programming if anyone can help me how to create a dll from this code? or any other suggestions to implement this conversion?

    Code CVI attached for reference.

    Thank you

    Lojius

    A starting point can be found here

  • How can I remove a control created with NewCtrl?

    I create controls dynamically with NewCtrl(). Now, I need to remove them and create different controls.

    How delete/delete one control that I created with NewCtrl?

    DiscardCtrl (); See the "Programming with controls" section in the help

  • can I open a vi created with labview 2009 on worm Labview 8.5?

    I have a vi created with Labview 2009 and I want to open and run the vi in Labview 8.5.

    It opens to 8.5

    Can I save the vi since 2009 in a format that is compatible with 8.5?

    If you click the file menu in the toolbar of LabVIEW, you should see a "except for the previous version. If your vi does not have all the features that are specific LabVIEW2009, you should be able to save it to 8.5.

    LabVIEW is generally open earlier versions, not the other way around. I say generally because there are a few points that have changed drastically, such that you have to use an intermediate version to make the vi up to a more recent version.

Maybe you are looking for