17 May 2013

User's picture in active directory



To import the picture:

Import-RecipientDataProperty -Identity marius.dumitru -Picture -FileData ([Byte[]]$(Get-Content -Path "C:\tmp\user.jpg" -Encoding Byte -ReadCount 0))


To remove the picture:

Set-Mailbox samAccountName -RemovePicture

16 May 2013

Compare 2 text files


fc.exe can be use to compare 2 files; can use binary or ASCII to compare files;

C:\>fc /?
Compares two files or sets of files and displays the differences between them

Ex: fc file1.txt file2.txt


10 May 2013

Search for inactive active directory accounts

i found a neat cmdlet that can retrieve inactive, disabled, expired or expiring active directory accounts;

full details about the command can be found on technet;

pay attention to the "-TimeSpan" argument - if you do not use the correct /accepted formatting the search will return wrong objects;



Search-ADAccount -AccountInactive -UsersOnly -SearchBase 'OU=Users,DC=domain,DC=intra' -TimeSpan 90.00:00:00.0 | Select-Object name, lastlogondate