Show AD user and manager details

This script displays a user’s Name, Company, Title, Office, Office Phone Number, Mobile Phone Number and E-Mail Address if they exist in AD, as well as those same details for their Manager. _x000A__x000A_Requires the ActiveDirectory PowerShell module loaded on machine this is be exected from. _x000A__x000A_Created by Rory Monaghan.

Version: 1.1.7
Created: 2018-11-26T11:34:50.73
Modified: 2018-11-27T17:20:37.857
Creator: Rory.Monaghan
Downloads: 124
Tags:
The Script Copy Script Copied to clipboard

<# .DESCRIPTION This script displays a users Name, Company, Title, Office, Office Phone Number, Mobile Phone Number and E-Mail Address, as well as those same details for their Manager. Created by Rory Monaghan. .PARAMETER User Specifies an Active Directory user object provided through a ControlUp Argument #>

$user=$args[0].split(“”)[1]
write-host $user

$ErrorActionPreference = “Stop”

If ( (Get-Module -Name ActiveDirectory -ErrorAction SilentlyContinue) -eq $null )
{
Try {
Import-Module ActiveDirectory
} Catch {
Write-Error “Unable to load the module” -ErrorAction Continue
Write-Error $Error[1] -ErrorAction Continue
Exit 1
}
}

Try {
$managerfirstname=(get-aduser (get-aduser $user -Properties manager).manager).GivenName
$managerlastname=(get-aduser (get-aduser $user -Properties manager).manager).SurName
$manageraccname=(get-aduser (get-aduser $user -Properties manager).manager).samaccountName

Get-AdUser -Identity $user -Properties * | Select GivenName,Surname,Department,Title,Company,mail,telephoneNumber,MobilePhone,Office
write-host “Reporing Manager is $managerfirstname $managerlastname : ”
Get-AdUser -Identity $manageraccname -Properties * | Select GivenName,Surname,Department,Title,Company,mail,telephoneNumber,MobilePhone,Office

} Catch {
Write-Error $Error[0] -ErrorAction Continue
Exit 1
}

START YOUR TRIAL

Get Your Download Link

Gain access to ControlUp from your PC. Register and get a link to start your Free Trial.