Providers: Scope of Variable Requiring @resource[]

asked 2017-05-15 01:21:06 -0500

ross.murray gravatar image

updated 2017-05-15 01:21:29 -0500

I am trying to set the following variable in my powershell provider for IIS.

      $identityType_alias =                        
            case @resource[:identitytype] 
            when 0, :LocalSystem then 0 
            when 1, :LocalService then 1 
            when 2, :NetworkService then 2 
            when 3, :SpecificUser then 3 
            when 4, :ApplicationPoolIdentity then 4

The trouble that I am experiencing is where to initialize it. If i set it at the start along with all other top-scope variables, @resource doesn't exist yet and it falls on it's face. I have temporarily just defined it each time I call on it but I know there is a better way to do this and the reproduction of code unnecessarily bothers me.

Specifically, this variable is used within the Create and Flush methods so it needs a scope appropriate to both of those.

edit retag flag offensive close merge delete