2016-07-28 96 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,並使用對象模型)。