Answer the question
In order to leave comments, you need to log in
How to write a login script?
Help me write the simplest login script (*.bat *.vbs or on PowerShell)
The algorithm is as follows:
1.) He must create once a text file on the ball with a username from AD
2.) He must add to this file every time at user login - computer name
and login time (excluding terminals, only local computers in the domain are needed)
Answer the question
In order to leave comments, you need to log in
echo %computername% %date% %time% >>\\server\share\%username%.txt
Run a script on the logog / logof, and look in AD the user went he went:
Param(
[Parameter(Position=0)]
[ValidateSet("Logon","Logoff","Unknown")]
[string]$Status="Unknown"
)
#no spaces in the filter
[adsisearcher]$searcher="samaccountname=$env:username"
#find the current user
$find = $searcher.FindOne()
#get the user object
[adsi]$user = $find.Path
#define a string to indicate status
$note= @("{0} {1} to {2}" -f (Get-Date),$status.ToUpper(),$env:computername)
[array]$NewVals = @()
$NewVals = try {
($user.GetEx('url'))[0..10]
}
catch {
@()
}
$newVals += $note
#DEBUG, output values in ISE
#$NewVals | out-host
#update the user property
$user.PutEx(2, 'url', $NewVals )
#commit the change
$user.SetInfo()
#DEBUG, output values in ISE
#$user.GetEx('url')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question