The NSW Police Force illegally hacked the private Facebook account of a Sydney man in a move branded a reprehensible and "criminal offence" by a magistrate.

After four months of illegal police surveillance on a closed Facebook page, Rhys Liam Halvey was arrested and charged with three counts of using a carriage service to offend police and a further three counts of publishing an indecent article.

One of the offending posts, featuring pop star Miley Cyrus and a NSW officer, which was found by police during unlawful monitoring of a private Facebook page.

The surveillance tactics were later supported in court by one of the highest ranking police officers in the state.

The "indecent" posts included a raunchy image of the American pop star Miley Cyrus that had been superimposed on a photograph of a serving officer. After Sydney magistrate Roger Brown warned that a "criminal offence" had been committed by the "unauthorised access", a senior member of the NSW Police hierarchy attempted to intervene with two sworn affidavits "supportive" of the actions.