ADScripts/FindUsersWithoutTitleOrPhone.ps1
2023-09-14 11:13:58 -06:00

20 lines
682 B
PowerShell

Import-Module ActiveDirectory
<#Get a list of all users that do not have a job title or phone number assigned to them.#>
if(!$creds){
$creds = Get-Credential
}
$list = Get-ADUser -Credential $creds -server lbdc01.mpe.ca -SearchBase "OU=MPEUsers,DC=mpe,DC=ca " -Filter * -Properties telephoneNumber,title,DisplayName
$newList = @()
foreach($person in $list){
if(!$person.telephoneNumber -or !$person.title){
$personObject = [PSCustomObject]@{
"Name"=$person.DisplayName
"Title"=$person.title
"Phone"=$person.telephoneNumber
}
$newList += $personObject
}
}
$newList | export-csv -path .\UsersWOPhoneOrTitle.csv