We have an agent procedure which runs powershell script. With that script we get size of the user's profile (we use $env:userprofile) in a script but we get that user's profile is " C:\WINDOWS\system32\config\systemprofile". For most of the pc's reporting works, for about 20% of them it doesn't work. They are all win10, the same build etc.

When I execute that PS script on local pc it works properly and we get all information as expected, but via agent procedure it doesn't work for some reason.

I execute script as a user, user is logged in at that time etc..

Has anyone had this behavior?