Solved

How to include the date in the DSGET command output file

Posted on 2009-05-12
7
448 Views
Last Modified: 2013-12-24
Hi Experts,

How could I include the date information (mmddyyy: i.e 05242009) in the output file I create with my script that already runs a DSGET to list all members in an AD group?

Thanks in advance.

0
Comment
Question by:HUSATech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 4

Expert Comment

by:delyan_valchev
ID: 24368760
Simple version if you have the date command output formatted as dd/mm/yyyy or dd.mm.yyyy. If date /t outputs in mm/dd/yyyy or mm.dd.yyyy you can switch the places of Day and Month variables. then you can use %Day%Month%Year in the dsget's output.
Hope it helps
for /F "tokens=1-4 delims=/. " %%i in ('date /t') do (
     set Day=%%i
     set Month=%%j
     set Year=%%k
  ) 

Open in new window

0
 
LVL 4

Expert Comment

by:delyan_valchev
ID: 24368815
Here is international-independent version which runs on 2003/XP and up. You can get the time as well.

FOR /F "skip=2 tokens=2-7 delims=," %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:csv') DO (
	SET Day=%%A
	SET Hour=%%B
	SET Minute=%%C
	SET Month=%%D
	SET Second=%%A
	SET Year=%%F
)

Open in new window

0
 

Author Comment

by:HUSATech
ID: 24369116
Hey thanks a lot for the quick answer, but let me ask you this: should I embed this in my batch file where I run the dsget? How should I use it?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 4

Accepted Solution

by:
delyan_valchev earned 50 total points
ID: 24369699
Just put it in the beginning of the batch file like the example below. Based on your question, I assume you have US regional settings (mm/dd/yyyy) so I edited a bit the first version.
Hope it helps!
@echo off
for /F "tokens=1-4 delims=/. " %%i in ('date /t') do (
     set Month=%%i
     set Day=%%j
     set Year=%%k
  ) 
set FileDate=%Month%%Day%%Year%
 
dsquery user -name SomeUser | dsget user -memberof > SomeUserMembership_%FileDate%.txt

Open in new window

0
 

Author Comment

by:HUSATech
ID: 24369884
Great, worked as expected. Thanks a lot.
0
 

Author Closing Comment

by:HUSATech
ID: 31580708
Thanks again, quick and easy to implement.
0
 
LVL 4

Expert Comment

by:delyan_valchev
ID: 24380217
The "international" version has a typo. Here is the correct one:
FOR /F "skip=2 tokens=2-7 delims=," %%A IN ('WMIC Path Win32_LocalTime Get Day^,Hour^,Minute^,Month^,Second^,Year /Format:csv') DO (
        SET Day=%%A
        SET Hour=%%B
        SET Minute=%%C
        SET Month=%%D
        SET Second=%%E
        SET Year=%%F
)

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question