How to track the date and time when AD users last accessed/mapped a shared folderPowershell - local credential verificationServer 2012 Local Shares - Cannot access using \IP but works via \localhostwhere does AD get logon datestampUsing a link/junction between web serversHow to modify Last Write Time and Last Access on folderTracking last modified date on a large file shareGet-WinEvent via Powershell remotingUsing Server USB SmartCard readerLast time User Profile was used on list of workgroup computersCombine powershell output

What is the term for a person whose job is to place products on shelves in stores?

Critique of timeline aesthetic

Do I need to watch Ant-Man and the Wasp and Captain Marvel before watching Avengers: Endgame?

What is this word supposed to be?

Will I lose my paid in full property

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

Can I criticise the more senior developers around me for not writing clean code?

How much of a wave function must reside inside event horizon for it to be consumed by the black hole?

Zonal Statistics is returning null values in ArcGIS

Older movie/show about humans on derelict alien warship which refuels by passing through a star

Unknown code in script

Is it acceptable to use working hours to read general interest books?

Should the Product Owner dictate what info the UI needs to display?

How much cash can I safely carry into the USA and avoid civil forfeiture?

Nails holding drywall

Why must Chinese maps be obfuscated?

Who's the random kid standing in the gathering at the end?

What is purpose of DB Browser(dbbrowser.aspx) under admin tool?

Find the identical rows in a matrix

Partitioning values in a sequence

What is the best way to deal with NPC-NPC combat?

Why do games have consumables?

I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?

Does a large simulator bay have standard public address announcements?



How to track the date and time when AD users last accessed/mapped a shared folder


Powershell - local credential verificationServer 2012 Local Shares - Cannot access using \IP but works via \localhostwhere does AD get logon datestampUsing a link/junction between web serversHow to modify Last Write Time and Last Access on folderTracking last modified date on a large file shareGet-WinEvent via Powershell remotingUsing Server USB SmartCard readerLast time User Profile was used on list of workgroup computersCombine powershell output






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am trying to get a list of all users defined in the Windows Server with the date-time of the last time it either logged in to the server or mapped/accessed a file share.
to do that I tried the following script:



Get-ADUser -Filter * -SearchBase "dc=whatever,dc=local" -ResultPageSize 0 -Prop CN,samaccountname,LastLogonTimestamp | Select CN,samaccountname,@N='Last‌Logon'; E=[DateTime]::FromFileTime($_.LastLogonTimestamp)


Which provided me with the following output:



CN samaccountname Last‌Logon 
-- -------------- -----------
Administrador Administrador 08/02/2019 17:30:00
Invitado Invitado 01/01/1601 1:00:00
krbtgt krbtgt 01/01/1601 1:00:00
Maite maite 01/01/1601 1:00:00
Mari Carmen mcarmen 01/01/1601 1:00:00
Emilio emilio 01/01/1601 1:00:00
Erica erica 01/01/1601 1:00:00


I know for a fact that the users other than Administrator have accessed the server file shares (some of them map them as drives every day) but the only valid logon date obtained in the list is for Adminstrator.



It seems like this command is only reporting when a user actually logs into the server through RDP or the console.



How can I get a similar query to report each time a user accessed any of the servers shares?










share|improve this question
























  • I feel like you would be better suited to enable file level and share level auditing on the servers. Then query the audit logs for the data you want. If you send the logs to a robust log collection engine, it may even have real-time triggers you can configure. You could send them to the event log for example and set up subscriptions from a central log server although I have not necessarily liked that solution in the past personally.

    – AdminOfThings
    Mar 24 at 13:43


















0















I am trying to get a list of all users defined in the Windows Server with the date-time of the last time it either logged in to the server or mapped/accessed a file share.
to do that I tried the following script:



Get-ADUser -Filter * -SearchBase "dc=whatever,dc=local" -ResultPageSize 0 -Prop CN,samaccountname,LastLogonTimestamp | Select CN,samaccountname,@N='Last‌Logon'; E=[DateTime]::FromFileTime($_.LastLogonTimestamp)


Which provided me with the following output:



