Hi guys,
I'm using the following that i've cobbled together for helpdesk to get info on account lockouts... what I'm not too sure about is that when it outputs a specific servername (as 'Client Name'), i.e. OURISASERVER - I want it to replace that field with "Mobile Device"... I'm just not too sure how to do that in the following, can someone help at all?
(I've converted this to .exe with ps2exe so the password in it shouldn't be a problem as they can't see the code)
$Admin = "admindomain\adminaccount"
$Password = convertto-securestring "adminpwd" -asplaintext -force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $Admin, $Password
$user = Read-Host "Please enter User Name to look for?"
Write-Host "Searching, Please Wait..." -foregroundcolor "green"
Get-WinEvent -Credential $cred -Logname 'Security' `
-FilterXPath "*[System[EventID=4740] and EventData[Data[@Name='TargetUserName']='$User']]" `
-ComputerName PDCDomainController | `
Select-Object TimeCreated,@{Label='User Name';Expression={$_.Properties[0].Value}},@{Label='Client Name';Expression={$_.Properties[1].Value}}
Write-Host
Write-Host "Complete!" -foregroundcolor "green"
Write-Host
Write-Host Press Any Key to Quit... -foregroundcolor "Yellow"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
I'm using the following that i've cobbled together for helpdesk to get info on account lockouts... what I'm not too sure about is that when it outputs a specific servername (as 'Client Name'), i.e. OURISASERVER - I want it to replace that field with "Mobile Device"... I'm just not too sure how to do that in the following, can someone help at all?
(I've converted this to .exe with ps2exe so the password in it shouldn't be a problem as they can't see the code)
$Admin = "admindomain\adminaccount"
$Password = convertto-securestring "adminpwd" -asplaintext -force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $Admin, $Password
$user = Read-Host "Please enter User Name to look for?"
Write-Host "Searching, Please Wait..." -foregroundcolor "green"
Get-WinEvent -Credential $cred -Logname 'Security' `
-FilterXPath "*[System[EventID=4740] and EventData[Data[@Name='TargetUserName']='$User']]" `
-ComputerName PDCDomainController | `
Select-Object TimeCreated,@{Label='User Name';Expression={$_.Properties[0].Value}},@{Label='Client Name';Expression={$_.Properties[1].Value}}
Write-Host
Write-Host "Complete!" -foregroundcolor "green"
Write-Host
Write-Host Press Any Key to Quit... -foregroundcolor "Yellow"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")