新しい Windows 2008 サーバー ローカル ユーザーを作成し、そのユーザーに別のプロファイル パスを割り当てようとしています。Windows が C:\Users\newUser の下にすべてのファイルを生成するのではなく、D:\customDir\newUser でそれを実行するようにしたいと考えています。これを行う方法を知っている人はいますか?
これまでのところ、これは私が持っているものです:
$users= @("U1","U2","U3")
$computer = [ADSI]"WinNT://$env:COMPUTERNAME,computer"
$group = [ADSI]"WinNT://$env:COMPUTERNAME/MyCustomGroup,group"
$users | foreach {
$userName = $_
$userPath = "D:\customDir\$userName"
echo "Creating $userName..."
$user = $computer.Create("User",$userName)
$user.put("description","User $userName Description")
#$user.put("profilePath",$userPath) #This does not work, throws an error
#$user.put("homeDirDrive","D:") #This appears to be ignored when uncommented
$user.setpassword($userName)
$user.setInfo()
$group.add($user.Path)
#run cmd from user account to create profile files/folders
$spw = ConvertTo-SecureString $userName -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList $userName,$spw
Start-Process cmd /c -WindowStyle Hidden -Credential $cred -ErrorAction SilentlyContinue
}
スクリプトはユーザーを正常に作成してカスタム グループに追加しますが、すべてのファイル/フォルダーは最終的に C:\Users\U* になります。