Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.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命令在桌面上保存文件_Powershell - Fatal编程技术网

我需要使用powershell命令在桌面上保存文件

我需要使用powershell命令在桌面上保存文件,powershell,Powershell,我正试图在我的桌面上保存一个文件,我该怎么做呢 这是我的尝试 New-Item index.html -Destination c:\users\aaa\desktop 通过以下方式创建新文件: New-Item -Type File -Name "test.txt" -Path 'C:\temp' "test" | Out-File -Append "C:\temp\test.txt" 通过以下方式写入文件: New-Item -Type File -Name "test.txt

我正试图在我的桌面上保存一个文件,我该怎么做呢

这是我的尝试

New-Item index.html -Destination c:\users\aaa\desktop
通过以下方式创建新文件:

 New-Item -Type File -Name "test.txt" -Path 'C:\temp'
 "test"  | Out-File -Append "C:\temp\test.txt"
通过以下方式写入文件:

 New-Item -Type File -Name "test.txt" -Path 'C:\temp'
 "test"  | Out-File -Append "C:\temp\test.txt"
复制文件:

  Copy-Item "C:\temp\test.txt" "C:\someWhereElse\test.txt"

有几种方法可以获取桌面路径:

$myDesktop = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::Desktop)

有了这个路径后,只需使用

但是我假定您要将现有文件复制到桌面,因此需要cmdlet


请查看该cmdlet的帮助>>
获取帮助新项目-参数*
New-Item -ItemType File -Path $myDesktop -Name 'index.html' | Out-Null
Copy-Item -Path 'PATH AND FILENAME WHERE THE ORIGINAL FILE IS' -Destination $myDesktop