Hi Guys,
I need your help. I need powershell script to get login attempt report into csv file. is there any script ?
Thanks in advanced
I have made this script but i don't know where and what am i missing in this script, It is not working:-
#> Param( [array]$ServersToQuery = (hostname), [datetime]$StartTime = "January 1, 1970" ) foreach ($Server in $ServersToQuery) { $LogFilter = @{ LogName = 'Security' ID = 4625, 644, 681, 529 StartTime = $StartTime } $AllEntries = Get-WinEvent -LogName "Security" -FilterHashtable $LogFilter -ComputerName $Server $AllEntries | Foreach { $entry = [xml]$_.ToXml() [array]$Output += New-Object PSObject -Property @{ TimeCreated = $_.TimeCreated Computer = $entry.Event.EventData.SubjectUserName User = $entry.Event.EventData.TargetDomainName logontype = $entry.Event.EventData.LogonType IPAddress = $entry.Event.EventData.IpAddress EventID = $entry.Event.System.EventID ServerName = $Server } } } $FilteredOutput += $Output | Select TimeCreated, Computer, User, logontype, IPAddress, ServerName @{Name='Action';Expression={ if ($_.EventID -eq '4625'){"Unknown user name or Bad password"} if ($_.EventID -eq '529'){"Unknown user name or Bad password"} if ($_.EventID -eq '644'){"User Account Locked Out"} if ($_.EventID -eq '681'){"The logon to account: %2 by: %1 from workstation: %3 failed"} } } $FilePath = "$env:C:\RDP_Report.csv" $FilteredOutput | Sort TimeCreated | Export-Csv $FilePath -NoTypeInformation Write-host "Writing File: $FilePath" -ForegroundColor Cyan Write-host "Done!" -ForegroundColor Cyan #End
When i run this script it is giving following error:-
I am not good in powershell. it is just copy from another script, and edit the event log and other information.
Original script is here :-
https://gallery.technet.microsoft.com/scriptcenter/Remote-Desktop-Connection-3fe225cd