CN samaccountname Last‌Logon 
-- -------------- -----------
Administrador Administrador 08/02/2019 17:30:00
Invitado Invitado 01/01/1601 1:00:00
krbtgt krbtgt 01/01/1601 1:00:00
Maite maite 01/01/1601 1:00:00
Mari Carmen mcarmen 01/01/1601 1:00:00
Emilio emilio 01/01/1601 1:00:00
Erica erica 01/01/1601 1:00:00


I know for a fact that the users other than Administrator have accessed the server file shares (some of them map them as drives every day) but the only valid logon date obtained in the list is for Adminstrator.



It seems like this command is only reporting when a user actually logs into the server through RDP or the console.



How can I get a similar query to report each time a user accessed any of the servers shares?










share|improve this question
























  • I feel like you would be better suited to enable file level and share level auditing on the servers. Then query the audit logs for the data you want. If you send the logs to a robust log collection engine, it may even have real-time triggers you can configure. You could send them to the event log for example and set up subscriptions from a central log server although I have not necessarily liked that solution in the past personally.

    – AdminOfThings
    Mar 24 at 13:43














0












0








0








I am trying to get a list of all users defined in the Windows Server with the date-time of the last time it either logged in to the server or mapped/accessed a file share.
to do that I tried the following script:



Get-ADUser -Filter * -SearchBase "dc=whatever,dc=local" -ResultPageSize 0 -Prop CN,samaccountname,LastLogonTimestamp | Select CN,samaccountname,@N='Last‌Logon'; E=[DateTime]::FromFileTime($_.LastLogonTimestamp)


Which provided me with the following output:



CN samaccountname Last‌Logon 
-- -------------- -----------
Administrador Administrador 08/02/2019 17:30:00
Invitado Invitado 01/01/1601 1:00:00
krbtgt krbtgt 01/01/1601 1:00:00
Maite maite 01/01/1601 1:00:00
Mari Carmen mcarmen 01/01/1601 1:00:00
Emilio emilio 01/01/1601 1:00:00
Erica erica 01/01/1601 1:00:00


I know for a fact that the users other than Administrator have accessed the server file shares (some of them map them as drives every day) but the only valid logon date obtained in the list is for Adminstrator.



It seems like this command is only reporting when a user actually logs into the server through RDP or the console.



How can I get a similar query to report each time a user accessed any of the servers shares?










share|improve this question
















I am trying to get a list of all users defined in the Windows Server with the date-time of the last time it either logged in to the server or mapped/accessed a file share.
to do that I tried the following script:



Get-ADUser -Filter * -SearchBase "dc=whatever,dc=local" -ResultPageSize 0 -Prop CN,samaccountname,LastLogonTimestamp | Select CN,samaccountname,@N='Last‌Logon'; E=[DateTime]::FromFileTime($_.LastLogonTimestamp)


Which provided me with the following output:



CN samaccountname Last‌Logon 
-- -------------- -----------
Administrador Administrador 08/02/2019 17:30:00
Invitado Invitado 01/01/1601 1:00:00
krbtgt krbtgt 01/01/1601 1:00:00
Maite maite 01/01/1601 1:00:00
Mari Carmen mcarmen 01/01/1601 1:00:00
Emilio emilio 01/01/1601 1:00:00
Erica erica 01/01/1601 1:00:00


I know for a fact that the users other than Administrator have accessed the server file shares (some of them map them as drives every day) but the only valid logon date obtained in the list is for Adminstrator.



It seems like this command is only reporting when a user actually logs into the server through RDP or the console.



How can I get a similar query to report each time a user accessed any of the servers shares?







powershell windows-server-2012






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 17:33









mxmissile

7,92734171




7,92734171










asked Mar 22 at 16:49









Oriol de los SantosOriol de los Santos

31




