我几天前已经问过这个问题,但是没有人回答,我发现了我的问题......
我在sharepoint服务器上创建一个文件夹,用于将文件排序到它们中,如果我启动它会抛出并上传错误,因为(当我停止使用断点时)我看到我的mkdir命令没有抛出任何错误信息,但我也没有工作......
修改
我将mkdir更改为New-Item -ItemTyoe目录,因为我觉得效果更好!
try {
#local file -> called "temporary" which will be created to down- & upload files (without this one the script won't work!!!)
New-Item -ItemType directory -Path $temp_local_file #it will be created on the paritition you entered at the top pf the program
#online files -> those files are created to have the same structure as in the template directory
New-Item -ItemType directory -Path $main_folder
New-Item -ItemType directory -Path $offer_folder
New-Item -ItemType directory -Path $delivery_folder
New-Item -ItemType directory -Path $order_folder
New-Item -ItemType directory -Path $review01_folder
} catch {
Write-Host -f Red "Folder konnten nicht erstellt werden!"
}
这是上传:
try {
$webclient.DownloadFile($reviewcomments, $review_download)
$webclient.DownloadFile($internal_project, $internal_project_download)
$webclient.DownloadFile($classification_document, $classification_download)
if($AVBInbox.Text -eq $AVB_languages[1]) {
$webclient.DownloadFile($AVB_en, $AVB_en_download)
Write-Host -f Green "Succesfully downloaded the english AVB"
}
elseif($AVBInbox.Text -eq $AVB_languages[0]) {
$webclient.DownloadFile($AVB_de, $AVB_de_download)
Write-Host -f Green "Succesfully downloaded the german AVB"
} else {
Show-MessageBox -Type Error -Message "An Error happened during the download of the AVB!"
}
} catch {
Write-Host -f Red "File Download failed, please retry!"
Show-MessageBox -Type Error -Message "Download failed please retry!"
}
如果有人有建议我会感谢他或她:D
答案 0 :(得分:1)
您在SharePoint中,(如果您的标记正确,则为sharepoint 2007)。所以你不在文件系统中。这就是为什么你有这种URL(\ workspace \ DavWWWRoot ........)它使用webDAV协议。
要与SharePoint交互,您需要创建自定义.exe(如果您在2007年)并使用SharePoint对象模型(2007年)。您不能在SharePoint 2007中使用PowerShell(或在您的脚本中加载Microsoft.SharePoint.dll,并使用对象模型)。