Store variable value in MOF file from PowerShell DSC

I want to update Anonymous authentication user and password from PowerShell DSC. I wrote below script resource to update that. I have issue where to store the Service account user name and password. I am passing [blockquote]$ServiceCred[/blockquote] variable as argument to the configuration.

Script UpdateServiceUserAnonymous
  {  
    GetScript = {return $null
            }
            SetScript = { 
             $PasswordPointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR[$ServiceCred.Password]
             $getPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto[$PasswordPointer] 
              start-sleep -Seconds 5
              Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Website'`
            -filter "system.webServer/security/authentication/anonymousAuthentication" -name "userName" -value $ServiceCred.UserName
              Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Website'`
             -filter "system.webServer/security/authentication/anonymousAuthentication" -name "password" -value $getPassword
                      }
            TestScript = {
            $PasswordPointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR[$ServiceCred.Password]
            $getPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto[$PasswordPointer]  
            Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Website' -filter "system.webServer/security/authentication/anonymousAuthentication" -Name "userName" | %{$_.Value} | Set-Variable userName
            Get-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'Martini' -filter "system.webServer/security/authentication/anonymousAuthentication" -Name "password" | %{$_.Value} | Set-Variable password     
            if[$userName -eq $ServiceCred.UserName -and $password -eq $getPassword] {$True}
            else {$false}
            }
   } 

I understand that this configuration argument value will be available only in compilation time(creation of MOF file) and not in run time (applying MOF file). Is there any way to store and refer this values from MOF file to script resource?
Could you please help me to solve this issue?

Thanks in advance.

MOF files aren’t scripts; they have no logic, and they’re not “run” like a script. Everything in a MOF is, and must be, a static value. There isn’t a way for them to refer to something else, if that’s what you’re after.

For your example it is probably worth writing a custom resource, which has the ability to use credentials.

The Script resource is a quick way to get functionality of a custom resource without actually creating a custom resource, but you’ve just hit one of the limitations.