31












  • I feel like you would be better suited to enable file level and share level auditing on the servers. Then query the audit logs for the data you want. If you send the logs to a robust log collection engine, it may even have real-time triggers you can configure. You could send them to the event log for example and set up subscriptions from a central log server although I have not necessarily liked that solution in the past personally.

    – AdminOfThings
    Mar 24 at 13:43


















  • I feel like you would be better suited to enable file level and share level auditing on the servers. Then query the audit logs for the data you want. If you send the logs to a robust log collection engine, it may even have real-time triggers you can configure. You could send them to the event log for example and set up subscriptions from a central log server although I have not necessarily liked that solution in the past personally.

    – AdminOfThings
    Mar 24 at 13:43

















I feel like you would be better suited to enable file level and share level auditing on the servers. Then query the audit logs for the data you want. If you send the logs to a robust log collection engine, it may even have real-time triggers you can configure. You could send them to the event log for example and set up subscriptions from a central log server although I have not necessarily liked that solution in the past personally.

– AdminOfThings
Mar 24 at 13:43






I feel like you would be better suited to enable file level and share level auditing on the servers. Then query the audit logs for the data you want. If you send the logs to a robust log collection engine, it may even have real-time triggers you can configure. You could send them to the event log for example and set up subscriptions from a central log server although I have not necessarily liked that solution in the past personally.

– AdminOfThings
Mar 24 at 13:43













1 Answer
1






active

oldest

votes


















0














You file share access creates a Network Logon (Logon Type 3) which doesn't affect the LastLogon attribute (and LastLogonTimestamp respectively). In this case you will have to obtain the information from the Domain Controllers event log, where all logons are logged. The following script will output the last logon date of any user with its logon type of the last 24h.



#86400000 = 24h
$FilterXPath = '*[System[EventID=4624 and TimeCreated[timediff(@SystemTime) <= 86400000]]]'
$LogonEvents = Get-WinEvent -LogName Security -FilterXPath $FilterXPath

$Logons = foreach ($LogonEvent in $LogonEvents)
[PSCustomObject]@
LogonDate = $LogonEvent.TimeCreated
UserName = $LogonEvent.Properties[5].Value
UserDomain = $LogonEvent.Properties[6].Value
LogonType = $LogonEvent.Properties[8].Value



$LogonsGroupedByUserName = $Logons | Group-Object -Property UserName

foreach ($Group in $LogonsGroupedByUserName)
$Group.Group





share|improve this answer

























  • Thanks for the info. It does not really help me in this case since the Atttribute I am using is the LastLogonTimestamp (which is replicated). On the other hand, I only have one Domain controller which is also the file server. My problems really is the fact that the users that simply access the network drives do not seem to be updating this parameter. Most users use a local windows user but when they access the share they need to identify themselves using the AD user (I know .. this is something we should change... )

    – Oriol de los Santos
    Mar 23 at 19:05












  • Right, I didn't notice you are using LogonTimeStamp in your query. I updated my answer.

    – vrdse
    Mar 24 at 9:15











  • Thanks. I had to make a change into the FilterXpath line definition because it did not take it as is. I simply removed the TimeCreated restriction and left it as: $FilterXPath = '*[System[EventID=4624]]'

    – Oriol de los Santos
    Mar 25 at 12:15











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55304329%2fhow-to-track-the-date-and-time-when-ad-users-last-accessed-mapped-a-shared-folde%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You file share access creates a Network Logon (Logon Type 3) which doesn't affect the LastLogon attribute (and LastLogonTimestamp respectively). In this case you will have to obtain the information from the Domain Controllers event log, where all logons are logged. The following script will output the last logon date of any user with its logon type of the last 24h.



#86400000 = 24h
$FilterXPath = '*[System[EventID=4624 and TimeCreated[timediff(@SystemTime) <= 86400000]]]'
$LogonEvents = Get-WinEvent -LogName Security -FilterXPath $FilterXPath

$Logons = foreach ($LogonEvent in $LogonEvents)
[PSCustomObject]@
LogonDate = $LogonEvent.TimeCreated
UserName = $LogonEvent.Properties[5].Value
UserDomain = $LogonEvent.Properties[6].Value
LogonType = $LogonEvent.Properties[8].Value



$LogonsGroupedByUserName = $Logons | Group-Object -Property UserName

foreach ($Group in $LogonsGroupedByUserName)
$Group.Group





