1

更新されたショートカットをワイルドカード パスにコピーしようとしています。ローカル マシンのテスト シナリオでコードを実行すると、コードが機能します。

$Source1 = "C:\Temp\Updated Shortcut\MyShortcut.lnk"
$destination1 = "C:\Temp\Users\*\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\MyShortcut.lnk"
Get-ChildItem -Path $destination1 | ForEach-Object { Copy-Item -Path $Source1 -Destination $_.DirectoryName }

ただし、本番ターゲット パスに対して実行しても機能しません。

$Source1 = "C:\Temp\Updated Shortcut\MyShortcut.lnk"
$destination1 = "U:\Users\*\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\MyShortcut.lnk"
Get-ChildItem -Path $destination1 | ForEach-Object { Copy-Item -Path $Source1 -Destination $_.DirectoryName }

ワイルドカードを削除して実際のパスを使用しても機能します。

$Source1 = "C:\Temp\Updated Shortcut\MyShortcut.lnk"
$destination1 = "U:\Users\JohnSmith\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\MyShortcut.lnk"
Get-ChildItem -Path $destination1 | ForEach-Object { Copy-Item -Path $Source1 -Destination $_.DirectoryName }

U:\Users フォルダーには 1181 個のフォルダー (1181 ユーザーごとに 1 つ) が含まれているため、それも問題になるかどうかはわかりません??

4

1 に答える 1