【发布时间】:2015-08-17 18:54:48
【问题描述】:
请注意,这是我的第一个 powershell 脚本项目。我正在尝试编写一个脚本,提示用户输入源文件和将其复制到的目录。该脚本运行没有错误,但实际上并没有复制文件。任何帮助将不胜感激。一个使用示例是:将 C:\Users\User\Desktop\info.txt 复制到 C:\Users\User\Documents\*
$source = Get-ChildItem -Path (Read-Host -Prompt 'Enter the full name of the file you want to copy')
$dirs = Get-ChildItem -Path (Read-Host -Prompt 'Enter the full name of the directory you want to copy to')
foreach ($dir in $dirs){
copy $source $dir
}
【问题讨论】:
标签: powershell scripting