locked
Power shell help RRS feed

  • Question

  • am new to power shell please help me to create a power shell code for the below xml file

    <Configuration>
    <SiteUrl>http://...</SiteUrl>
    <lists>
    <List Name="Issues" Versioning="true">
     <columnToAdd ColumnName="% Complete" Type ="Number" ViewName="All Items"/>
     <columnToAdd ColumnName="Actual Work" Type ="Number" ViewName="All Items"/>
    </List>
    <List Name="Risks" Versioning="true">
     <columnToAdd ColumnName="Callback Number" Type ="Single line of text" ViewName="All Items"/>
     <columnToAdd ColumnName="Contact Name" Type ="Single line of text" ViewName="All Items"/>  
    </List>
    </lists>
    <libraries>
    <LibraryName>Meeting Notes</LibraryName>
    <LibraryName>Project Documents</LibraryName>
    </libraries>
    </Configuration>
    Tuesday, April 9, 2013 1:27 PM

Answers

All replies

  • two questions:

    1. what have you got so far?
    2. what is it that you want your script to do to or with this xml file?

    assuming you have nothing and want a script to delete the xml file, I'd suggest you try this:

        remove-item ./myxmflfile.xml


    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

    Tuesday, April 9, 2013 3:05 PM
  • Hi Dunbar,

    In a share point site I want the below operations with the help of power shell code and am taking the site URL and the below fields in the above XML file :

    •  taken two List names:1)Issues.2)Risks for both the lists I want the versioning to be true.
    •  i.e. :List Name="Issues" Versioning="true">
      for the ISSUE list I want to add two column names "% complete" "Actual work", set the type to "Number" and add to "All Items" view.
    • And for RISK list I want to add two column names "Callback Number" "Contact Name" ,set the type to "Number" .

    The Below is the sample code that I tried.

    Param(

      [Parameter(Mandatory=$True,Position=1)]

       [string]$configFile

    )

    [xml]$config = Get-Content $configFile

    $lists=$config.Configuration.lists.List

    $columnToAdd=$config.Configuration.lists.List[0].columnToAdd

    $columnToAdd=$config.Configuration.lists.List[1].columnToAdd

    $siteurl = $config.Configuration.SiteUrl

    $ViewName=$config.Configuration.lists.List[0].columnToAdd[0].ViewName

    $ColumnName=$config.Configuration.lists.List[0].columnToAdd[0].ColumnName

     

    $site = Get-SPSite $siteurl

    $web = $site.AllWebs

    $Lst=$web.lists[$List[0].Name]

    foreach($subsite in $web)

    Please help me to get the code for the problem.

    Thanks 

    Tuesday, April 9, 2013 4:42 PM
  • sorry, but XML and sharepoint are two areas where I lack experience. in addition, I still do not understand what you expect to result from this.

    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

    Tuesday, April 9, 2013 8:40 PM
  • Am new to power shell please help me to write power shell code for the below xml file

     <Configuration>
     <SiteUrl>http://...</SiteUrl>
     <lists>
     <List Name="Issues" Versioning="true">
      <columnToAdd ColumnName="% Complete" Type ="Number" ViewName="All Items"/>
      <columnToAdd ColumnName="Actual Work" Type ="Number" ViewName="All Items"/>
     </List>
     <List Name="Risks" Versioning="true">
      <columnToAdd ColumnName="Callback Number" Type ="Single line of text" ViewName="All Items"/>
      <columnToAdd ColumnName="Contact Name" Type ="Single line of text" ViewName="All Items"/> 
     </List>
     </lists>
     <libraries>
     <LibraryName>Meeting Notes</LibraryName>
     <LibraryName>Project Documents</LibraryName>
     </libraries>
     </Configuration>

     

     


    In a share point site I want the below operations with the help of power shell code and am taking the site URL and the below fields in the above XML file :
    • taken two List names:1)Issues.2)Risks for both the lists I want the versioning to be true.
    • i.e. :List Name="Issues" Versioning="true">
     for the ISSUE list I want to add two column names "% complete" "Actual work", set the type to "Number" and add to "All Items" view.
    •And for RISK list I want to add two column names "Callback Number" "Contact Name" ,set the type to "Number" .

    The Below is the sample code that I tried.


    Param(

      [Parameter(Mandatory=$True,Position=1)]

       [string]$configFile

    )

    [xml]$config = Get-Content $configFile

    $lists=$config.Configuration.lists.List

    $columnToAdd=$config.Configuration.lists.List[0].columnToAdd

    $columnToAdd=$config.Configuration.lists.List[1].columnToAdd

    $siteurl = $config.Configuration.SiteUrl

    $ViewName=$config.Configuration.lists.List[0].columnToAdd[0].ViewName

    $ColumnName=$config.Configuration.lists.List[0].columnToAdd[0].ColumnName

     

    $site = Get-SPSite $siteurl

    $web = $site.AllWebs

    $Lst=$web.lists[$List[0].Name]

    foreach($subsite in $web)

    • Merged by Yan Li_ Friday, April 12, 2013 6:41 AM
    Wednesday, April 10, 2013 3:45 AM
  • Hi,

    If you are looking for powershell methods to work with XML files, then I would like to suggest you refer below articles:

    Use PowerShell to Simplify Access to XML Data

    http://blogs.technet.com/b/heyscriptingguy/archive/2012/09/13/use-powershell-to-simplify-access-to-xml-data.aspx

    The Scripting Wife Learns to Use PowerShell to Work with XML

    http://blogs.technet.com/b/heyscriptingguy/archive/2012/03/25/the-scripting-wife-learns-to-use-powershell-to-work-with-xml.aspx

    Regards,

    Yan Li


    Cataleya Li
    TechNet Community Support

    • Proposed as answer by Yan Li_ Monday, April 15, 2013 2:17 AM
    • Marked as answer by Yan Li_ Tuesday, April 16, 2013 1:45 AM
    Friday, April 12, 2013 5:16 AM