New Zealand secured their second consecutive victory, defeating Pakistan by five wickets.