Logon Scripts

 

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

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 Engineer's Toolset v10Engineer's Toolset v10

The Engineer's Toolset v10 provides a comprehensive console of utilities for troubleshooting computer problems.  Guy says it helps me monitor what's occurring on the network, and the tools teaches me more about how the system literally operates.

There are so many good gadgets, it's like having free rein of a sweetshop. Thankfully the utilities are displayed logically: monitoring, discovery, diagnostic, and Cisco tools.  Download your copy of the Engineer's Toolset v 10

-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.

Guy Recommends: SolarWinds LANSurveyorSolarwinds LANSurveyor

LANSurveyor will produce a neat diagram of your network topology.  But that's just the start; LANSurveyor can create an inventory of the hardware and software of your machines and network devices.  Other neat features include dynamic update for when you add new devices to your network.  I also love the ability to export the diagrams to Microsoft Visio.

Finally, Guy bets that if you take a free trial of LANSurveyor then you will find a device on your network that you had forgotten about, or someone else installed without you realizing!

Download a Free Trial of LANSurveyor

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))"

See Also

 *


Google

Web  This website

Review of Orion NPMGuy Recommends: Orion's Network Performance Monitor (NPM)

Orion NPM is designed for detecting network outages.

Network-centric views (screenshot) make it easy to see what's working, and what needs your attention.

Download your free trial of Orion's network performance monitor

 

Home Copyright © 1999-2009 Computer Performance LTD All rights reserved

Please report a broken link, or an error.


Download your eBook:  How to use CSVDE commands - only $6.25

CSVDESave hours of frustration and buy Guy's eBook.  The extra features include: detailed instructions on how to import and export user accounts, ten new pages of worked CSVDE examples.

You get a printer friendly version with copy enabled, and no expiry date.