doooolaney
Programmer
Hi, I've just joined here because it looks like a good place to troubleshoot PowerShell (which I've just started to learn) and I'll be doing some Android programming at some point so I'm sure I'll be needing all you guys help.
Ok...My problem is that the code below brings about the dreaded cannot index into null array error when using the $ListOfUsers variable.
Does anyone have any ideas how I resolve this or rewrite the code to work better?
Cheers.
NOTE: All variable instances not initialised have been done so in the code elsewhere
Ok...My problem is that the code below brings about the dreaded cannot index into null array error when using the $ListOfUsers variable.
Does anyone have any ideas how I resolve this or rewrite the code to work better?
Cheers.
NOTE: All variable instances not initialised have been done so in the code elsewhere
Code:
# Store the list of users due to expire
$ListOfUsers[0]
$Count = -1
# If the user's account is due or almost due to expire then capture details of account into an array
if (($DaysLeft -eq $NumOfDays) -or ($DaysLeft -le $NumOfDays) -and ($DaysLeft -ge 0) -or ($DaysLeft -le 0)) {
$ListOfUsers[$Count++] = $Users.Name
$ListOfUsers[$Count++] = $Users.Email
$ListOfUsers[$Count++] = $ExpiredDate
$ListOfUsers[$Count++] = $DaysLeft
}