【问题标题】:Mkdir is slow which makes my script crashMkdir 很慢,这使我的脚本崩溃
【发布时间】:2016-12-02 10:12:32
【问题描述】:

几天前我已经问过这个问题,但没有人回答,我发现我的问题是什么......

我正在共享点服务器上创建一些文件夹,用于将文件排序到其中,如果我启动它,它会抛出并上传错误,因为(当我停止使用断点时)我看到我的 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

【问题讨论】:

  • 它是哪一个:“它不起作用”“它确实起作用了,但通过 web 客户端无法立即看到”
  • 它没有抛出任何错误,但真正的问题是我有一个路径,我认为他有一个问题 `\\workspace\DavWWWRoot\content\00000100\Research\ TestOffer\documents`
  • 因为他抛出了一个找不到网络路径的错误,而且我花了好几年才打开这条路径,所以我认为它很慢
  • 访问网络路径前使用test-connection

标签: powershell sharepoint sharepoint-2007 powershell-2.0


【解决方案1】:

您在 SharePoint 中(如果您的标签正确,则为 sharepoint 2007)。所以你不在文件系统中。这就是为什么你有这种使用 webDAV 协议的 URL (\workspace\DavWWWRoot........)。

要与 SharePoint 交互,您需要开发一个自定义 .exe(如果您使用的是 2007 版)并使用 SharePoint 对象模型(适用于 2007 版)。您不能在 SharePoint 2007 中使用 PowerShell(或在脚本中加载 Microsoft.SharePoint.dll 并使用对象模型)。

【讨论】:

    猜你喜欢
    • 2019-01-13
    • 1970-01-01
    • 1970-01-01
    • 2022-06-21
    • 1970-01-01
    • 2013-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多