The Measure of a Man (Star Trek: The Next Generation, Season 2, Episode 9)
Commander Bruce Maddox, a cyberneticist, boards the Enterprise under the guise of asking Data a few questions about his creator. It turns out Maddox wants to dismantle Data and upload his memory to the starbase mainframe in order to figure out how to recreate his positronic brain.
Data resigns from Starfleet to avoid being disassembled, at which point Maddox claims he is Starfleet property, not a sentient being who can decline orders. Picard demands a formal hearing to determine whether Data has a soul.
Watch Star Trek: The Next Generation on CBS All-Access.