M
M
m33th00k2020-09-24 10:01:22
Active Directory
m33th00k, 2020-09-24 10:01:22

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

3 answer(s)
C
ComodoHacker, 2020-09-24
@ComodoHacker

echo %computername% %date% %time% >>\\server\share\%username%.txt

I think it's easier than ever.

D
Dmitry Shumov, 2020-09-24
@dshumov

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')

C
CityCat4, 2020-09-24
@CityCat4

You can write at least on vbs, at least on ps - what you know, write on that. The task is simple, it is decided that there is there. Reading the documentation of the corresponding language and MSDN is something, and M$'s MSDN is drop dead.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question