Remediating extension attributes

From MyWiki
Revision as of 11:15, 27 August 2014 by George2 (Talk | contribs)

Jump to: navigation, search

Step 1, generate a list of potential problem accounts
Get a list of users to check for the correct configuration of the ExtensionAtribute1 and ExtensionAtribute2 attributes
We can user serveral commands depending on the desired selection criteria, examples below:
List users created on a particular day: Get-QADUser -CreatedOn 2014/07/26 > user_list.txt
List users created within a date range Get-QADUser -CreatedAfter 2014/07/26 -CreatedBefore 2014/07/30 > user_list.txt
You will need to open the text file in and editor to remove the column headers and blank lines at the top, and any blank lines at the bottom
Step 2, run the script below taking the file generated above as its input
It is assumed that we have the Quest cmdlets installed and loaded and that we are logged into a Domain Controller with appropriate credentails


function FileSize3 ($dir)                                                                                                                                                                    
{                                                                                                                                                                                            
 
Write-Host " WE need to create the attributes for user $dir "                                                                                                                                
$its_user = $mail_attr.Split('@')[0]                                                                                                                                                         
write-host "The proposed ext1 is $its_user"                                                                                                                                                  
write-host "The proposed ext2 is $office_attr"                                                                                                                                               
write-host "Ready to configure the extension attributes for user $roy"                                                                                                                       
#Get-QADUser $roy                                                                                                                                                                            
#Get-QADUser $roy                                                                                                                                                                            
Get-QADUser $roy | Set-QADUser -objectAttributes @{extensionAttribute1=$its_user}                                                                                                            
Get-QADUser $roy | Set-QADUser -objectAttributes @{extensionAttribute2=$office_attr}                                                                                                         
 
 
}                                                                                                                                                                                            
 
 
$lines=Get-Content testfile                                                                                                                                                                  
    $lines |                                                                                                                                                                                 
     ForEach-Object{                                                                                                                                                                         
         $roy =   $_.Split(' ')[0]                                                                                                                                                           
        $ray = get-qaduser $roy -includeallproperties                                                                                                                                        
        $the_uid = $ray.uid                                                                                                                                                                  
        $mail_attr = $ray.mail                                                                                                                                                               
        $office_attr = $ray.Office                                                                                                                                                           
        $the_uid_length = $ray.uid.length                                                                                                                                                    
        $ext_length = $ray.extensionattribute1.length                                                                                                                                        
        $bog = $ray.extensionattribute1                                                                                                                                                      
        $nog = $ray.extensionattribute2                                                                                                                                                      
        Write-host "Username is $roy : uid is $the_uid : uid lenght is $the_uid_length : ext1 length is $ext_length : ext1 attribute is $bog : ext2 is $nog  "                               
if ($ray.extensionattribute1.length -lt 2)                                                                                                                                                   
{                                                                                                                                                                                            
        Filesize3($roy)                                                                                                                                                                      
 
}                                                                                                                                                                                            
else                                                                                                                                                                                         
{                                                                                                                                                                                            
Write-host "User $roy has the ExtensionAttribute1 popupated with the value $bog "                                                                                                            
}                                                                                                                                                                                            
}