PowerShell을 사용하여 기본 사용자 프로필에 파일 복사

PowerShell을 사용하여 기본 사용자 프로필에 파일 복사

아래 코드는 예상대로 작동하지 않습니다. 기본 사용자를 제외한 모든 사용자 프로필에 파일과 디렉터리를 복사합니다. 관리자 권한으로 Powershell을 실행하고 있습니다.

$Source = 'C:\Temp\Teste\*'
$Destination = 'C:\users\*\AppData\Local\'
$Default = 'C:\users\Default\AppData\Local\'
Get-ChildItem $Destination | ForEach-Object {Copy-Item -Path $Source -Destination $_ -Force -Recurse}
Get-ChildItem $Default -Force | ForEach-Object {Copy-Item -Path $Source -Destination $_ -Force -Recurse}

답변1

소스 위치의 모든 파일과 폴더를 %localappdata%기본 프로필로 복사해야 한다고 가정합니다. 마지막 줄을 다음과 같이 변경하면 여기에서 작동합니다.

Copy-Item -Path $Source -Destination $Default -Force

재귀적으로 복사합니다(소스에서 대상으로 모든 하위 폴더 및 파일).

Copy-Item -Path $Source -Destination $Default -Force -Recurse

관련 정보