Adding homeDirectory attribute to account created with Powershell
hi, when create new accounts , add attribute $objuser.put("homedirectory", "\\dc01\home$\$username") can see it's populated in account in ad, , mapped drive when user logs on, actual folder on share not created on share. need add script add folder share?? or not possible?
thanks
$users = import-csv "c:\script\list3.csv" $objadsi = [adsi]"ldap://ou=*users,dc=corp,dc=we" $users | foreach { $username = $_.username $path = "\\dc01\home$\$username" $objuser = $objadsi.create("user", "cn=$username") $objuser.put("samaccountname", $username) $objuser.put("userprincipalname", $username + "@corp.we") $objuser.put("homedirectory", $path) $objuser.setinfo() $objuser.setpassword("password1") $objuser.psbase.invokeset('accountdisabled', $false) $objuser.setinfo() if (-not (test-path $path)) { $acl = (md $path).getaccesscontrol() $perm = ($username + "@corp.we"),"modify","containerinherit,objectinherit","none","allow" $accessrule = new-object system.security.accesscontrol.filesystemaccessrule $perm $acl.setaccessrule($accessrule) $acl | set-acl -path $path } }
Windows Server > Windows PowerShell
Comments
Post a Comment