2014-12-05 24 views
0

我正在寫一個PowerShell腳本來「編譯」一堆文件到一個文件夾,所以我可以壓縮它,然後分發它。該腳本將從各種特別指定的目錄中提取,因此我不必通過它們進行搜索和啄食,並且可能會遺漏文檔和某些修訂。複製項失敗,沒有錯誤,我敢肯定這是簡單的,但我看不到它

我正在堵塞,它正在工作,並在我的過程中的某個時刻,一些停止。我無法弄清楚改變了什麼,或者如果我達到了極限,或者發生了什麼,因爲這是我的第一個使用PowerShell的腳本。我認爲我忽略了一些非常基本的東西或者造成了根本性的錯誤。直到我的錯誤,或者我碰到的限制,腳本運行良好,這些文件被複制。這些文檔大多是PDF文件,一些文檔文檔,我認爲這裏有一個或兩個電子表格。

在管線176完成:

#to Windows Authentication to Fusion RV 
Copy-item -Path $FSG\$SW\0.RoomView.Notes\"windows auth"\*.* -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Windows Authentication to Fusion RV" 

腳本停止複印文件,我想不通爲什麼。我希望你們&加爾可以幫助我。我谷歌搜索& DuckDuckGo'd,直到我找到了複製品的各種先進功能,我不認爲我需要任何這些。我在腳本中創建目錄,因此我不需要測試它們是否在那裏,並且我知道源目錄中會有文件,這就是它們爲什麼是源目錄的原因。

我在某個地方犯了一個根本的錯誤,還是我碰到了一些我不知道的限制?我不想複製超過255個字符的文件。在最後一個文件夾中最長的是192.

該腳本仍在前進176行;我在線路188

#to RoomView Connected Displays 
Copy-item -Path $FSG\$HW\"RoomView Connected Displays.Packet"\*.*  -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"RoomView Connected Displays" 

其中的PowerShell爲具有讀/訪問文件的一個問題得到一個錯誤,所以我刪除從該目錄中的目錄和任何文件被複制。

我開發的Windows 7專業版64似乎是ISE V1.0

我碰到這個線程就有關添加記錄語句位: Powershell Copy-Item caching ,但我不知道如何整合這爲了這。

這裏是整個腳本:

# Prompts for quick or full compile 

# quick compile does not include the web help, because it takes a while to copy a few thousand files 

# sample code for this prompt from http://technet.microsoft.com/en-us/library/ff730939.aspx 

[bool]$quickCompile=$true 


$title = "Quick compile?" 
$message = "Do you want to include the web help files in this compile?" 

$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", ` 
    "Copies the web help files." 

$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", ` 
    "Does not copy the web help files." 

$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no) 

$result = $host.ui.PromptForChoice($title, $message, $options, 1) 


#switch ($result) 
# { 
#  0 {"You selected Yes." $quickCompile=false } 
#  1 {"You selected No." $quickCompile=true} 
# } 

if(!$result){ 
    $quickCompile=$false 
} 







# Compiles the Fusion packet for distribution 

############################### 
###########Variables########### 
############################### 

#folder structure 
$FSG = "F:\FSG" 
$containerFolder = "Packet.0" 
#Fusion for IT and AV Professionals 
$rootFolder  = "Fusion for IT and AV pros $(Get-Date -format 「MM-dd-yyyy」)" 
$subRoot1  = "Fusion Server" 
$subRoot2  = "Scheduling Enhancement and Panels" 
$subRoot2sub1 = "Scheduling Panels" 
$subRoot3  = "SQL Server" 

#source folders 
$HW  = "0.Hardware" 
$3SMDoc = "0.Hardware\TPMC-3SM.Documentation" 
$4SMDoc = "0.Hardware\TPMC-4SM.Documentation" 
$4SMDDoc = "0.Hardware\TPMC-4SM-FD.Documentation" 
$730Doc = "0.Hardware\TSW-730.Documentation" 
$730OLH = "0.Hardware\TSW-730.OLH" 
$CENRVS = "0.Hardware\CEN-RVS.Notes" 

