Automation

 View Only
  • 1.  How to check, if an folder exists?

    Posted Jan 09, 2015 07:49 PM

    Hi all,

    is it possible to check, if a folder ( type = VM ) exists in the Vcenter? How?

    Thanks in advance

    Chakoe



  • 2.  RE: How to check, if an folder exists?

    Posted Jan 09, 2015 08:58 PM

    #change here foldername to check

    $foldername = "test"

    $data = get-folder -Type VM | Where-Object {$_.name -eq $foldername}

    if ($data -eq $null) {

        Write-Host "$foldername Folder doesn't exist" -BackgroundColor Red

    }

    else {

        Write-Host "$foldername Folder exists" -BackgroundColor DarkGreen

    }

    for complete report just use command

    Get-Folder