27 April, 2017

HOW TO IMPORT / EXPORT ActiveDirectory User List with Properties (French Characters – UTF8)

HOW TO IMPORT / EXPORT ActiveDirectory User List with Properties (French Characters – UTF8)
1- Export Users to a CSV file from an OU with the following command. (Don’t forget to “import-module ActiveDirectory” when you start PowerShell)

Get-ADUser -Filter * -SearchBase "OU=Administrateurs Systeme,OU=Utilisateurs,dc=domain,dc=com" -properties * | Export-Csv C:\AdminSysteme.csv -Encoding UTF8

This command will grab all users from the Administrateurs Systeme OU and Export it into a CSV file in C:\AdminSysteme.csv in UTF8 encoding for French characters.

2- Open the exported CSV file with Excel. Remove the first line and unused columns from the file. Save As the file and make sure you select the “Save as type” to “CSV (Comma delimited) (*.csv)”. You need to make sure that the file encoding is still UTF8. To do so, while in the “Save As” dialogue, click on “Tool”, “Web Options” and under “Encoding” make sure that the “Save this document as” is set to “Unicode UTF-8)”.  
3- Open back the same file and enter all the data you want to modify and save back the file same way as step #2!

4- Open the file in “Notepad” and without changing anything, “Save as” the file again and make sure that the encoding is UTF-8 and if it is not, save as with UTF8.

5- Now that you have all your data in a compatible CSV file. Import the user data with the following command in powershell. 

import-csv "C:\Users\user\Desktop\ADUserList\NEw folder\AdminSysteme1.csv" –Encoding UTF8 |  {Set-ADUser -Identity $_.samaccountname -Description $_.Description -StreetAddress $_.StreetAddress -City $_.City -PostalCode $_.PostalCode -Country $_.Country -Department $_.Departement -Fax $_.Fax -HomePage $_.HomePage -Office $_.Office -OfficePhone $_.OfficePhone -State $_.State -Title $_.Title} 

Known Issues!
All imported properties must be filled with values!
If you have an error of this kind while importing back the csv file;

PS C:\Windows\system32> C:\Users\user\Desktop\ADUserList\New folder\Untitled2.ps1
Set-ADUser : replace
At C:\Users\kelmas\Desktop\ADUserList\New folder\Untitled2.ps1:1 char:104
+ ...  | ForEach {Set-ADUser -Identity $_.samaccountname -Description $_.De ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (calexandre:ADUser) [Set-ADUser], ADInvalidOperationException
    + FullyQualifiedErrorId : ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.SetADUser

Either not all the fields are filled in or the CSV file is not compatible (Comma delimited?, UTF8?)

08 April, 2017

Server 2016 - PerfNet Application Error Event ID 2006

Server 2016 is out and although it's still a baby, I've decided to slowly put it in production as a secondary storage/backup server. I was testing on a Dell PowerEdge T320 server with 10GB & 1GB nics and other than some iscsi configuration, everything else was at default settings on the system. Please note that this is a physical machine and not a VM!

Server 2016 is great and I have to admit, the experience has been really good so far... I'm sharing one of the difficult issues I had