Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

how to update XML value in powershell constrained mode.

$
0
0

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"
# read file
[xml]$xml = Get-Content 'c:\temp\example.xml'
# value from file
$xml.ServiceConfiguration.Certificates.Certificate.thumbprint
# update value
$xml.ServiceConfiguration.Certificates.Certificate.thumbprint = '222222222222222222222222222'
# see its been updated
$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?


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>