Creating a home folder during new hire script.


i wasn't sure if should post in orchestrator forums or not using scsm , scorch make new user account.  works without issue until point creating home folder , setting security.

i spare full details of happens begin defining username , password of can make accounts. follow following code.

$adcredential = new-object system.management.automation.pscredential ($aduser,(convertto-securestring $adpassword -asplaintext -force))     $session = new-pssession -computername localhost 

from there, create scriptblock, passing in number of variables.  use following code create home drive , set security.

$udrive = new-item -path $homedirectorybase -name $samaccountname -itemtype directory  $acl = get-acl $udrive  $ar = new-object system.security.accesscontrol.filesystemaccessrule("domain\$samaccountname","modify","containerinherit, objectinherit", "none","allow")  $acl.setaccessrule($ar)  set-acl -path $udrive -aclobject $acl

sometimes script works without issue fails error code being "some or identity references not translated" @ point.  guessing happening user being created on 1 domain controller , setting permissions looking @ dc user not exist.

would able control , things "better" by changing session localhost dc?

thank in advance.

you cannot remotely resolve domain accounts due security restrictions.

we use gp create new user folders via folder redirection.  1 set automatic , folders created correct security first time user logs in.  set home folder redirected "documents" folder share , well.


\_(ツ)_/



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

DCOM received error "2147746132" from...

ADFS 3.0 Event ID 4625 | An Error occurred During Logon | Status: 0xC000035B

DFSR RPC replication errors 5014 1726 with large files over VPN