Search code examples
powershelliisazure-powershell

How can I change IIS application pool property setProfileEnvironment from Powershell?


How can I set the "setProfileEnvironment" property from Powershell?

The following code is generating error "The property 'setProfileEnvironment' cannot be found on this object. Verify that the property exists and can be set."

$IISServerManager = Get-IISServerManager
$pool = $IISServerManager.ApplicationPools.Add("MyPoolName")
...
$pool.ProcessModel.LoadUserProfile = $true
$pool.ProcessModel.SetProfileEnvironment = $true

Solution

  • @BruceZhang's answer worked, as does this:

    Set-ItemProperty ("IIS:\AppPools\MyAppPoolName") -Name processModel.setProfileEnvironment -value "true"
    

    Just make sure, if you are using the code block from the original post, that you commit the changes so the new application pool exists before calling the above command, using:

    $IISServerManager.CommitChanges()