Hi Everyone. trying to work with azure automation which seems to run in powershell constrained language mode and just cant get an XML value updated like i can in standard powershell and completely unable to fine any useful examples of XML in that mode or a good list of what the magical 'core types' are.
XML
<ServiceConfiguration serviceName="someservice" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="5" osVersion="*" schemaVersion="2015-04.2.6">
<Certificates>
<Certificate name="somecert" thumbprint="1111111111111111111111111" thumbprintAlgorithm="sha1" />
</Certificates>
</ServiceConfiguration>
Powershell
# because azure automation runs in constrained mode
$ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"
$ExecutionContext.SessionState.LanguageMode = "ConstrainedLanguage"
# read file
[xml]$xml = Get-Content 'c:\temp\example.xml'
[xml]$xml = Get-Content 'c:\temp\example.xml'
# value from file
$xml.ServiceConfiguration.Certificates.Certificate.thumbprint
$xml.ServiceConfiguration.Certificates.Certificate.thumbprint
# update value
$xml.ServiceConfiguration.Certificates.Certificate.thumbprint = '222222222222222222222222222'
$xml.ServiceConfiguration.Certificates.Certificate.thumbprint = '222222222222222222222222222'
# see its been updated
$xml.ServiceConfiguration.Certificates.Certificate.thumbprint
$xml.ServiceConfiguration.Certificates.Certificate.thumbprint
Error i keep getting.
Cannot set property. Property setting is supported only on core types in this language mode.
Anyone know the secret incantation?