Where is $($env:UserProfile) is located for LCM

With default configuration of LCM it seems to have inconsistent execution account. For [Script] resource it resolves to C:\Windows\system32\config\systemprofile while [File] resource is resolving to c:\users\client
Is File resource actually being called as “client” user or how do find out where location of UserProfile for LCM is? I need to know this location since I need to create “.docker” subfolder there and put some config files there.

It’s going to depend, given that the LCM runs as System. The File resource in particular, being a binary module, is a little odd in a lot of ways. The LCM doesn’t have a user profile and it doesn’t run in a user’s context. Individual resources, if provided with an alternate credential, would run in that user’s context and normally with that user’s profile.

My file resource writes to Destinationpath = “$($env:UserProfile).docker\key.pem” which resolves to c:\users\client for some reason. LCM is in default config and [File] is not using any alternative RunAs setting.

        File ClientKey{
            Destinationpath = "$($env:UserProfile)\.docker\key.pem"
            Contents        = $clientKey
            Force           = $true
        }

Yyyyyyeah, but $env:userprofile, used in that context, would normally resolve when you run the script and create a MOF. What’s in the MOF?

Oh, I see. I can not see MOF really since AzureAutomation compiles it and then client pulls it from Azure pull server. So this resolution actually baked into MOF as opposed to be resolved when executed on client?

Yeah, basically just like any script. MOFs are static - they can’t contain variables, except in a [Script] resource, obviously.