powershell - Automating the creation of Homedrive of a newly created AD user -


i have made script create homefolder(by name of samaccountname) newly created ad user.

$adserver = 'xyz1'  import-module activedirectory  $searchbase = "ou=xyz2,ou=xyz3,dc=xyz4,dc=xyz5"  $adusers = get-aduser -filter {name -eq "xyz6"} -server $adserver -searchbase $searchbase -properties *  new-item -itemtype directory -path "xyz7\$($adusers.samaccountname)" 

everything automated except fact have feed in name of user (ad account name) make search particular user. want change process. want make automated thru scheduled run.

now, want query eventlog , search eventid = 4720 (ie "a new user created") , trap samaccountname of newly created user (under attributes [i have checked]) , pass in current script... if run overall script scheduled run, detect new user creation , automatically make homefolder.

$a = (get-eventlog system | where-object {$_.eventid -eq 514}).message 

should allow information want. can split result parese out sam name.

"514" example - you'll need replace ever eventid want track.

linky has more info on how use get-eventlog filter results


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -