ADScripts/Update-UserManagers.ps1

22 lines
924 B
PowerShell
Raw Permalink Normal View History

2023-09-14 11:13:58 -06:00
<#
Script tp update the user manager field based on a CSV / Output from somewhere.
Erik Eckert - MPE Engineering - 2022
Modules:
- ActiveDirectory
- ImportExcel - As Admin - Install-Module -Name ImportExcel -force
#>
Import-Module ImportExcel
Import-Module ActiveDirectory
$users = get-aduser -Filter 'mail -like "*@mpe.ca" -and Enabled -eq $true' -SearchBase 'OU=MPEUsers,DC=mpe,DC=ca' -Properties manager,company,department,title,Office,extensionAttribute1
$MPEData = Import-Excel -Path 'I:\Admin\Employee Designation & Title Listing\MPE Staff Info.All Offices.xlsx' -WorksheetName 'Sheet1' -StartColumn 2 -EndColumn 7 | where 'Last Name' -NE $null
# Org Chart is full of "dotted line" or "Contextual" reporting structures.
# Should probably default to office Manager for the office, then tier down for people with a clear path in the existing Org Chart.
# need to come up with a CSV format to import.