我需要使用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