Jump to content

brian873

Member
  • Posts

    335
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United Kingdom

Everything posted by brian873

  1. Thanks everyone I have it working the way I need it now. @allen2 - thats a fair point and a good one to look out for. However in this environment there are no nested groups and all usernames are generated from another system so should be fine with the current task. @Yzöwl - I have used the line you provided, thanks very much I will take a look at the other methods tools mentioned, but I can get what I need for now! Cheers
  2. Thanks jaclaz & Yzöwl OK that makes sense now. I cant test it at the moment, will do it tomorrow. My only concern would be that %groupname% in some cases will contain spaces. I think omitting the " " will cause a problem. I will report what I find.
  3. Hi Jaclaz, thanks for the reply Sorry !%newName! was a typo, it should be !newName! Ok here is the information you asked for. When the CMD file prompts for input at the line set /p groupname=enter groupname: I am entering Accounts Working CMD file @echo off CLS echo. set /p groupname=enter groupname: echo. echo. dsquery * domainroot -filter "(&(objectClass=group)(name=""%groupname%""))" -l -d DomainName -attr member >>GroupMemberExtract.txt CLS setlocal enabledelayedexpansion FOR /F "tokens=1 delims=," %%a IN ( GroupMemberExtract.txt ) DO ( set oldName=%%a set newName=!oldName:~3! echo !newName!>>GroupMemberTrim.txt ) SETLOCAL DISABLEEXTENSIONS :END GroupMemberExtract.txt GroupMemberTrim.txt Non working CMD file with vairables @echo off CLS echo. set /p groupname=enter groupname: echo. echo. dsquery * domainroot -filter "(&(objectClass=group)(name=""%groupname%""))" -l -d DomainName -attr member >>"%groupname%Extract.txt" CLS setlocal enabledelayedexpansion FOR /F "tokens=1 delims=," %%a IN ( "%groupname%Extract.txt" ) DO ( set oldName=%%a set newName=!oldName:~3! echo !newName!>>"%groupname%Trim.txt" ) SETLOCAL DISABLEEXTENSIONS :END AccountsExtract.txt AccountsTrim.txt So as you see, using the variables in this example throws out the %%a in the for loop and instead of phrasing the contents it uses the filename.
  4. Hi, I have a CMD file which extracts users from an Active Directory group then trims it so only the username is displayed in the output file GroupMemberTrim.txt. It works fine, however I would like to use dynamic file names instead of static GroupMemberExtract.txt -> %groupname%-Extract.txt GroupMemberTrim.txt -> %groupname%-Trim.txt When I change this it breaks the FOR loop so the %%a variable does not read in the contents of %groupname%-Extract.txt instead it reads the filename %groupname%-Extract.txt as the %%a variable. Does anyone have any ideas how this could be fixed? Thanks @echo off CLS :GroupsMembersExtract echo. set /p groupname=enter groupname: echo. echo. dsquery * domainroot -filter "(&(objectClass=group)(name=""%groupname%""))" -l -d DomainName -attr member >>GroupMemberExtract.txt :GroupsMembersTrim CLS setlocal enabledelayedexpansion FOR /F "tokens=1 delims=," %%a IN ( GroupMemberExtract.txt ) DO ( set oldName=%%a set newName=!oldName:~3! echo !%newName!>>GroupMemberTrim.txt ) SETLOCAL DISABLEEXTENSIONS :END
  5. Hi Guys, thanks for both your help ! Thats it working fine for me now
  6. Hi, I am looking for some help with a VB script I am trying to improve. The script runs at logon and pulls out some AD information to create an email signature for the user in Outlook 2003. The script is working fine but I would now like to add in a check so if a field is blank, it does not include that section the in signature. The issue is that not all users have fax numbers so I would like to check the fax and only include the line objSelection.TypeText "Direct Fax: " & strFax if it is not empty. Any pointers ? Full Script On Error Resume Next Set objSysInfo = CreateObject("ADSystemInfo") strUser = objSysInfo.UserName Set objUser = GetObject("LDAP://" & strUser) strName = objUser.FullName strTitle = objUser.Title strDepartment = objUser.Department strCompany = objUser.Company strPhone = objUser.telephoneNumber strFax = objUser.facsimileTelephoneNumber Set objWord = CreateObject("Word.Application") Set objDoc = objWord.Documents.Add() Set objSelection = objWord.Selection Set objEmailOptions = objWord.EmailOptions Set objSignatureObject = objEmailOptions.EmailSignature Set objSignatureEntries = objSignatureObject.EmailSignatureEntries objSelection.Font.Name = "Arial" objSelection.Font.Size = "10" objSelection.Font.Bold = True objSelection.TypeParagraph() objSelection.TypeText strName objSelection.TypeParagraph() objSelection.TypeText strTitle objSelection.TypeParagraph() objSelection.TypeText "Direct Dial: " & strPhone objSelection.TypeParagraph() objSelection.TypeText "Direct Fax: " & strFax Set objSelection = objDoc.Range() objSignatureEntries.Add "AD Signature", objSelection objSignatureObject.NewMessageSignature = "AD Signature" objSignatureObject.ReplyMessageSignature = "AD Signature" objDoc.Saved = True objWord.Quit
×
×
  • Create New...