bsharath
asked on
Find users in a group and find the created dates
Hi,
I want a scrip to find all the users in a specific group and find the users created dates in that group alone.As i need to keeps users for 3 months after the user is created in the group.So is there a way to do thse 2 tasks in 1 script.
regards
Sharath
I want a scrip to find all the users in a specific group and find the users created dates in that group alone.As i need to keeps users for 3 months after the user is created in the group.So is there a way to do thse 2 tasks in 1 script.
regards
Sharath
ASKER
Farhan
I tried When i enter the groupname it just closes in prompt without any output.
"Groupname"
Enter
Closes the screen
I tried When i enter the groupname it just closes in prompt without any output.
"Groupname"
Enter
Closes the screen
What group name did you enter?
ASKER
"Chennai-fs" is the group name
Apply following command and paste results
Click Start -> Run -> Cmd.exe
DSQuery Group -Name "Chennai-fs"
Click Start -> Run -> Cmd.exe
DSQuery Group -Name "Chennai-fs"
ASKER
No output.
These groups are in the root domain....
These groups are in the root domain....
ASKER
I have tried for the local groups a file is created "WhenCreatedRpt.Txt" but no data inside...
What local group name did you type? Type that group name in following command and post results.
DSQuery Group -Name "GroupName"
^--------------- Group Name here
DSQuery Group -Name "GroupName"
^--------------- Group Name here
ASKER
I have tried with a local group.
Chennai_FS-SG
It shows the Ou path
The same when i try with the .cmd file it creates a file but no data in it.
Chennai_FS-SG
It shows the Ou path
The same when i try with the .cmd file it creates a file but no data in it.
Can you plz post the output of following:
DSQuery Group -Name "Chennai_FS-SG"
DSQuery Group -Name "Chennai_FS-SG"
ASKER
C:\>DSQuery Group -Name "Chennai_FS-SG"
"CN=Chennai_FS-SG,OU=Secur ity Groups,OU=IND,OU=Countries ,DC=Develo pment,DC=G roup,DC=co ,DC=uk"
"CN=Chennai_FS-SG,OU=Secur
Did you try this script with "Chennai_FS-SG" group name? and also try with "CN=Chennai_FS-SG,OU=Secur ity Groups,OU=IND,OU=Countries ,DC=Develo pment,DC=G roup,DC=co ,DC=uk"
ASKER
Farhan for both the file is created but no data to the file.
This is a security group....
I tried with many groups and many machines same thing happens.File gets created but no data.
This is a security group....
I tried with many groups and many machines same thing happens.File gets created but no data.
ASKER
Post results of following script.
:: Copy and Paste below code in notepad and save it with any name having .cmd extension.
:: SCRIPT START
@Echo Off
SET /P GroupDN=Enter Group Name or DN (enclosed in double quotes):
IF [%GroupDN%]==[] Echo No Group specified&&Goto :EndScript
Echo %GroupDN% |FIND /I "CN=" >NUL
IF NOT ERRORLEVEL 1 (
DSQuery Group %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
) ELSE (
DSQuery Group -Name %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
DSQuery Group -Name %GroupDN% >GroupDN.tmp
SET /p GroupDN=<GroupDN.tmp
DEL /f /q GroupDN.tmp)
Echo.
Echo Group Name: %GroupDN%
Echo %GroupDN%
Echo.
Echo Members:
DSGet Group %GroupDN% -members
:EndScript
:: SCRIPT END
:: Copy and Paste below code in notepad and save it with any name having .cmd extension.
:: SCRIPT START
@Echo Off
SET /P GroupDN=Enter Group Name or DN (enclosed in double quotes):
IF [%GroupDN%]==[] Echo No Group specified&&Goto :EndScript
Echo %GroupDN% |FIND /I "CN=" >NUL
IF NOT ERRORLEVEL 1 (
DSQuery Group %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
) ELSE (
DSQuery Group -Name %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
DSQuery Group -Name %GroupDN% >GroupDN.tmp
SET /p GroupDN=<GroupDN.tmp
DEL /f /q GroupDN.tmp)
Echo.
Echo Group Name: %GroupDN%
Echo %GroupDN%
Echo.
Echo Members:
DSGet Group %GroupDN% -members
:EndScript
:: SCRIPT END
ASKER
Farhan i get this.
Enter Group Name or DN (enclosed in double quotes): "chennai_fs-sg"
Group Name: "CN=Chennai_FS-SG,OU=Secur ity Groups,OU=IND,OU=Countries ,DC=Develo pm
ent,DC=Group,DC=co,DC=uk"
"CN=Chennai_FS-SG,OU=Secur ity Groups,OU=IND,OU=Countries ,DC=Develo pment,DC=
Group,DC=co,DC=uk"
Members:
"CN=Fer,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri es,DC=dev
,DC=Group,DC=co,DC=uk"
"CN=Mj kumar,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri es,DC=dev
pment,DC=Group,DC=co,DC=uk "
"CN=Rh k. Kannan,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri es,DC=D
evelopment,DC=Group,DC=co, DC=uk"
"CN=Man Kay,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
es,DC=dev,DC=Group,DC=co,D C=uk"
"CN=Vpal Ke,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri es,DC=D
evelopment,DC=Group,DC=co, DC=uk"
"CN=Smar Ye,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri es,D
C=dev,DC=Group,DC=co,DC=uk "
"CN=Biri,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri es,DC=Deve l
opment,DC=Group,DC=co,DC=u k"
"CN=Ani Ku,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri es,DC=Dev
elopment,DC=Group,DC=co,DC =uk"
Press any key to continue . . .
When i try for a root group do not get anything...
<edited by SouthMod per https://www.experts-exchange.com/questions/26631502/26-Nov-10-15-Automated-Request-for-Attention-Q-22793506.html?cid=1572&anchorAnswerId=34215138#a34215138>
Enter Group Name or DN (enclosed in double quotes): "chennai_fs-sg"
Group Name: "CN=Chennai_FS-SG,OU=Secur
ent,DC=Group,DC=co,DC=uk"
"CN=Chennai_FS-SG,OU=Secur
Group,DC=co,DC=uk"
Members:
"CN=Fer,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
,DC=Group,DC=co,DC=uk"
"CN=Mj kumar,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
pment,DC=Group,DC=co,DC=uk
"CN=Rh k. Kannan,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
evelopment,DC=Group,DC=co,
"CN=Man Kay,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
es,DC=dev,DC=Group,DC=co,D
"CN=Vpal Ke,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
evelopment,DC=Group,DC=co,
"CN=Smar Ye,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
C=dev,DC=Group,DC=co,DC=uk
"CN=Biri,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
opment,DC=Group,DC=co,DC=u
"CN=Ani Ku,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
elopment,DC=Group,DC=co,DC
Press any key to continue . . .
When i try for a root group do not get anything...
<edited by SouthMod per https://www.experts-exchange.com/questions/26631502/26-Nov-10-15-Automated-Request-for-Attention-Q-22793506.html?cid=1572&anchorAnswerId=34215138#a34215138>
:: Copy and Paste below code in notepad and save it with any name having .cmd extension.
:: SCRIPT START
@Echo Off
SET /P GroupDN=Enter Group Name or DN (enclosed in double quotes):
IF [%GroupDN%]==[] Echo No Group specified&&Goto :EndScript
Echo %GroupDN% |FIND /I "CN=" >NUL
IF NOT ERRORLEVEL 1 (
DSQuery Group %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
) ELSE (
DSQuery Group -Name %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
DSQuery Group -Name %GroupDN% >GroupDN.tmp
SET /p GroupDN=<GroupDN.tmp
DEL /f /q GroupDN.tmp)
Echo.
Echo Please wait while system generate report...
Echo.
DSQuery * -Filter "(memberOf=%GroupDN%)" -Attr distinguishedName whenCreated >WhenCreatedRpt.Txt
Echo Script finish check 'WhenCreatedRpt.Txt' file.
Echo.
:EndScript
:: SCRIPT END
:: SCRIPT START
@Echo Off
SET /P GroupDN=Enter Group Name or DN (enclosed in double quotes):
IF [%GroupDN%]==[] Echo No Group specified&&Goto :EndScript
Echo %GroupDN% |FIND /I "CN=" >NUL
IF NOT ERRORLEVEL 1 (
DSQuery Group %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
) ELSE (
DSQuery Group -Name %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
DSQuery Group -Name %GroupDN% >GroupDN.tmp
SET /p GroupDN=<GroupDN.tmp
DEL /f /q GroupDN.tmp)
Echo.
Echo Please wait while system generate report...
Echo.
DSQuery * -Filter "(memberOf=%GroupDN%)" -Attr distinguishedName whenCreated >WhenCreatedRpt.Txt
Echo Script finish check 'WhenCreatedRpt.Txt' file.
Echo.
:EndScript
:: SCRIPT END
ASKER
Farhan i dont get any thing.After i enter the group name the scree just disappears...
I get this...
Enter Group Name or DN (enclosed in double quotes): "Chennai_FS-SG"
Please wait while system generate report...
dsquery failed:Value for `startnode' has incorrect format.
type dsquery /? for help.Script finish check 'WhenCreatedRpt.Txt' file.
Press any key to continue . . .
I get this...
Enter Group Name or DN (enclosed in double quotes): "Chennai_FS-SG"
Please wait while system generate report...
dsquery failed:Value for `startnode' has incorrect format.
type dsquery /? for help.Script finish check 'WhenCreatedRpt.Txt' file.
Press any key to continue . . .
:: Copy and Paste below code in notepad and save it with any name having .cmd extension.
:: SCRIPT START
@Echo Off
IF EXIST WhenCreatedRpt.Txt DEL /F /Q WhenCreatedRpt.Txt
SET /P GroupDN=Enter Group Name or DN (enclosed in double quotes):
IF [%GroupDN%]==[] Echo No Group specified&&Goto :EndScript
Echo %GroupDN% |FIND /I "CN=" >NUL
IF NOT ERRORLEVEL 1 (
DSQuery Group %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
) ELSE (
DSQuery Group -Name %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
DSQuery Group -Name %GroupDN% >GroupDN.tmp
SET /p GroupDN=<GroupDN.tmp
DEL /f /q GroupDN.tmp)
Echo.
Echo Please wait while system generate report...
Echo.
FOR /F "delims=*" %%m IN ('DSGet Group %GroupDN% -Members') DO DSQuery User %%m -disabled >>WhenCreatedRpt.Txt
Echo Script finish check 'WhenCreatedRpt.Txt' file.
Echo.
:EndScript
:: SCRIPT END
:: SCRIPT START
@Echo Off
IF EXIST WhenCreatedRpt.Txt DEL /F /Q WhenCreatedRpt.Txt
SET /P GroupDN=Enter Group Name or DN (enclosed in double quotes):
IF [%GroupDN%]==[] Echo No Group specified&&Goto :EndScript
Echo %GroupDN% |FIND /I "CN=" >NUL
IF NOT ERRORLEVEL 1 (
DSQuery Group %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
) ELSE (
DSQuery Group -Name %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
DSQuery Group -Name %GroupDN% >GroupDN.tmp
SET /p GroupDN=<GroupDN.tmp
DEL /f /q GroupDN.tmp)
Echo.
Echo Please wait while system generate report...
Echo.
FOR /F "delims=*" %%m IN ('DSGet Group %GroupDN% -Members') DO DSQuery User %%m -disabled >>WhenCreatedRpt.Txt
Echo Script finish check 'WhenCreatedRpt.Txt' file.
Echo.
:EndScript
:: SCRIPT END
ASKER
Farhan i get this.
Enter Group Name or DN (enclosed in double quotes):"chennai_fs-sg"
Please wait while system generate report...
Script finish check 'WhenCreatedRpt.Txt' file.
Press any key to continue . . .
When i check the file it has no data...
Inside "chennai_fs-sg" i have 7 users
When i enter a root domain's group says invalid group...
Enter Group Name or DN (enclosed in double quotes):"chennai_fs-sg"
Please wait while system generate report...
Script finish check 'WhenCreatedRpt.Txt' file.
Press any key to continue . . .
When i check the file it has no data...
Inside "chennai_fs-sg" i have 7 users
When i enter a root domain's group says invalid group...
Are you sure "chennai_fs-sg" group contain users that are disabled?
Apply following and post results:
Click Start -> Run -> Cmd.exe
DSQuery * -Filter "(memberOf="CN=Chennai_FS- SG,OU=Secu rity Groups,OU=IND,OU=Countries ,DC=Develo pm
ent,DC=Group,DC=co,DC=uk") " -Attr distinguishedName whenCreated
Click Start -> Run -> Cmd.exe
DSQuery * -Filter "(memberOf="CN=Chennai_FS-
ent,DC=Group,DC=co,DC=uk")
ASKER
Farhan will this output only users that are disabled...
Then can you change the script to accept even root groups...
Then can you change the script to accept even root groups...
ASKER
Farhan i get this.
C:\>DSQuery * -Filter "(memberOf="CN=Chennai_FS- SG,OU=Secu rity Groups,OU=IND,OU=
Countries,DC=Development,D C=Group,DC =co,DC=uk" )" -Attr distinguishedName wh
enCreated
dsquery failed:Value for `startnode' has incorrect format.
type dsquery /? for help.
C:\>
C:\>DSQuery * -Filter "(memberOf="CN=Chennai_FS-
Countries,DC=Development,D
enCreated
dsquery failed:Value for `startnode' has incorrect format.
type dsquery /? for help.
C:\>
ASKER
farhankazi:Are you sure "chennai_fs-sg" group contain users that are disabled?
I dont get this.I just need to get all the users in a group with there created dates of all the members
I dont get this.I just need to get all the users in a group with there created dates of all the members
ASKER
Any help...
Sorry for my last comment, I think I mixed two posts!!
Modifying the script and will post in few minutes...
Modifying the script and will post in few minutes...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Farhan i checked with some security groups it works but not on Parent domain Groups....
Search with Group DN instead of its name.
ASKER
Like this.
Cn=admin, OU=Service Accounts DC=Development,DC=Group,DC =co,DC=uk
Cn=admin, OU=Service Accounts DC=Development,DC=Group,DC
yes, you can get exact DN using following command.
Click Start -> Run -> Cmd.exe
DSQuery Group -Name GroupName
Now above command will display exact DN of the Group. Copy and paste this DN to script input.
Click Start -> Run -> Cmd.exe
DSQuery Group -Name GroupName
Now above command will display exact DN of the Group. Copy and paste this DN to script input.
ASKER
Thanks a lot Farhan.I was just about to ask you for this but you understood...:)
ASKER
Farhan
How can i get the root domain's Groups....
What is the command to get all groups Dn of root domain
How can i get the root domain's Groups....
What is the command to get all groups Dn of root domain
Click Start -> Run -> Cmd.exe
DSQuery Group ForestRoot -Name * -Limit 0
Above command will display all groups from forest root.
DSQuery Group ForestRoot -Name GroupName
Above command will search for group name in forest root
DSQuery Group ForestRoot -Name * -Limit 0
Above command will display all groups from forest root.
DSQuery Group ForestRoot -Name GroupName
Above command will search for group name in forest root
ASKER
Thanks Farhan.....
Any help on this Q...
https://www.experts-exchange.com/questions/22800611/Script-to-schedule-a-task-every-1-min-to-keep-a-update-on-all-sessions-on-my-Machine.html
Any help on this Q...
https://www.experts-exchange.com/questions/22800611/Script-to-schedule-a-task-every-1-min-to-keep-a-update-on-all-sessions-on-my-Machine.html
:: SCRIPT START
@Echo Off
SET /P GroupDN=Enter Group Name or DN (enclosed in double quotes):
IF [%GroupDN%]==[] Echo No Group specified&&Goto :EndScript
Echo %GroupDN% |FIND /I "CN=" >NUL
IF NOT ERRORLEVEL 1 (
DSQuery Group %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
) ELSE (
DSQuery Group -Name %GroupDN% 2>NUL |FIND /I "CN=" >NUL
IF ERRORLEVEL 1 Echo Invalid Group DN&&Goto :EndScript
DSQuery Group -Name %GroupDN% >GroupDN.tmp
SET /p GroupDN=<GroupDN.tmp
DEL /f /q GroupDN.tmp
)
Echo.
Echo Please wait while system generate report...
Echo.
DSQuery * -Filter "(&(sAMAccountType=8053063
Echo Script finish check 'WhenCreatedRpt.Txt' file.
Echo.
:EndScript
IF EXIST GroupDN.tmp DEL /F /Q GroupDN.tmp
:: SCRIPT END