トップページ > プログラム > 2020年10月01日 > tnCBqate

書き込み順位&時間帯一覧

24 位/131 ID中時間01234567891011121314151617181920212223Total
書き込み数0000000000100000000001002



使用した名前一覧書き込んだスレッド一覧
デフォルトの名無しさん
PowerShell -Part 4

書き込みレス一覧

PowerShell -Part 4
610 :デフォルトの名無しさん[sage]:2020/10/01(木) 10:19:36.95 ID:tnCBqate
New-Itemはハードリンクもバグってる
こっちはWindows以外のOSでも問題になるはず

New-Item -Type Directory -Name linktest
New-Item -Name linktest\target
New-Item -type HardLink -Name linktest\hardlink -Target linktest\target

に対して、こんなメッセージでエラーになってしまう

New-Item: Could not find item linktest\target.

興味深いのは

New-Item -Type HardLink -Name linktest\hardlink -Target target

と間違えてみると

New-Item: Cannot find path 'カレントディレクトリ\target' because it does not exist.

ちゃんと正しいエラーメッセージが返る
不思議だ
PowerShell -Part 4
612 :デフォルトの名無しさん[sage]:2020/10/01(木) 21:26:37.01 ID:tnCBqate
これでどう? (長すぎて切れるかも)

$origCurDir = [System.Environment]::CurrentDirectory
New-Item -ItemType Directory -Path linktest

Push-Location linktest
New-Item -ItemType Directory -Path dir

Push-Location dir # linktest/dir
New-Item -ItemType Directory -Path subdir
Set-Content -Path file -Value "hello"
New-Item -ItemType HardLink -Path hardlink_1 -Value file
New-Item -ItemType SymbolicLink -Path symlink_1 -Value subdir

Pop-Location # linktest
New-Item -ItemType HardLink -Path dir/hardlink_2 -Value dir/file
New-Item -ItemType SymbolicLink -Path dir/symlink_2 -Value subdir

Push-Location dir # linktest/dir
[System.Environment]::CurrentDirectory = $PWD
New-Item -ItemType HardLink -Path hardlink_3 -Value file
New-Item -ItemType SymbolicLink -Path symlink_3 -Value subdir

Pop-Location # linktest
[System.Environment]::CurrentDirectory = $PWD
New-Item -ItemType HardLink -Path dir/hardlink_4 -Value dir/file
New-Item -ItemType SymbolicLink -Path dir/symlink_4 -Value subdir

Pop-Location
[System.Environment]::CurrentDirectory = $origCurDir

Get-ChildItem -Path linktest/dir | Sort-Object -Property CreationTime | Format-Table Attributes,LinkType,Target,Length,Name


※このページは、『2ちゃんねる』の書き込みを基に自動生成したものです。オリジナルはリンク先の2ちゃんねるの書き込みです。
※このサイトでオリジナルの書き込みについては対応できません。
※何か問題のある場合はメールをしてください。対応します。