I am trying to hide certain users from being searched for in SharePoint.
I have found the solution here: Show/ Hide and Change User Profile Properties
However, when I run the second command I get the following error:
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.Sign up to join this community
Ensure you have proper rights to run these command. Refer to this article.
Let us know if it helped.
Following the code that you linked to will only hide certain profile properties (first name, last name, email, phone number, etc). It will not hide the actual profiles themselves. However, it looks as if you User Profile Service is either turned off or you do not have access to it. Make sure that you have access to the service. Also, make sure the User Profile Service and Synchronization Service are both running.
It looks like you're still trying to find an answer to your earlier question SharePoint - Hide Irrelevant Users from Search check out my answer and make sure you really need to be editing the UPS.
If it really is the UPS Service Application you're interested in then the UPS Guide on Harbar.net really helped me out (although James Grizzles answer looks to have links to all the information you need).