share|improve this answer

























  • Thanks for the info. It does not really help me in this case since the Atttribute I am using is the LastLogonTimestamp (which is replicated). On the other hand, I only have one Domain controller which is also the file server. My problems really is the fact that the users that simply access the network drives do not seem to be updating this parameter. Most users use a local windows user but when they access the share they need to identify themselves using the AD user (I know .. this is something we should change... )

    – Oriol de los Santos
    Mar 23 at 19:05












  • Right, I didn't notice you are using LogonTimeStamp in your query. I updated my answer.

    – vrdse
    Mar 24 at 9:15











  • Thanks. I had to make a change into the FilterXpath line definition because it did not take it as is. I simply removed the TimeCreated restriction and left it as: $FilterXPath = '*[System[EventID=4624]]'

    – Oriol de los Santos
    Mar 25 at 12:15















0














You file share access creates a Network Logon (Logon Type 3) which doesn't affect the LastLogon attribute (and LastLogonTimestamp respectively). In this case you will have to obtain the information from the Domain Controllers event log, where all logons are logged. The following script will output the last logon date of any user with its logon type of the last 24h.



#86400000 = 24h
$FilterXPath = '*[System[EventID=4624 and TimeCreated[timediff(@SystemTime) <= 86400000]]]'
$LogonEvents = Get-WinEvent -LogName Security -FilterXPath $FilterXPath

$Logons = foreach ($LogonEvent in $LogonEvents)
[PSCustomObject]@
LogonDate = $LogonEvent.TimeCreated
UserName = $LogonEvent.Properties[5].Value
UserDomain = $LogonEvent.Properties[6].Value
LogonType = $LogonEvent.Properties[8].Value



$LogonsGroupedByUserName = $Logons | Group-Object -Property UserName

foreach ($Group in $LogonsGroupedByUserName)
$Group.Group





share|improve this answer

























  • Thanks for the info. It does not really help me in this case since the Atttribute I am using is the LastLogonTimestamp (which is replicated). On the other hand, I only have one Domain controller which is also the file server. My problems really is the fact that the users that simply access the network drives do not seem to be updating this parameter. Most users use a local windows user but when they access the share they need to identify themselves using the AD user (I know .. this is something we should change... )

    – Oriol de los Santos
    Mar 23 at 19:05












  • Right, I didn't notice you are using LogonTimeStamp in your query. I updated my answer.

    – vrdse
    Mar 24 at 9:15











  • Thanks. I had to make a change into the FilterXpath line definition because it did not take it as is. I simply removed the TimeCreated restriction and left it as: $FilterXPath = '*[System[EventID=4624]]'

    – Oriol de los Santos
    Mar 25 at 12:15













0












0








0







You file share access creates a Network Logon (Logon Type 3) which doesn't affect the LastLogon attribute (and LastLogonTimestamp respectively). In this case you will have to obtain the information from the Domain Controllers event log, where all logons are logged. The following script will output the last logon date of any user with its logon type of the last 24h.



#86400000 = 24h
$FilterXPath = '*[System[EventID=4624 and TimeCreated[timediff(@SystemTime) <= 86400000]]]'
$LogonEvents = Get-WinEvent -LogName Security -FilterXPath $FilterXPath

$Logons = foreach ($LogonEvent in $LogonEvents)
[PSCustomObject]@
LogonDate = $LogonEvent.TimeCreated
UserName = $LogonEvent.Properties[5].Value
UserDomain = $LogonEvent.Properties[6].Value
LogonType = $LogonEvent.Properties[8].Value



$LogonsGroupedByUserName = $Logons | Group-Object -Property UserName

foreach ($Group in $LogonsGroupedByUserName)
$Group.Group





share|improve this answer















You file share access creates a Network Logon (Logon Type 3) which doesn't affect the LastLogon attribute (and LastLogonTimestamp respectively). In this case you will have to obtain the information from the Domain Controllers event log, where all logons are logged. The following script will output the last logon date of any user with its logon type of the last 24h.



