Setting Home Directory for newly added users
I'm writing a Powershell script to do a complete Windows 7 Build. I have a
function that adds the users I need, but it does not set the Home
Directory, which makes a later section of my script (setting the users'
desktops) fail because the directories "don't exist" yet.
Here is the main part of the function:
[CmdletBinding()]
Param(
[Parameter(Position=0,
Mandatory=$True,
ValueFromPipeline=$True)]
[string]$userName,
[Parameter(Position=1,
Mandatory=$True,
ValueFromPipeline=$True)]
[string]$password,
[string]$computerName = $env:ComputerName,
[string]$description = "Created by PowerShell"
)
$computer = [ADSI]"WinNT://$computerName"
$user = $computer.Create("User", $userName)
$user.setpassword($password)
$user.put("description",$description)
$user.SetInfo()
}
No comments:
Post a Comment