import-vappfolder powercli function feedback request

  • David Hovey
  • David Hovey's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
More

a quick function I have thrown together to ease the deployment process of entire folders of OVA/F's. I have tested it with some success on the resent Palo Alto and VMware ICM pods, however I am sure its missing functionality for some use cases and I do not have any comments or what-if compatibility in the function (currently) I'd love to get some feedback or suggestions on the function and will update this post as the function is improved.

function Import-VappFolder{
    Param(
        [Parameter(Mandatory)]
        [string]$SourceFolder
        ,
        [Parameter(Mandatory)]
        [string]$Server
        ,
        [Parameter(Mandatory)]
        [string]$Storage
        ,
        [Parameter(Mandatory=$false)]
        [string]$DestinationFolder
        )

    $vmHost = Get-VMHost -Name $server

    $vmDataStore = Get-Datastore -Name $Storage

    if($DestinationFolder -ne ""){
        $vmFolder= Get-Folder -Name $DestinationFolder
    }
    $SourceOVAs=Get-Childitem -Recurse -filter *.ov* $SourceFolder | where{$_.name -match ".ov[af]"} | foreach-object {
        #InventoryLocation requires powercli 6.5.2+
        if($DestinationFolder -ne ""){
            Import-Vapp -Source $_.fullname -Datastore $vmDataStore -VMHost $vmHost -InventoryLocation $vmFolder -force
        }
        else{
            Import-Vapp -Source $_.fullname -Datastore $vmDataStore -VMHost $vmHost -force
        }
    }
}

as noted in my comment the inventorylocation flag requires powercli 6.5.2 or higher.

#43

Please Log in or Create an account to join the conversation.

Moderators: David HoveyShawn MonsenSuper User