A Thurston County judge granted a preliminary injunction Wednesday to block a new law that would have allowed the state to decertify and remove elected sheriffs from office.