2016-07-28 56 views
0

我已经问过这个问题前一些日子,但没有人回答,我发现我的问题是什么...MKDIR是缓慢的,这使得我的脚本崩溃

我创建这将是一个SharePoint服务器上某个文件夹用于将文件分类到它们中,如果我启动它,则会抛出并上传错误,因为(当我停止使用断点时),我看到我的mkdir命令没有抛出任何错误消息,但我也没有工作...

编辑:

我改变的mkdir到新建项目-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

究竟是这样的:*“它没有工作”*或*“它确实有效,但它不能通过webclient立即显示”*? –

+0

它不会抛出任何错误,它没有工作,但真正的问题是,我有一个路径,我认为他有一个问题'\\ workspace \ DavWWWRoot \ content \ 00000100 \ Research \ TestOffer \ documents \' –

+0

因为他抛出一个错误的网络路径未找到,需要多年才能打开此路径,所以我认为它很慢 –

回答

1

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

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