Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2010 SharePoint 2010将网站字段导出为XML文件_Visual Studio 2010_Powershell_Sharepoint 2010_Stsadm - Fatal编程技术网

Visual studio 2010 SharePoint 2010将网站字段导出为XML文件

Visual studio 2010 SharePoint 2010将网站字段导出为XML文件,visual-studio-2010,powershell,sharepoint-2010,stsadm,Visual Studio 2010,Powershell,Sharepoint 2010,Stsadm,我刚刚开始使用SharePoint 2010(你可以说有点晚了!)我已经通过GUI创建了一个列表,就像我通常使用SharePoint 2007一样。然后,我将使用Gary la pointe stsadm扩展来提取字段XML,并将它们放入VisualStudio中的一个功能中 我想知道这还能做吗!我在2010 stsadm命令中找不到gl Exportsitecolumns命令 是否有powershell替代方案 任何帮助或指导都将不胜感激 干杯 Truez我不知道在powershell中会有这

我刚刚开始使用SharePoint 2010(你可以说有点晚了!)我已经通过GUI创建了一个列表,就像我通常使用SharePoint 2007一样。然后,我将使用Gary la pointe stsadm扩展来提取字段XML,并将它们放入VisualStudio中的一个功能中

我想知道这还能做吗!我在2010 stsadm命令中找不到gl Exportsitecolumns命令

是否有powershell替代方案

任何帮助或指导都将不胜感激

干杯
Truez

我不知道在powershell中会有这样的替代方案。但非常简单的解决方案可以是这段代码:

$w = Get-SPWeb http://localhost/subweb
$w.Fields | select SchemaXml # option 1: prints all xml to console
$w.Fields | select schemaxmlwithresourcetokens # option 2: the same, but with resource tokens
$w.Fields | %{ $_.schemaxml } | out-file c:\temp\fields.xml -encoding unicode #option 3: saves output to text file

powershell中的另一种选择是:Phil Childs

$sourceWeb = Get-SPWeb http://portal
$xmlFilePath = "C:\Install\Script-SiteContentTypes.xml"

#Create Export File
New-Item $xmlFilePath -type file -force

#Export Content Types to XML file
Add-Content $xmlFilePath "<?xml version=`"1.0`" encoding=`"utf-8`"?>"
Add-Content $xmlFilePath "`n<ContentTypes>"
$sourceWeb.ContentTypes | ForEach-Object {
    if ($_.Group -eq "Custom Content Types") {
        Add-Content $xmlFilePath $_.SchemaXml
    }
}
Add-Content $xmlFilePath "</ContentTypes>"

$sourceWeb.Dispose()
$sourceWeb=Get-SPWebhttp://portal
$xmlFilePath=“C:\Install\Script SiteContentTypes.xml”
#创建导出文件
新项$xmlFilePath-类型文件-强制
#将内容类型导出到XML文件
添加内容$xmlFilePath“”
添加内容$xmlFilePath“`n”
$sourceWeb.ContentTypes | ForEach对象{
if($\组-eq“自定义内容类型”){
添加内容$xmlFilePath$\ SchemaXml
}
}
添加内容$xmlFilePath“”
$sourceWeb.Dispose()