I have a Powershell function where I am trying to declare some parameter $vipstatus, I mean when I try to execute the function with that parameter I want to see only the result stored in $vipstatus.
But when I try to execute that it's just listing out the entire output instead of the data stored in $vipstatus
function Get-NSVIPStatus
{
param(
#[parameter(Mandatory=$false)]
#[string]$vipstatus
)
$Components = @("virtualserver")
$VIPstatus = New-Object System.Collections.ArrayList($null)
foreach ($component in $Components)
{
$Metrics = Invoke-RestMethod "https://graphvip100.com/metrics/find?query=metrics.winops.netscalers.components.nsexsre*.$component.*.2m.status" -ErrorAction Stop
$Raw = foreach ($metric in $Metrics)
{
Invoke-RestMethod "https://graphvip100.com/render?target=$($metric.id)&from=-10min&format=csv" -ErrorAction Stop
}
$Data = $Raw | ConvertFrom-Csv -Header "Metric","Time","Value" | Where-Object { -not [string]::IsNullOrEmpty($_.Value) } | Group-Object -Property Metric
foreach ($group in $Data)
{
$NetscalerName = $group.Name.Split(".")[4]
$Componentname = $group.name.split(".")[5]
$Name = $group.Name.Split(".")[6]
If (($group.Group[-1].Value -eq "0.0") -and ($group.Group[-2].Value -eq "0.0") -and ($name -notmatch $exclusionpattern) -and ($netscalername -notmatch $netscalerexclusion))
{
$vipdown = [PSCustomObject]@{
NetscalerName = $NetscalerName
Componentname = $Componentname
Name = $Name
}
foreach ($vip in $vipdown)
{
$null = $VIPstatus.Add($vipdown)
write-warning "$vipdown is down"
}
$failures = $true
}
ElseIf (($group.Group[-1].Value -eq "1.0") -and ($group.Group[-2].Value -eq "1.0") -and ($name -notmatch $exclusionpattern) -and ($netscalername -notmatch $netscalerexclusion))
{
Write-Verbose "$NetscalerName $Componentname $Name is UP" -Verbose
}
ElseIf (($group.Group[-1].Value -eq "2.0") -and ($group.Group[-2].Value -eq "2.0") -and ($name -notmatch $exclusionpattern) -and ($netscalername -notmatch $netscalerexclusion))
{
Write-Verbose "$NetscalerName $Componentname $Name is OUT OF SERVICE" -Verbose
}
}
}
So can anyone help me with what am I missing?
param( #[parameter(Mandatory=$false)] #[string]$vipstatus )
I want the output to be when executed "Get-NSVIPStatus $vipstatus" - 1,2,3
but it is listing out the entire scripts output