簡體   English   中英

復制項目失敗而沒有錯誤,我敢肯定這很簡單,但我看不到它

[英]Copy-item failing without error, I'm sure it's something simple but I can't see it

我正在編寫一個PowerShell腳本,以將大量文檔“編譯”到一個文件夾中,以便我可以將其壓縮然后分發。 該腳本將從各種特別指定的目錄中拉出,因此我不必四處搜尋,也不會丟失文檔和某些修訂版。

我正在插電,並且運行正常,並且在過程中的某個時刻,某些操作停止了。 我不知道發生了什么變化,或者是否達到極限,或者發生了什么,因為這是我使用PowerShell編寫的第一個腳本。 我認為我忽略了一些非常基本的內容或犯了一個基本錯誤。 直到出現我的錯誤或達到的極限為止,腳本運行良好,並且正在復制這些文檔。 這些文檔主要是PDF,一些word文檔,我認為某個地方有一個或兩個電子表格。

在第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"

腳本停止復制文檔,我不知道為什么。 我希望你們和女孩可以幫助我。 在找到了復制項目的各種高級功能之前,我已經用Googled和DuckDuckGo進行了搜索,我認為我不需要這些。 我正在腳本中創建目錄,因此無需測試它們是否存在,並且我知道源目錄中將有文件,這就是它們成為源目錄的原因。

我是在某個地方犯了根本性錯誤,還是達到了我不知道的極限? 我不是要復制超過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在讀取/訪問文件時遇到問題,因此我從該目錄中刪除了該文件,並且該目錄中的任何內容都沒有被復制。

我正在使用似乎是ISE v1.0的Windows 7 Pro 64位進行開發

我遇到了有關添加日志記錄語句的線程: Powershell Copy-Item緩存,但是我不確定如何對此進行集成。

這是整個腳本:

# 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"

原來,我忘記了在較新文件夾的目標路徑中刪除子文件夾引用。 那絕對是一個“ duh”時刻。 目標文件夾太長1個文件夾,因此這就是為什么沒有復制任何內容的原因。

謝謝您的幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM