Hello @Sathishkumar Singh , here's how to get the information. You'll then have to decide on the method to send the email, depending on what's available in your organization.
$Last24h = (Get-Date).AddHours(-24)
$Users = Get-ADUser -Filter { whencreated -ge $Last24h } -Properties mail, Name, GivenName, Surname, Office, telephoneNumber, manager, Department
$output = foreach ($user in $users) {
$manager = $null
if ($null -ne $user.manager) {
$manager = Get-ADUser $user.Manager -Properties Name, mail
}
[PSCustomObject] @{
Email = $user.mail
Name = $user.Name
'First Name' = $user.GivenName
'Last Name' = $user.Surname
Location = $user.Office
'Phone Number' = $user.telephoneNumber
'Manager Name' = $manager.Name
'Manager Email' = $manager.mail
Department = $user.Department
}
}
$output | Export-Csv -Path 'C:\scripts\Data.csv'
If this or any other reply helped solve your question, please remember to upvote and/or "Accept Answer". It helps others facing similar issues find the solution.