| « Powershell create Scheduled Tasks | Windows PowerShell 2.0 RTM for WinXP/W2k3/W2k8/Vista » |
Dec
28
The only missing "simple" action or method on an array is to retrieve the index number representing a value. That's why I wrote this simple function:
# -----------------------------------------------------
Function IndexOfArray
{
param ([array]$x, [String]$y)
$ItemIndex = 0
If (!($x -contains $y)) {Return ""; Break}
ForEach ($item in $x)
{
If ($y -eq $item) { Return $ItemIndex; Break}
$ItemIndex++
}
}
# -----------------------------------------------------
$arrDTAP = ("D", "T", "A", "P")
$IndexNumber = IndexOfArray $arrDTAP "T"
$IndexNumber
No feedback yet
Comments are closed for this post.