Jump to content

Chris Carter

Members
  • Posts

    2
  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    Chris Carter reacted to Continu IT Solutions in Add domain\username to header search on username   
    I found a powershell script that will update the computer name to do just this elsewhere on this forums (and for the life of me I cannot find it now to give the author credit). that creates the info just like my mockup.
    I modified it slightly from the original but here is the code I use:
    $lastlogon = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser") $hostname = hostname $installtype = (New-Object -ComObject WScript.Shell).RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\InstallationType") $pos = $lastlogon.IndexOf("\") $leftPart = $lastlogon.Substring(0, $pos) $lastlogonusername = $lastlogon.Substring($pos+1) if ($installtype -eq "Server") { Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name ComputerName -Value $hostname , "/" , $leftPart }else { Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name ComputerName -Value $hostname , " - " , $leftPart , "\" , $lastlogonusername } Saved this as a script named Update Computername with User
    Then i set the computers to notify when user logs in as a low level notification
    then i created a workflow that triggers off that low level alert, runs this script, then deletes the notification and marks the workflow as a success

    Now i can search on username and it works!
×
×
  • Create New...