Hi,
I have a script with read-host to find users in AD, but i want to change it so it shows more information about the user and the computername he or she works with.
What i like to do is:
1: search with the last name of the user instead of the username
2: getting the desired information of the searched user at 1 (already in the script Get-ADUser)
3: getting the computer name of the user (the pc has the name of the user in the description like this: Doe, J (John)
4: show a txt file with information of the user and the name of the computer (info about the user is already in the script invoke-item)
The hard part for me is combining get-aduser and get-adcomputer.
I searched and tried, but i'm new to powershell and was not able to do this.
I think the easiest way to work this out is to search the last name in the description of the computer and using that to get the user information (as you see in the script at get-ADUser
the code:
$name = Read-Host -Prompt "Please enter the login name of the user"
Get-ADUser $name -Properties * | Select CN, SamAccountName, Title, DisplayName, EmployeeNumber, Department, EmailAddress, telephoneNumber, HomeDirectory, ProfilePath, AccountExpirationDate, LastLogonDate, LockedOut,
PasswordExpired, PasswordLastSet > "C:\LOGTEST\User.txt"
Invoke-Item "C:\LOGTEST\User.txt"
Write-Host "Your user information is now on your screen" -ForegroundColor Green
Log ("Check user information about $name")
Sleep -Seconds 5
$name = ""
Thank you