$dir = Read-Host 'Please enter the letter drive to backup user folder.'
copy-item ($env:USERPROFILE+"\Documents") -destination ($dir+":\Backup") -recurse
私はドキュメントフォルダをコピーしようとしていますが、バックアップフォルダを見ると写真とビデオもコピーされています。次のエラーを取得:powershellを使用してドキュメントフォルダをコピーしようとしています
Copy-Item : Access to the path 'C:\Users\admin\Documents\My Music' is denied.
At C:\Users\admin\Desktop\Untitled1.ps1:2 char:10
+ copy-item <<<< ($env:USERPROFILE+"\Documents") -destination ($dir+":\Backup") -recurse
+ CategoryInfo : PermissionDenied: (My Music:DirectoryInfo) [Copy-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : CopyDirectoryInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
Copy-Item : Access to the path 'C:\Users\admin\Documents\My Pictures' is denied.
At C:\Users\admin\Desktop\Untitled1.ps1:2 char:10
+ copy-item <<<< ($env:USERPROFILE+"\Documents") -destination ($dir+":\Backup") -recurse
+ CategoryInfo : PermissionDenied: (My Pictures:DirectoryInfo) [Copy-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : CopyDirectoryInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
Copy-Item : Access to the path 'C:\Users\admin\Documents\My Videos' is denied.
At C:\Users\admin\Desktop\Untitled1.ps1:2 char:10
+ copy-item <<<< ($env:USERPROFILE+"\Documents") -destination ($dir+":\Backup") -recurse
+ CategoryInfo : PermissionDenied: (My Videos:DirectoryInfo) [Copy-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : CopyDirectoryInfoItemUnauthorizedAccessError,Microsoft.PowerShell.Commands.CopyItemCommand
また、選択したドライブのルートにユーザーフォルダを作る
これらのリンクは、実際には従来のアプリケーションのシンボリックリンクです。可能性のある複製http://stackoverflow.com/questions/21514284/parsing-shortcuts-in-powershell – user4317867
通常、これらのシンボリックリンクは必要ありません(レガシーでよく記述されていないWindowsアプリケーションのバックコンパイル用にのみ存在します)。他のすべてに成功した。エラーメッセージにもかかわらずコピーが実際には動作しなかったことを確認しましたか?エラーを取り除くためのすばやく簡単な方法の1つは '-ErrorAction SilentlyContinue'ですが、正当なエラーも抑制するので注意してください。 –