$ProjMgmt = "0.Project Management" 

$SW   = "0.Software" 
$RVLicensing = "0.Software\0.RoomView.License" 
$RVNotes  = "0.Software\0.RoomView.Notes" 
$SQLLicensing = "0.Software\database.SQL.Licensing" 
$SQLNotes  = "0.Software\database.SQL.Notes" 
$FRVMarketing = "0.Software\Fusion RV.Marketing" 
$FRVNetworking = "0.Software\Fusion RV.Networking" 
$FRVNotes  = "0.Software\Fusion RV.Notes" 


############################### 
#create the directory structure 
############################### 

md -Path $FSG\$containerFolder -Name $rootFolder 

cd $FSG\$containerFolder\$rootFolder 
md "eControl and xPanels" 
md "Fusion Server" #$subRoot1 
md "Getting Started as a User" 
md "Project Management" 
md "RoomView Connected Displays" 
md "Scheduling Enhancement and Panels" #$subRoot2 
md "SQL Server" #$subRoot3 

cd $FSG\$containerFolder\$rootFolder\$subRoot1 
md "CEN-RVS" 
md "Fusion RV Web Help" 
md "Licensing Information" 
md "Networking" 
md "Official Documentation" 
md "Prerequisites, including powerShell script" 
md "Product Info" 
md "Requirements, Architechture, and Design" 
md "Tech Info" 
md "Windows Authentication to Fusion RV" 

cd $FSG\$containerFolder\$rootFolder\$subRoot2 
md "Outlook Add-in" 
md "Scheduling Panels" #$subRoot2sub1 

cd $FSG\$containerFolder\$rootFolder\$subRoot2\$subRoot2sub1 
md "TPMC-3SM" 
md "TPMC-4SM" 
md "TPMC-4SM-FD" 
md "TSW-730" 

cd $FSG\$containerFolder\$rootFolder\$subRoot3 
md "Multi-database model only" 
md "SQL Licensing" 

cd $FSG\$containerFolder 
#reset current folder 


############################### 
#copy the files 
############################### 

##### NOTE: ` is the escape character used below and from the same key as the ~, right next to 1 on a standard QWERTY keyboard. ` and ' are different. ' is a single quote 

#Copy-Item -Path C:\fso\20110314.log -Destination c:\fsox\mylog.log 

#To the root 
Copy-item -Path $FSG\$ProjMgmt\starter\"Fusion Support Group Contact info*.pdf"    -Destination $FSG\$containerFolder\$rootFolder 
Copy-item -Path $FSG\$containerFolder\"Fusion for IT and AV professionals release notes.txt" -Destination $FSG\$containerFolder\$rootFolder 

#to eControl and xPanels 
Copy-item -Path $FSG\$SW\xpanel.Notes\starter\*.*           -Destination $FSG\$containerFolder\$rootFolder\"eControl and xPanels" 

#to Fusion Server 
Copy-item -Path $FSG\$SW\0.RoomView.Notes\starter\'``[RoomView``] Versions explained*.pdf' -Destination $FSG\$containerFolder\$rootFolder\"Fusion Server" 

#to Fusion Server\CEN-RVS 
Copy-item -Path $FSG\0.Hardware\"CEN-RVS.Notes"\starter\*.*           -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"CEN-RVS" 

#Copy the web help 
if(!$quickCompile){ 
    Copy-item -Path $FSG\$SW\"Fusion RV.Web Help"\starter\*.* -recurse      -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Fusion RV Web Help" 
} 

#to Fusion Server\License 
Copy-item -Path $FSG\$SW\0.RoomView.License\starter\*.*          -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Licensing Information" 

