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

1.6k views Asked by At

I'm writing a PowerShell script to "compile" a bunch of documentation into a folder so I can zip it up and then distribute it. The script will pull from various specially designated directories so i don't have to hunt and peck through them and potentially miss documents and certain revisions.

I was plugging away and it was working, and at some point in my process, something stopped. I can't figure out what changed, or if I hit a limit, or what's going on, since this is my first script with PowerShell. I think I'm overlooking something very basic or made a fundamental error. Up until my mistake, or the limit that I've hit, the script runs fine and those documents are being copied. The documents are mostly PDFs, some word docs, and I think there's a spreadsheet or two somewhere.

At the completion of line 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"

the script stops copying documents and I can't figure out why. I'm hoping you guys & gals can help me. I've Googled & DuckDuckGo'd until I've found all sorts of advanced features of copy-item and I don't think I need any of those. I'm creating the directories in the script, so I don't need to test if they're there, and I know there will be files in the source directories, that's why they're the source directories.

Did I make a fundamental mistake somewhere, or did I hit some limit I didn't know of? I'm not trying to copy a file with more than 255 characters. The longest in that last folder is 192.

The script is still advancing past line 176; I was getting an error at line 188

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

where PowerShell was having a problem reading/accessing a file, so I removed the file from that directory and nothing from that directory is being copied.

I'm developing on Windows 7 Pro 64 bit in what seems to be ISE v1.0

I came across this thread about adding logging statements: Powershell Copy-Item caching but I'm not sure how to integrate that for this.

Here is the entire script:

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

There are 1 answers

0
YetAnotherRandomUser On BEST ANSWER

It turns out that I forgot to remove a subfolder reference in the destination paths in the newer folders. it was most definately a "duh" moment. The destination folders were 1 folder too long, so that's why nothing was getting copied.

Thanks for the help!