Share via

Powershell script for Blocking file access - Intune

Sandeep K 0 Reputation points
2025-10-03T10:56:10.21+00:00

Hi,

I have a requirement to restrict users in my organization so that they can save their data only in the Desktop, Downloads, and Documents folders. Additionally, they should have read-only access to all other folders and drives in their systemNew Powershell--.txt.

I tested a command locally, and it worked as expected. However, when deploying it through Intune, I encountered an error. I also checked with the Microsoft team, but they were unable to assist in resolving this issue.

Microsoft Security | Intune | Configuration

1 answer

Sort by: Most helpful
  1. Pavel yannara Mirochnitchenko 13,456 Reputation points MVP
    2026-01-13T09:43:27.1066667+00:00

    If a script is user-based, it must be run as local user. If script is system based, it must be run as a system context in Intune. In system context, one issue you hit is %userprofile%, if your script contains userprofile variables.

    You also can add logging in Powershell script and later investigate the log file for errors.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.