Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 复制项目失败,无错误,I';我确信它是';这很简单,但我能';我看不出来_Powershell_Copy Item - Fatal编程技术网

Powershell 复制项目失败,无错误,I';我确信它是';这很简单,但我能';我看不出来

Powershell 复制项目失败,无错误,I';我确信它是';这很简单,但我能';我看不出来,powershell,copy-item,Powershell,Copy Item,我正在编写一个PowerShell脚本,将一堆文档“编译”到一个文件夹中,这样我就可以将其压缩并分发。该脚本将从各种特别指定的目录中提取,因此我不必搜索和浏览它们,并可能丢失文档和某些修订 我正在插电,它正在工作,在我的过程中的某个时刻,一些东西停止了。我不知道发生了什么变化,或者我是否达到了极限,或者发生了什么,因为这是我使用PowerShell的第一个脚本。我想我忽略了一些非常基本的东西,或者犯了一个根本性的错误。直到我犯了错误,或者我达到了极限,脚本运行正常,这些文档正在被复制。这些文档主

我正在编写一个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"
脚本停止复制文档,我不知道为什么。我希望你们能帮助我。我一直在谷歌上搜索,直到我找到了复制品的各种高级功能,我想我不需要这些。我在脚本中创建目录,所以我不需要测试它们是否存在,我知道源目录中会有文件,这就是为什么它们是源目录

我是在什么地方犯了一个根本性的错误,还是达到了我不知道的极限?我不想复制超过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 Pro 64位上开发ISE v1.0版

我遇到了一个关于添加日志语句的帖子: 但我不确定如何将其整合到这一点上

以下是整个脚本:

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

结果是,我忘了删除较新文件夹中目标路径中的子文件夹引用。这绝对是一个“无聊”的时刻。目标文件夹太长,因此无法复制任何内容


谢谢你的帮助

你能告诉我们具体的错误吗?另外,虽然我们自己也可以找到这些行,但您能否指出代码中引用的行,这样我们就不必担心猜错了?其中一些将被放到相同的目录中。文件名可以相同吗?这不会停止脚本,但
-Force
可能有助于防止出现这种情况。如果有疑问,请始终尝试使用-LiteralPath而不是-Path,以防在计算表达式时字符串中有一些古怪的东西可能会变成其他东西。@Matt在我指出这些行之后,我确实复制了我指出的脚本行。有问题的目录中没有重复的文件。@Mickey我会试试-LiteralPath我在路径名中看到一些方括号
[
]
,请小心。我在文件名中使用[和],而不是文件夹名。我花了一点时间寻找合适的转义字符,甚至在脚本中做了笔记来区分“vs”。那很“有趣”。英雄联盟