Logon Scripts

Guy recommends:
A free trial of
WebHelpDesk

Solarwinds Free WebHelpDesk

Install a ticket-based help desk system from SolarWinds. Download your free trial

CSVDE - Switches (Parameters)

Introduction to CSVDE Switches

With an Active Directory import or export, the spreadsheet should be your focus.  Surprisingly, CSVDE and its switches only play a minor part in the data exchange.  My point is that with other Windows executables like Isinteg or NTDSUTIL you cannot learn enough about their switches.  However, you can become an expert in CSVDE with just a passing acquaintance with these 6 switches: -d, -f, -i, -k, -l, and -r.  As I keep saying, the real work is done in the Excel spreadsheet, especially with an import into Active Directory.

CSVDE Topics

 ♦

CSVDE Beginners Mistake to Avoid

A beginners mistake with CSVDE, is to put a space between the minus sign and the switch:
CSVDE -  f Newport.csv, is wrong.   That gap or space is wrong -   f
CSVDE -f  Newport.csv, is correct.   No gap is correct -f

List of CSVDE Switches

If you take my advice, just concentrate on these 6 CSVDE switches: -d,  -f,  -i, -k, -l and -r

-a and -b UserDistinguishedName Password.  If you must use these switches, then treat  -a and -b as a pair.  A likely scenario is that you are logged on as non-administrator and wish to run CSVDE against your Active Directory.  As a non-administrator, you would get an error unless you employ these switches to connect with the correct credentials.

-c String1 String2.  This switch replaces all olddomain names in String1 with newdomain names String2.  Could be used to change all dc=oldom distinguished name in the export domain (String1) with dc=newdom of the import domain (String2). 

Guy's advice is to ignore the -c switch and make all such find and replace changes in the spreadsheet before you create the import CSV file.

-d  This is useful filter switch for when you want to export from just one OU.  Use the -d switch to set the root directory for the export.  For example, if you are only interested in an OU called Newport type, CSVDE -f Newport1.csv -d "OU=Newport,DC=cp,DC=com".  Note, there are no spaces between cp,DC=com.

-f filename is a mandatory switch for both import and export.  Simply specify the .csv file for transfer data.  It makes life easier if this file is in the same directory as you issue the CSVDE command.  Here is an export example CSVDE -f Newport.csv

-g Omits paged searches.   I have never bothered with this switch.

-i  Switches CSVDE to import mode.  For example, CSVDE -i -f Newport.csv.  Remember that the default mode is export, in which case it's just plain CSVDE -f FileName.csv

-j Path Sets the log file directory.  The point of a log file is that it's permanent where as the -v verbose mode is ephemeral.  -j creates one or two log files.  It always creates a file called csv.log, additionally it creates csv.err if it encounters any errors.

-j Trap: As far as I can see without the -j switch, CSVDE will not create a log file at all.  I mention this as other documentation suggests that you are just setting the path, in my opinion, with -j you are creating the file as well as setting its path.

-k Useful for ignoring simple errors: "Object already exists," "Constraint violation," and "Attribute or value already exists."  I almost always use this switch as part of the CSVDE import command.

Guy Recommends:  SolarWinds' Free Bulk Import ToolFree Download Solarwinds Bulk Import Tool

Import users from a spreadsheet.  Just provide a list of the users with their fields in the top row, and save as .csv file.  Then launch this FREE utility and match your fields with AD's attributes, click and import the users.

Optionally, you can provide the name of the OU where the new accounts will be born. Download your FREE bulk import tool.

If you need more comprehensive software, download a free trial of SAM (Server & Application Monitor)

-l(L) LDAP Attributes.   On the one hand, I think of L for list, on the other hand I think of -l as a column-wise filter.  What this switch does is export only the LDAP properties that you are interested in and ignores the rest of the attributes.  Example CSVDE -f Newport5.csv  -l "DN, objectclass, objectcategory, givenName, sn".  Note the position of speech marks and commas.

-m Another column-wise filter.  Omits Active Directory properties such as the ObjectGUID, objectSID, pwdLastSet and samAccountType attributes.

-n Omits export of binary values.

-o LDAPAttributeList.  Think of -o as omit.  This is probably the least useful of the 4 export filters.  In many cases the exclusion list would be so long that it is better to be positive and just include the fields ou want with -L.  Not a switch I use.

-p Scope.  Useful for highly nested OUS. Sets the search scope. Options are Base, OneLevel, or SubTree.  The default is SubTree meaning all Active Directory Information. Example, CSVDE -f Newportonel.csv -p onelevel, would limit the output to one level of OUs.

-r Filters on LDAP properties.  Very useful on Exports (not needed on imports).  I think of the -r as a row-wise filter example: CSVDE -f Newport4.csv -r  objectClass=user.  This would filter out rows with OUs and other objects that I am not interested in.  See also -L filter.

-s Domain Controller.  If you are on member server or XP machine then you need to add this switch to your CSVDE import or export command.  Example CSVDE -i -f Newport.csv -s BigServer

-t PortNumber  Specifies an LDAP port number. The default LDAP port is 389. The global catalog port is 3268.  The only point of this switch is if you use non-standard LDAP ports.

-v Sets verbose mode.  Normally -v gives too much information, so I confine its use to investigating why a filter did, or did not, produce the effect I wanted.  For example, CSVDE -f Newport9.csv - d "OU=Newport,dc=cp,dc=com" -v.

Recommended: Solarwinds' Permissions Analyzer - Free Active Directory ToolFree Permissions Analyzer for Active Directory

I like the Permissions Analyzer because it enables me to see WHO has permissions to do WHAT at a glance.  When you launch this tool it analyzes a users effective NTFS permissions for a specific file or folder, and takes into account network share access, then displays the results in a nifty desktop dashboard!

Think of all the frustration that this free SolarWinds utility saves when you are troubleshooting authorization problems for user's access to a resource.  Give this permissions monitor a try - it's free!

Download SolarWinds' Free Permissions Analyser - Active Directory Tool

More CSVDE Logic: and (&) or (|)

John H. Mason wrote in with a solution to logic problem that he was having with CSVDE export.  John's mission was to export all user accounts from Active Directory, which were disabled.  Research indicated that he needed to filter on userAccountControl values of 514, or 546 or 66050.

He wanted a command which would say: 'Export all accounts with a userAccountControl value of 514, or 546 or 66050'.  One solution would have been to run the command three times, however, John came up with this elegant application of the pipe symbol (|) meaning 'or'.

CSVDE 'or' (|) Example

csvde -f c:\AllDisabled.csv -r "(|(useraccountcontrol=514)(useraccountcontrol=546)(useraccountcontrol=66050))" -l "DN, objectclass, objectcategory, sn, givenName, sAMAccountName, useraccountcontrol"

Incidentally, this pipe symbol (|) is asci 124.  If you are having trouble finding the key, then hold down the Alt Key and type 124 on the numeric keyboard, then let go of the alt key, the result will be: |

CSVDE 'and' (&) Example

CSVDE -f export.csv -r "(&(objectClass=user)(sn=Thomas))"

 

If you like this page then please share it with your friends

 


See Also

 *


Custom Search

Site Home

Guy Recommends: WMI Monitor for PowershellSolarwinds WMI Monitor

Windows Management Instrumentation (WMI) is most useful for PowerShell scripting.

SolarWinds have produced this Free WMI Monitor to take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

Author: Guy Thomas Copyright © 1999-2017 Computer Performance LTD All rights reserved.

Please report a broken link, or an error to:

If you like this page then please share it with your friends