Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

modify user objects across trusted domains

$
0
0

we get a report from HR that makes changes to managers etc.   there are 2 domains in our company with a trust between them.  of course if the user is in the domain that the script is not run from then it errs out.  i did try a few things as you see they are commented out - stuck here...unless I do some kind of if location is CA then do XXXX

Question is how can I make modifications of users across multiple domains?  the command set-adserversettings -viewentireforest $true isn't finding the user.  how can i make is see the other trusted domain.

 

$userobjects=import-csv "C:\hold\_powershell\setaduser kronos\mpan.csv" -Header ("EMPK_LOGON", "mgrk_logon","EMP_LOC","EMP_EMAIL","EMPNO","PERSONIDNO","FIRSTNAME","MI","LASTNAME","EMPLOYEESTATUS","EXEMPT_STAT","HIREDATE","JOBCODE","POSITIONCODE","POSITION","POSITIONDESC","COSTCENTER","POSITION_REASON","SUPERVISORIDNO","MGR_NO","MGR_FIRSTNAME","MGR_MI","MGR_LASTNAME","MGR_EMP_STATUS","MGR_JOBCODE","POSTIONCODE","MGR_POSITIONDESC","MGR_LOC")

#Set-AdServerSettings -ViewEntireForest $True
#$AdminSessionADSettings.ViewEntireForest = $True
ForEach ( $userobject in $userobjects ) {
#Assign the content to variables
$FileUsername = $userobject.empk_logon
$Fileposition = $userobject.position
$filemgr = $userobject."mgrk_logon"

# Output the content to the screen
Write-Host $FileuserName title is $Fileposition and mgr is $filemgr
Set-ADUser $FileUsername -Manager $filemgr -Title $fileposition
}


Viewing all articles
Browse latest Browse all 10624

Trending Articles