Writing a spec script is legally permissible, and is not a violation of copyright.<p><i>Distributing</i> a spec script gets into fair use issues--submitting it to the show producers, or using it a sample to get a screenwriting gig are generally acceptable.  Distributing it online generally crosses the boundary into non-permissible uses. (Meaning that it is an actionable copyright violation which the copyright owners could choose to pursue and would likely prevail in court.)