Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 238
  • Last Modified:

Scripiting with ifmember

I am writing a logon script using ifmember for my Windows 2003 domain users, but I am getting the incorrect output. I want the users to only receive the mappings they are member of, but right now they are receiving all of them.
The following is the script i wrote.
@ECHO OFF


::Group Network Drive Mappings

:HIT GLOBAL

NET USE F: /D
NET USE G: /D
NET USE I: /D
NET USE K: /D
NET USE L: /D
NET USE M: /D
NET USE N: /D
NET USE Q: /D
NET USE R: /D
NET USE V: /D
:NET USE H: /D
:NET USE H: \\Hit-ProdFile-01\%USERNAME%
NET USE J: /D
NET USE J: \\Hit-ProdFile-01\COMMON
NET USE P: /D
NET USE P: \\Hit-ProdFile-01\PUBLIC
NET USE U: /D
NET USE U: \\Hit-PST-01\%USERNAME%
NET USE Y: /D
NET USE Y: \\Hit-ProdFile-01\Projects
NeT USE Z: /D
NET USE Z: \\HIT-ArchFile-01\Archived_Data

:HIT SECURITY GROUPS

ifmember FINANCE_ACCOUNTING
if errorlevel 1 goto Management_Finance

ifmember GRAPHICS
if errorlevel 1 goto GRAPHICS

ifmember IT_GROUP
if errorlevel 1 goto IT_GROUP

ifmember PORTFOLIO MANAGEMENT
if errorlevel 1 goto PORTFOLIO_MANAGEMENT

ifmember LEGAL
if errorlevel 1 goto LEGAL

ifmember MARKETING
if errorlevel 1 goto MARKETING

ifmember SINGLE_FAMILY
if errorlevel 1 goto SINGLE_FAMILY

ifmember PUBLIC AFFAIRS
if errorlevel 1 goto PUBLIC_AFFAIRS

ifmember HUMAN_RESOURCES
if errorlevel 1 goto HUMAN_RESOURCES

ifmember MULTI_FAMILy
if errorlevel 1 goto MULTI_FAMILy

goto end

:Management_Finance
NET USE F: \\Hit-ProdFile-01\Management_Finance
:goto end

:GRAPHICS
NET USE G: \\Hit-ProdFile-01\GRAPHICS
:goto end

:IT_Group
NET USE I: \\Hit-ProdFile-01\IT
:goto end

:PORTFOLIO MANAGEMENT
NET USE K: "\\Hit-ProdFile-01\PORTFOLIO_MANAGEMENT"
:goto end

:LEGAL
NET USE L: \\Hit-ProdFile-01\Legal
:goto end

:MARKETING
NET USE M: \\Hit-ProdFile-01\Marketing
:goto end

:SINGLE_FAMILY
NET USE N: "\\Hit-ProdFile-01\SINGLE_FAMILY"
:goto end

:PUBLIC AFFAIRS
NET USE Q: "\\Hit-ProdFile-01\PUBLIC_AFFAIRS"
:goto end

:HUMAN_RESOURCES
NET USE R: "\\Hit-ProdFile-01\HUMAN_RESOURCES"
:goto end

:MULTI_FAMILY
NET USE V: "\\Hit-ProdFile-01\MULTI_FAMILY"
:goto end


:END
Exit
Any help will greatly appreciate.
Thanks and have a nice Thanks Given.
0
aflcio-hit
Asked:
aflcio-hit
  • 3
  • 2
1 Solution
 
oBdACommented:
They're currently receiving most of the mappings because you started the "goto" statements with a colon, turning them into labels instead of commands.
Remove the colon at the beginning and try again:
goto end
instead of
:goto end
0
 
aflcio-hitAuthor Commented:
When I remove the colon and run the scrpit I  only receive the global mappings (4) and only one of the groupmemership mappings ( I should receive all of them).
0
 
oBdACommented:
Meaning your account is in all of the necessary groups?
Then simply replace the "goto" statements in the "if errorlevel" command with the net use commands directly, and remove everything after (and including) the "goto end" command (you don't need the "exit", the logon script will close automatically when it's done):

ifmember FINANCE_ACCOUNTING
if errorlevel 1 NET USE F: \\Hit-ProdFile-01\Management_Finance
...
0
 
aflcio-hitAuthor Commented:
   The change you recommended made a huge difference in the output, but for some unknown reason I am still not getting one mapping.
    When I copy the mapping I am mission and paste it in the run windows the shares open without any problem.
    What could be causing this?
    Thanks.
0
 
oBdACommented:
Looking closer, it should actually be two drives you don't get, K: and Q:.
As with anything that contains spaces in a command line, you need to put quotes around group names with spaces:

ifmember "PORTFOLIO MANAGEMENT"
ifmember "PUBLIC AFFAIRS"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now