I want to get this report because, sometime we must know that pc always use local user or their domain user. So, if i can grab this information from Active Directory, i can give it to user and tell them to use their domain user. User complain to us that they cannot access folder sharing on server because they only use their local user.
I search on internet and i found this from netwrix.com
I search on internet and i found this from netwrix.com
- Open Powershell ISE.
- Create a new script with the following code (Define "domain" and "export-csv" fields):
$Domain = "na.local"
$InactiveFor = 0
$Time = (Get-Date).Adddays(-($InactiveFor))
Get-ADUser -Filter {LastLogonTimeStamp -lt $Time -and enabled -eq $true} -Properties LastLogonTimeStamp |
select-object Name,@{Name="Stamp";
Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp).ToString('yyyy-MM-dd_hh:mm:ss')}} | export-csv C:\temp\lastlogon.csv –notypeinformation - Run the script.
- Open a file produced by the script in MS Excel.
Comments
Post a Comment