Automation

 View Only
  • 1.  Detaching baselines at the vcenter server level

    Posted May 08, 2012 03:31 PM

    Hi,

    I'm writing a custom PowerCLI script to remediate an individual cluster. One of the steps I wish to perform before remediating is to ensure that any *existing attached* baselines are detached so that the script doesn't remediate against those but only the one passed as a parameter. The detach process I want to follow is, detach at:

    1) the vcenter server level.

    2) the datacenter level.

    3) the parent folder level.

    4) the cluster itself.

    5) all hosts within the cluster.

    All work fine, except for 1. E.g.

    $vcenterBL = Get-Baseline -Entity "vcenter.domain.com"
    if($vcenterBL -ne $null)
    {
         Write-Output "Removing baselines attached at the vCenter server level."
         Detach-Baseline -Entity "vcenter.domain.com" -Baseline $vcenterBL -Confirm:$false
    }

    However I get the error:

    Get-Baseline : 08/05/2012 16:22:37  Get-Baseline  Could not find InventoryItem with name 'vcenter.domain.com'.
    At line:1 char:13
    + Get-Baseline <<<<  -Entity "vcenter.domain.com"
        + CategoryInfo          : ObjectNotFound: (vcenter.domain.com:String) [Get-Baseline], VimException
        + FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_ObjectNotFound,VMware.VumAutomation.Commands.Get Baseline

    Indeed, Get-Inventory shows no "vcenter.domain.com". How do I detach or attach at this level?

    Thanks for any help! :smileyhappy:



  • 2.  RE: Detaching baselines at the vcenter server level
    Best Answer

    Posted May 08, 2012 03:41 PM

    You could use the hidden folder Datacenters.

    Something like this

    $entity = Get-Folder Datacenters 
    $vcenterBL
    = Get-Baseline -Entity $entity
    if($vcenterBL -ne $null) {      Write-Output "Removing baselines attached at the vCenter server level."
         Detach-Baseline -Entity $entity -Baseline $vcenterBL -Confirm:$false
    }


  • 3.  RE: Detaching baselines at the vcenter server level

    Posted May 08, 2012 03:54 PM

    Woohoo, it works. Thanks!