Hi, I have a powershell script that runs inside of a .Net program that exports certain Document Library files (and the folder structure) into files on the server (where they are then zipped and put on a CD). This script has been working fine until we updated
some of the libraries to allow Link To Document in the library. When we link to a document, that document is not included in the output of this script, but we need it to be. I don't use powershell that often, and I can't figure out why the linked
documents wouldn't be pulled in (wouldn't the item url property that I'm using in the script point to the actual location of the document so that it can be included in the appropriate library?). I'm not sure what I can change in this script
to enable the linked documents in some of the libraries to be included in the export. Thanks for any help/ideas! Gist of the script is listed below:
$eLibraryUrl = [Microsoft.SharePoint.Administration.SPFarm]::Local.Properties.Item("MyLibrary")
$spWeb = Get-SPWeb -Identity $eLibraryUrl
Export-SPWeb $eLibraryUrl -Path "E:\E\siteexport.cab" -IncludeVersions 2 -CompressionSize 1024
[System.Reflection.Assembly]::LoadWithPartialName("System.Xml")
get-childitem *.cab | foreach-object {
expand -r $_.Name -f:* "E:\E"
$manifestXml = get-content ".\manifest.xml"
$nameTable = new-object System.Xml.NameTable
$xnm = new-object System.Xml.XmlNamespaceManager -argumentList $nameTable
$xnm.AddNamespace("sp", "urn:deployment-manifest-schema")
$manifest = new-object System.Xml.XmlDocument
$manifest.LoadXml($manifestXml)
$folders = $manifest.SelectNodes("//sp:Folder", $xnm)
$folders | foreach-object {
try
{
echo "Creating directory " + $_.Url
md $_.Url
$folder = get-item $_.Url
$folder.CreationTime = [System.Xml.XmlConvert]::ToDateTime($_.TimeCreated)
$folder.LastWriteTime = [System.Xml.XmlConvert]::ToDateTime($_.TimeLastModified)
}
catch
{
echo "Unable to create directory: " + $_.Url
}
}
$files = $manifest.SelectNodes("//sp:File[(contains(translate(@Url, 'dDoOcC', 'ddoocc'), '.doc') or contains(translate(@Url, 'pPdDfF', 'ppddff'), '.pdf') or contains(translate(@Url, 'dDoOcCxX', 'ddooccxx'), '.docx'))]", $xnm)
$files | foreach-object {
try
{
echo "moving " + $_.FileValue + " to " + $_.Url
move-item $_.FileValue $_.Url
$ActualFile = get-item $_.Url
$ActualFile.CreationTime = [System.Xml.XmlConvert]::ToDateTime($_.TimeCreated)
$ActualFile.LastWriteTime = [System.Xml.XmlConvert]::ToDateTime($_.TimeLastModified)
}
catch
{
echo "unable to move file " + $_.FileValue + " to " + $_.Url
}
}
}