I am attempting to exclude a few groups in the recent posts indexed by the sidebar. This is what I have got, but it is no longer working (the $ex part is how I am attempting to exclude). Any suggestions are appreciated:

<?php
        $latest = get_posts('numberposts=7');
        $i = 0;
        $ex = "65,86";
        ?>
        <?php foreach ($latest as $latest_post): $i++; ?>
            <li <?php if ($i === 1) echo 'id="most_recent"' ?>><a href="<?php echo get_permalink($latest_post->ID) ?>"><?php echo $latest_post->post_title ?></a></li>
        <?php endforeach ?>
    </ul>

</div>

I'd most likely make use of a custom loop with this. Something similar to the code below should work:

<!--Set up your query here.  In this example we're excluding cats 1, 2, 3 and displaying 5 posts-->
<?php query_posts( 'cat=-1,-2,-3&posts_per_page=5' ); ?>        

<!--Start the loop-->       
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<!--Your HTML and template tags here-->
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>

<?php endwhile; ?>

<?php else: ?>

<!-- Put something here in case there are not recent posts-->

<?php endif; wp_reset_query();?>
<!--Make sure you include the reset query function at the end here if you want other custom loops after this one-->

The advantage of using query posts is you can then use the rest of the parameters available within wordpress

http://codex.wordpress.org/Function_Reference/query_posts#Parameters