param (
    [Parameter(Mandatory = $true)]
    [string]$vmName
)

Set-Location $PSScriptRoot


$VM = Get-VM $vmName -ErrorAction SilentlyContinue -ErrorVariable gVM
if ($VM) {
    $VM.State
} else {
    Write-Error "Failed to get VM and its state`r`nError: $gVM"
    Exit 1
}