#copies program directory
copy-item .\iphone -Recurse c:\Users\$env:username -force
#sets file I want to copy to unknown directory name as $file1
C:\Users\$env:username\iphone\.filename = $file1
#sets unknown folder location to $location1 which is a randomly named directory
#under this subfolder in appdata\Roaming\parentfolder\23761253721536721(random //number) ,
#name is just a string of numbers
Get-ChildItem C:\Users\$env:username\AppData\Roaming\parentfolder = $location1
//attempts to copy file to location
copy-item $file1 $location1
PowerShell 新手。我确信我让这件事变得比需要的更难。这就像我尝试执行此操作的第 10 个脚本一样,我觉得我离答案越来越远了。一直在技术网上查看示例,但没有找到任何用于设置我试图将文件复制到的未知目录路径的内容。
如果您的回答不介意解释代码在做什么,以便我可以学习,我将不胜感激。
为变量赋值时,变量引用需要位于 的左侧=
:
$file1 = Get-Item C:\Users\$env:username\iphone\.filename
$location1 = Get-ChildItem C:\Users\$env:username\AppData\Roaming\parentfolder
$file1 |Copy-Item -Destination $location1.FullName
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句