Kapitany's helpful answer is effective, and mclayton's comment on the question provides additional information, but let me provide systematic background information:
PowerShell's adaptation of the XML DOM surfaces XML child elements and attributes as object properties, in addition to the type-native properties of the .NET types being adapted, [xml]
(System.Xml.XmlDocument
) and System.Xml.XmlElement
.
Because your <WebService>
element is a simple XML element - one that has neither attributes nor child elements - the property referring to it was surfaced as a [string]
value rather than as a System.Xml.XmlElement
instance, so as to make setting and getting mere text content easier.
That is, a property representing a simple XML element:
Only properties adapting complex elements - ones that have at least one attribute or child element - surface as (adapted) XmlElement
instances, and only then can you access type-native properties such as .InnerText
explicitly.
For a comprehensive overview of PowerShell's adaptation of the XML DOM, see this answer.
To illustrate the difference:
# Getting / setting a property representing a SIMPLE element
# returns / updates the element's native .InnerText property value.
# Get: -> 'http://example.com/webapi/'
$xmldata.SystemSettings.Authentication.WebService
# Set
$xmldata.SystemSettings.Authentication.WebService = 'http://example.com/webapi_v2/'
# Get: -> 'http://example.com/webapi/'
$xmldata.SystemSettings.Authentication.Item('WebService').InnerText
# Set
$xmldata.SystemSettings.Authentication.Item('WebService').InnerText = 'http://example.com/webapi_v2/'