r/PowerShell • u/Johnnybegood77 • Dec 28 '25
How to hide a SharePoint folder/Excel file using PowerShell without breaking permissions?
Hello, I'm a novice to SharePoint, and I want to hide a folder/file without breaking permissions.
Here's my situation, I have 6 users that regularly use our main shared Excel file for orders in the desktop Excel app for a business. And then I have 3 users that use power queries to pull data (their orders) into their own Excel file and we don't want them to access the main shared Excel file. I was told that I can't break permissions with the 3 users from the main Excel file because the power queries require access to the main file. I was also told that I could use PowerShell to hide a folder/file. But it appears that was available in classic SharePoint and not the modern SharePoint.
My hope is to have all the main files on Document SharePoint site and then create a SharePoint site for only the 6 users that contain a link back to the main Excel file. And then I'll create a SharePoint site for each of the 3 users but then somehow hide the main Excel from them without breaking permissions. Can anyone offer any help with this or an alternative to what I'm trying to accomplish?
2
u/Zozorak Dec 28 '25
Are you not able to set the power queries to run a Under a service account and then remove permisisons from the main files?
Thats probably where I would start as itll be cleanest. Other methods will start getting messy quickly as from my knowledge theres no way to hide a folder from a user without revoking permissions.
13
u/Owlstorm Dec 28 '25
The root cause of your problem sounds like trying to use excel as a database and a form and a report.
It doesn't support row level security, so you could move subsets of the data around on a schedule or load into a data warehouse or rearchitect the layers more.
7
u/Dragennd1 Dec 28 '25
Show us what code you've got and we'll be happy to help troubleshoot and answer any questions thereof.
This is not the place to ask for free code with no effort on your part.
1
u/matalis Dec 29 '25
You don't need a whole new SharePoint site you can just create a different document library or put some files in a folder and break permissions on the folder.
If I had to do this I would go the separate document library route or make a SharePoint table or do what other people have suggested and don't use a spreadsheet.