#86400000 = 24h
$FilterXPath = '*[System[EventID=4624 and TimeCreated[timediff(@SystemTime) <= 86400000]]]'
$LogonEvents = Get-WinEvent -LogName Security -FilterXPath $FilterXPath

$Logons = foreach ($LogonEvent in $LogonEvents)
[PSCustomObject]@
LogonDate = $LogonEvent.TimeCreated
UserName = $LogonEvent.Properties[5].Value
UserDomain = $LogonEvent.Properties[6].Value
LogonType = $LogonEvent.Properties[8].Value



$LogonsGroupedByUserName = $Logons | Group-Object -Property UserName

foreach ($Group in $LogonsGroupedByUserName)
$Group.Group






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 24 at 9:15

























answered Mar 22 at 17:01









vrdsevrdse

1,764214




1,764214












  • Thanks for the info. It does not really help me in this case since the Atttribute I am using is the LastLogonTimestamp (which is replicated). On the other hand, I only have one Domain controller which is also the file server. My problems really is the fact that the users that simply access the network drives do not seem to be updating this parameter. Most users use a local windows user but when they access the share they need to identify themselves using the AD user (I know .. this is something we should change... )

    – Oriol de los Santos
    Mar 23 at 19:05












  • Right, I didn't notice you are using LogonTimeStamp in your query. I updated my answer.

    – vrdse
    Mar 24 at 9:15











  • Thanks. I had to make a change into the FilterXpath line definition because it did not take it as is. I simply removed the TimeCreated restriction and left it as: $FilterXPath = '*[System[EventID=4624]]'

    – Oriol de los Santos
    Mar 25 at 12:15

















  • Thanks for the info. It does not really help me in this case since the Atttribute I am using is the LastLogonTimestamp (which is replicated). On the other hand, I only have one Domain controller which is also the file server. My problems really is the fact that the users that simply access the network drives do not seem to be updating this parameter. Most users use a local windows user but when they access the share they need to identify themselves using the AD user (I know .. this is something we should change... )

    – Oriol de los Santos
    Mar 23 at 19:05












  • Right, I didn't notice you are using LogonTimeStamp in your query. I updated my answer.

    – vrdse
    Mar 24 at 9:15











  • Thanks. I had to make a change into the FilterXpath line definition because it did not take it as is. I simply removed the TimeCreated restriction and left it as: $FilterXPath = '*[System[EventID=4624]]'

    – Oriol de los Santos
    Mar 25 at 12:15
















Thanks for the info. It does not really help me in this case since the Atttribute I am using is the LastLogonTimestamp (which is replicated). On the other hand, I only have one Domain controller which is also the file server. My problems really is the fact that the users that simply access the network drives do not seem to be updating this parameter. Most users use a local windows user but when they access the share they need to identify themselves using the AD user (I know .. this is something we should change... )

– Oriol de los Santos
Mar 23 at 19:05






Thanks for the info. It does not really help me in this case since the Atttribute I am using is the LastLogonTimestamp (which is replicated). On the other hand, I only have one Domain controller which is also the file server. My problems really is the fact that the users that simply access the network drives do not seem to be updating this parameter. Most users use a local windows user but when they access the share they need to identify themselves using the AD user (I know .. this is something we should change... )

– Oriol de los Santos
Mar 23 at 19:05














Right, I didn't notice you are using LogonTimeStamp in your query. I updated my answer.

– vrdse
Mar 24 at 9:15





Right, I didn't notice you are using LogonTimeStamp in your query. I updated my answer.

– vrdse
Mar 24 at 9:15













Thanks. I had to make a change into the FilterXpath line definition because it did not take it as is. I simply removed the TimeCreated restriction and left it as: $FilterXPath = '*[System[EventID=4624]]'

– Oriol de los Santos
Mar 25 at 12:15





Thanks. I had to make a change into the FilterXpath line definition because it did not take it as is. I simply removed the TimeCreated restriction and left it as: $FilterXPath = '*[System[EventID=4624]]'

– Oriol de los Santos
Mar 25 at 12:15



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55304329%2fhow-to-track-the-date-and-time-when-ad-users-last-accessed-mapped-a-shared-folde%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript