if the purpose of this script is to close "ALL" opened alerts, the first line should be:
$alerts = get-alert |where-object {$_.ResolutionState -ne 255}