In Sharepoint there are many OOB list with a field "Xml". For example, by running this:

$url = http://sharepoint.domain.com
 $site = Get-SPSite $url
 $site.rootweb.lists["User Information List"].items[0].xml

I can get the first record's XML field content, which similar to below:

<z:row xmlns:z='#RowsetSchema' ows_Content
                                     322F4F' ows_Title='Welcome to my blog!' 
                                     ows_Body='&lt;div class=&quot;ExternalClas
                                     ;&lt;p&gt;This is where I&#39;ll be 
                                     sharing my thoughts on topics that matter 
                                     to me. Who knows... I might even share 
                                     pictures, videos and links to other 
                                     interesting stuff.&lt;/p&gt;&lt;p&gt;If I 
                                     catch your interest, let me hear from 
                                     ows_NumComments='0' ows_PostCategory='' 
                                     ows_PublishedDate='2014-02-05 00:31:41' 
                                     ows_RatedBy='' ows_LikedBy='' ows_ID='1' 
                                     ows_Modified='2014-02-04 20:31:41' 
                                     ows_Created='2014-02-04 20:31:41' 
                                     ows_Author='1073741823;#System Account' 
                                     ows_Editor='1073741823;#System Account' 

My question is : 1. What kind of XML is it? Do it has a format name and suggested accessing method? 2. Can I access the value "ows_Author" by powershell?


The XML represents the inherent configuration of a particular list item.

Generally you wouldn't want to access the values by reading/parsing the XML directly, but rather using the wrapper object.

You can access any of those fields using the "array" accessor for the wrapper field value object.

Example: http://www.robertkuzma.com/2012/09/get-items-from-sharepoint-list-using-powershell-script/

  • Thank you! I get what I need. But I am not fully understand the syntax. I can get the author value by $_['author'] or $_['ows_author'] but not $_['ows_aut']. Why is it? Any reference for this "wrapper" method? Thanks. – Mark L May 2 '14 at 5:47
  • When you access $site.rootweb.lists["User Information List"].items[0] you get a SPListItem which has the Item property which you can use as $_['fieldname'] to get a fields value from Title, InternalName or StaticName of the field – Per Jakobsen May 2 '14 at 7:53
  • How can I find out the Title, InternalName or StaticName of the field? – Mark L May 2 '14 at 8:01
  • Title is the fieldname shown in the UI. InternalName is the name after ows_ in the XML. StaticName is the same as InternalName unless it's changed by code. $site.rootweb.lists["User Information List"].Fields will give all the fields with this as attributes. – Per Jakobsen May 2 '14 at 8:07
  • For any OOB field you can do a quick google search to find that the internal field name is. You can even spot this by using Server Explorer in Visual Studio, and watching the properties window to find the static/internal field name, or any other field. – Amadeo Gallardo May 3 '14 at 6:44

As @Amadeo answers you should use SPListItem.Item aka. "array" property to get fieldvalues.

But in general if you want to access XML values in PowerShell you just have to cast the string to xml then you can just dot your way through elements and attributes like this:

$url = http://sharepoint.domain.com
$site = Get-SPWeb $url
$xml = [xml]$site.lists["User Information List"].items[0].xml

BTW If you need to access the SPWeb at an URL just use Get-SPWeb instead of Get-SPSite and RootWeb

To get the Id of the User as requested in the comment use something like:

$url = http://sharepoint.domain.com
$web = Get-SPWeb $url
$list = $web.Lists["User Information List"]
$item = $list.Items[0]
$author = New-Object -Type 'Microsoft.SharePoint.SPFieldUserValue' -ArgumentList ($web ,$item["Author"])
  • Actually I want to get the member ID which match with the ID returned by Get-SPUser. When I call $_['Member'] it returns a string like "33;#Peter Morris". Can I get "33" directly? – Mark L May 2 '14 at 8:26
  • See addition to answer – Per Jakobsen May 2 '14 at 15:22
  • Thanks I can get the Author ID. However a member's ID may not be the Author ID (e.g. the administrator add the member to site, the author will be the admin) – Mark L May 12 '14 at 5:47
  • Oh I get get the member id by using ArgumentList ($web,$_["ows_Member"]). Thank you! – Mark L May 12 '14 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.