I'm using PowerShell on Windows 7, and writing a script to copy a bunch of files from one folder structure to another. Kind of like compiling. The PowerShell Copy-Item
cmdlet thinks that square brackets, [ ], are wildcards of some kind, and I am not able to escape them for some reason.
I can't use -LiteralPath
, because I want to use an asterisk * wildcard since the filename has a date as part of the filename, and the date changes. The date is used as a version number.
This post was helpful, but no amount of ticks (2x or 4x per bracket) escapes the square brackets.
I am not receiving an error; PowerShell behaves the same as if I entered in the wrong filename.
This is the specific line I'm working on:
#to Fusion Server
Copy-item -Path $FSG$SW.RoomView.Notesstarter"[RoomView] Versions explained*.pdf" -Destination $FSG$containerFolder$rootFolder"Fusion Server"
And this is the whole thing:
# Compiles the Fusion packet for distribution
###############################
###########Variables###########
###############################
#folder structure
$FSG = "F:FSG"
$containerFolder = "Packet.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.HardwareTPMC-3SM.Documentation"
$4SMDoc = "0.HardwareTPMC-4SM.Documentation"
$4SMDDoc = "0.HardwareTPMC-4SM-FD.Documentation"
$730Doc = "0.HardwareTSW-730.Documentation"
$730OLH = "0.HardwareTSW-730.OLH"
$CENRVS = "0.HardwareCEN-RVS.Notes"
$ProjMgmt = "0.Project Management"
$SW = "0.Software"
$RVLicensing = "0.Software.RoomView.License"
$RVNotes = "0.Software.RoomView.Notes"
$SQLLicensing = "0.Softwaredatabase.SQL.Licensing"
$SQLNotes = "0.Softwaredatabase.SQL.Notes"
$FRVMarketing = "0.SoftwareFusion RV.Marketing"
$FRVNetworking = "0.SoftwareFusion RV.Networking"
$FRVNotes = "0.SoftwareFusion 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 "Licenseing Information"
md "Networking"
md "Official Documentation"
md "Prerequisites, including powerShell script"
md "Product Info"
md "Requirements"
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
###############################
#Copy-Item -Path C:fso20110314.log -Destination c:fsoxmylog.log
#To the root
Copy-item -Path $FSG$ProjMgmtstarter"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$SWxpanel.Notesstarter*.* -Destination $FSG$containerFolder$rootFolder"eControl and xPanels"
#to Fusion Server
Copy-item -Path $FSG$SW.RoomView.Notesstarter"[RoomView] Versions explained*.pdf" -Destination $FSG$containerFolder$rootFolder"Fusion Server"
What can I do to escape the square brackets and still use a wildcard filename part of the Copy-Item
cmdlet?