I have a script where I am trying to get the status of the VIP and services and it returns the value as up, down, out of service as in the screenshot, but I want help with the script to be updated as, if the status is "down" to return value as 0, and if "up" as 1, and if "out of service" as 2.

<#
.Synopsis
This script will obtain status od vip's and services from exsre owned netscalers and send to graphite
#>
$Modules = @(
"SecretServer"
"Netscaler"
"automation"
)
foreach ($Module in $Modules)
{
if (-not(Get-Module $Module))
{
Import-AHModule $Module
}
}
#Obtaining Credentials from Secret server
Write-verbose "$(Get-date): Creating Secret Server Login"
$SecurePassword = ConvertTo-SecureString $env:WinPassword -AsPlainText -Force -ErrorAction Stop
$SSCred = New-Object System.Management.Automation.PSCredential ($env:WinUserName,$SecurePassword) -ErrorAction Stop
$NScred = Get-SecretServerCredential -SamAccountName "nsex" -OperatorCredentials $SSCred -ErrorAction Stop -Verbose:$false
$Netscalers = Get-NSExsrePrimary | select-object -ExpandProperty DNSName
$RunDate = Get-Date
Foreach ($Netscaler in $Netscalers)
{
$null = Connect-NetScaler -hostname $Netscaler -Credential $NSCred
$VIPs = Get-NSStat -type lbvserver
$services = Get-NSStat -type service
Foreach ($vip in $vips){
#VIP status
$VIP | Select-Object @{Name="Name";e={"metrics.winops.vip.$($vip.name).status.2m.vipstate"}},
@{Name="Value";Expression={$_.state}},
@{Name="Date";Expression={$RunDate}}
Foreach ($service in $services){
# service status
$Service | Select-Object @{Name="Name";e={"metrics.winops.service.$($service.name).status.2m.servicestate"}},
@{Name="Value";Expression={$_.state}},
@{Name="Date";Expression={$RunDate}}
}
}
}