#to Fusion Server\Networking 
Copy-item -Path $FSG\$SW\"Fusion RV.Networking"\starter\*.*          -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\Networking 
Copy-item -Path $FSG\$SW\0.RoomView.Notes\networking\*.*          -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\Networking 
Copy-item -Path $FSG\$SW\0.Crestron.documentation\starter\"rg_ip_considerations_guide.pdf"  -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\Networking 

#to Fusion Server\Official Documentation 
Copy-item -Path $FSG\$SW\"Fusion RV.Documentation"\starter\* -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Official Documentation" 

#to Fusion Server\"Prerequisites, including powerShell script" 
Copy-item -Path $FSG\$SW\"Fusion RV.Documentation"\starter\"The order to install the requirements and the softwares.txt" -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Prerequisites, including powerShell script" 
Copy-item -Path $FSG\$FRVNotes\prereqs\*                     -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Prerequisites, including powerShell script" 

#to Fusion Server\"Product Info" 
Copy-item -Path $FSG\$SW\0.RoomView.Notes\product\*.*          -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Product Info" 
Copy-item -Path $FSG\$SW\"Fusion RV.Marketing"\starter\*.*         -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Product Info" 
Copy-item -Path $FSG\$SW\"Fusion RV.Documentation"\starter\'``[Fusion``] Spec sheet.pdf'  -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Product Info" 
Copy-item -Path $FSG\$SW\"Fusion RV.API.Notes"\starter\*.*           -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Product Info" 

#to Requirements, Architechture, and Design 
Copy-item -Path $FSG\$SW\"Fusion RV.Notes"\"requirements and design"\*.* -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Requirements, Architechture, and Design" 

#to Tech Info 
Copy-item -Path $FSG\$SW\"Fusion RV.Notes"\"tech info"\*.* -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Tech Info" 
Copy-item -Path $FSG\$SW\0.RoomView.Notes\"tech info"\*.* -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Tech Info" 

#to Windows Authentication to Fusion RV 
Copy-item -Path $FSG\$SW\0.RoomView.Notes\"windows auth"\*.* -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Windows Authentication to Fusion RV" 

#to Getting Started as a User 
Copy-item -Path $FSG\$SW\"Fusion RV.User guides"\starter\*.* -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Getting Started as a User" 

Copy-item -Path $FSG\$SW\"Fusion RV.Notes"\user\*.*   -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Getting Started as a User" 
Copy-item -Path $FSG\$SW\0.RoomView.License\starter\*.*  -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Getting Started as a User" 

#to Project Management 
Copy-item -Path $FSG\$ProjMgmt\starter\*.*     -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"Project Management" 

#to RoomView Connected Displays 
Copy-item -Path $FSG\$HW\"RoomView Connected Displays.Packet"\*.*  -Destination $FSG\$containerFolder\$rootFolder\$subRoot1\"RoomView Connected Displays" 
+0

您能告訴我們具體的錯誤嗎?另外,雖然可以自己找到這些代碼,但是您能指出代碼中的代碼行嗎?這樣我們就不必擔心猜錯了嗎?其中一些將進入相同的目錄。文件名可以相同嗎?這不會停止腳本,但'-Force'可能有助於阻止這些腳本。 – Matt 2014-12-05 15:22:31

+1

如果有疑問,請始終嘗試使用-LiteralPath而不是-Path,以防字符串中出現一些可能會在評估表達式時變成別的東西。 – 2014-12-05 15:26:22

+0

@ Matt我在我指出來的時候複製了我指出的代碼行。有問題的目錄中沒有重複文件。 @ Mickey我會嘗試-LiteralPath – YetAnotherRandomUser 2014-12-05 15:32:57

回答

0

事實證明,我忘了刪除在新文件夾中的目標路徑的子文件夾參考。這絕對是一個「唔」的時刻。目標文件夾是1個文件夾太長,所以這就是爲什麼沒有被複制。

感謝您的幫助!

相關問題