11543

IT Management Daily
Storage Daily
Security Daily
FREE NEWSLETTERS
search
 

follow us on Twitter


internet.commerce
Be a Commerce Partner

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Products
 Barcode for Libraries (Barcode for libraries)
 RecoveryFix for OST (Data Recovery Fix)
 Easy RAR Recovery (MunSoft)
 Word Recovery (Word Recovery)
 Bulletproof Public PC (Pc-Safety)
 Fix Outlook Errors (Fix Outlook Errors)
» Enterprise IT Planet » Resources » SMS Scripts

Script for Obtaining Local Administrator Names

September 26, 2003

Email Print Digg This Add to del.icio.us
Here's a script from Ian Gregory that will obtain the names of the members of the Local Administrators group on each PC. This script uses addusers.exe from the Resource Kit and generates a custom MIF file containing this information. You need all three files in the package source directory.

Download the admins.zip package.

<< Back to SMS Scripts list.


Below is the entire script:


Document Type: IPF
item: Global
  Version=6.0
  Title English=Untitled Installation
  Flags=00000100
  Languages=0 0 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  LanguagesList=English
  Default Language=2
  Japanese Font Size=10
  Start Gradient=0 0 255
  End Gradient=0 0 0
  Windows Flags=00010000000000010010110000011000
  Log Pathname=%MAINDIR%\INSTALL.LOG
  Message Font=MS Sans Serif
  Font Size=8
  Disk Filename=SETUP
  Patch Flags=0000000000000001
  Patch Threshold=85
  Patch Memory=4000
  FTP Cluster Size=20
  Variable Name1=_SYS_
  Variable Default1=C:\WINNT\System32
  Variable Flags1=00001000
  Variable Name2=_SMSINSTL_
  Variable Default2=C:\Program Files\Microsoft SMS Installer
  Variable Flags2=00001000
end
item: Open/Close INSTALL.LOG
  Flags=00000001
end
item: Check if File/Dir Exists
  Pathname=%SYS%
  Flags=10000100
end
item: Set Variable
  Variable=SYS
  Value=%WIN%
end
item: End Block
end
item: Set Variable
  Variable=APPTITLE
  Value=Local Admins
  Flags=10000000
end
item: Set Variable
  Variable=GROUP
  Flags=10000000
end
item: Set Variable
  Variable=DISABLED
  Value=!
end
item: Set Variable
  Variable=CRLF
  Value=
  Value=
end
item: Set Variable
  Variable=COUNT
  Value=1
end
item: Parse String
  Source=%WIN%
  Pattern=:
  Variable1=SYSDRIVE
end
item: Set Variable
  Variable=MAINDIR
  Value=Untitled
  Flags=10000000
end
item: Check Configuration
  Flags=10111011
end
item: Get Registry Key Value
  Variable=COMMON
  Key=SOFTWARE\Microsoft\Windows\CurrentVersion
  Default=%SYSDRIVE%:\Program Files\Common Files
  Value Name=CommonFilesDir
  Flags=00000100
end
item: Get Registry Key Value
  Variable=PROGRAM_FILES
  Key=SOFTWARE\Microsoft\Windows\CurrentVersion
  Default=%SYSDRIVE%:\Program Files
  Value Name=ProgramFilesDir
  Flags=00000100
end
item: Set Variable
  Variable=MAINDIR
  Value=%PROGRAM_FILES%\%MAINDIR%
  Flags=00001100
end
item: Set Variable
  Variable=EXPLORER
  Value=1
end
item: Else Statement
end
item: Set Variable
  Variable=MAINDIR
  Value=%SYSDRIVE%:\%MAINDIR%
  Flags=00001100
end
item: End Block
end
item: Set Variable
  Variable=BACKUP
  Value=%MAINDIR%\BACKUP
  Flags=10000000
end
item: Set Variable
  Variable=DOBACKUP
  Value=B
  Flags=10000000
end
item: Set Variable
  Variable=COMPONENTS
  Flags=10000000
end
item: Set Variable
  Variable=BRANDING
  Value=0
end
item: If/While Statement
  Variable=BRANDING
  Value=1
end
item: Read INI Value
  Variable=NAME
  Pathname=%INST%\CUSTDATA.INI
  Section=REGISTRATION
  Item=NAME
end
item: Read INI Value
  Variable=COMPANY
  Pathname=%INST%\CUSTDATA.INI
  Section=REGISTRATION
  Item=COMPANY
end
item: If/While Statement
  Variable=NAME
end
item: Set Variable
  Variable=DOBRAND
  Value=1
end
item: End Block
end
item: End Block
end
item: Wizard Block
  Direction Variable=DIRECTION
  Display Variable=DISPLAY
  Bitmap Pathname=%_SMSINSTL_%\DIALOGS\TEMPLATE\WIZARD.BMP
  X Position=9
  Y Position=10
  Filler Color=8421440
  Dialog=Select Program Manager Group
  Dialog=Select Backup Directory
  Dialog=Display Registration Information
  Dialog=Get Registration Information
  Variable=EXPLORER
  Variable=DOBACKUP
  Variable=DOBRAND
  Variable=DOBRAND
  Value=1
  Value=A
  Value=1
  Value=1
  Compare=0
  Compare=1
  Compare=0
  Compare=1
  Flags=00000011
end
item: If/While Statement
  Variable=DISPLAY
  Value=Select Destination Directory
end
item: Set Variable
  Variable=BACKUP
  Value=%MAINDIR%\BACKUP
end
item: End Block
end
item: End Block
end
item: If/While Statement
  Variable=DOBACKUP
  Value=A
end
item: Set Variable
  Variable=BACKUPDIR
  Value=%BACKUP%
end
item: End Block
end
item: If/While Statement
  Variable=BRANDING
  Value=1
end
item: If/While Statement
  Variable=DOBRAND
  Value=1
end
item: Edit INI File
  Pathname=%INST%\CUSTDATA.INI
  Settings=[REGISTRATION]
  Settings=NAME=%NAME%
  Settings=COMPANY=%COMPANY%
  Settings=
end
item: End Block
end
item: End Block
end
item: Open/Close INSTALL.LOG
end
item: Check Disk Space
  Component=COMPONENTS
end
item: Install File
  Source=admins.mif
  Destination=%WIN%\MS\SMS\NOIDMIFS\ADMINS.MIF
  Flags=0000000000100010
end
item: Set Variable
  Variable=COMMON
  Value=%COMMON%
  Flags=00010100
end
item: Check Configuration
  Flags=10011010
end
item: Set Variable
  Variable=MAINDIR
  Value=%MAINDIR%
  Flags=00010100
end
item: End Block
end
item: Check Configuration
  Flags=10111011
end
item: Get Registry Key Value
  Variable=STARTUPDIR
  Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
  Default=%WIN%\Start Menu\Programs\StartUp
  Value Name=StartUp
  Flags=00000010
end
item: Get Registry Key Value
  Variable=DESKTOPDIR
  Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
  Default=%WIN%\Desktop
  Value Name=Desktop
  Flags=00000010
end
item: Get Registry Key Value
  Variable=STARTMENUDIR
  Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
  Default=%WIN%\Start Menu
  Value Name=Start Menu
  Flags=00000010
end
item: Get Registry Key Value
  Variable=GROUPDIR
  Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
  Default=%WIN%\Start Menu\Programs
  Value Name=Programs
  Flags=00000010
end
item: Get Registry Key Value
  Variable=CSTARTUPDIR
  Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
  Default=%STARTUPDIR%
  Value Name=Common Startup
  Flags=00000100
end
item: Get Registry Key Value
  Variable=CDESKTOPDIR
  Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
  Default=%DESKTOPDIR%
  Value Name=Common Desktop
  Flags=00000100
end
item: Get Registry Key Value
  Variable=CSTARTMENUDIR
  Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
  Default=%STARTMENUDIR%
  Value Name=Common Start Menu
  Flags=00000100
end
item: Get Registry Key Value
  Variable=CGROUPDIR
  Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
  Default=%GROUPDIR%
  Value Name=Common Programs
  Flags=00000100
end
item: Set Variable
  Variable=CGROUP_SAVE
  Value=%GROUP%
end
item: Set Variable
  Variable=GROUP
  Value=%GROUPDIR%\%GROUP%
end
item: Else Statement
end
item: End Block
end
item: Self-Register OCXs/DLLs
  Description English=Updating System Configuration, Please Wait...
end
item: Remark
end
item: Execute Program
  Pathname=%INST%\addusers.exe
  Command Line=/d %TEMP%\userinfo.txt
  Flags=00000010
end
item: Remark
end
item: Remark
  Text=     The following lines edit the text output file to
  Text=     strip out unnecesary sections and carriage returns,
end
item: Remark
  Text=     replace backslashes with colons (SMS inventory can't
  Text=     parse the MIF file when it contains backslashes),
end
item: Remark
  Text=     and adds the values to the custom MIF file.
end
item: Remark
end
item: Edit INI File
  Pathname=%TEMP%\userinfo.txt
  Settings=[User]
  Settings=[Global]
  Settings=
end
item: Insert Line into Text File
  Pathname=%TEMP%\userinfo.txt
  Search Text=[Local]
  Line Number=0
  Flags=00001000
end
item: Insert Line into Text File
  Pathname=%TEMP%\userinfo.txt
  Search Text=Backup Operators,Members can bypass file security to back up files,
  Line Number=0
  Flags=00001000
end
item: Insert Line into Text File
  Pathname=%TEMP%\userinfo.txt
  Search Text=Guests,Users granted guest access to the computer/domain,
  Line Number=0
  Flags=00001000
end
item: Insert Line into Text File
  Pathname=%TEMP%\userinfo.txt
  Search Text=Power Users,Members can share directories and printers,
  Line Number=0
  Flags=00001000
end
item: Insert Line into Text File
  Pathname=%TEMP%\userinfo.txt
  Search Text=Replicator,Supports file replication in a domain,
  Line Number=0
  Flags=00001000
end
item: Insert Line into Text File
  Pathname=%TEMP%\userinfo.txt
  Search Text=Users,Ordinary users,
  Line Number=0
  Flags=00001000
end
item: Read/Update Text File
  Variable=LINES
  Pathname=%TEMP%\userinfo.txt
end
item: Parse String
  Source=%LINES%
  Pattern=computer/domain,
  Variable2=LINES
end
item: Remark
end
item: If/While Statement
  Variable=LINES
  Flags=00010101
end
item: If/While Statement
  Variable=LINES
  Value=%CRLF%
  Flags=00010010
end
item: Parse String
  Source=%LINES%
  Pattern=%CRLF%
  Variable1=LINES
  Variable2=LINES1
end
item: Set Variable
  Variable=LINES
  Value=%LINES1%
  Flags=00000001
end
item: End Block
end
item: If/While Statement
  Variable=LINES
  Value=\
  Flags=00010010
end
item: Parse String
  Source=%LINES%
  Pattern=\
  Variable1=LINES
  Variable2=LINES1
end
item: Set Variable
  Variable=LINES
  Value=:%LINES1%
  Flags=00000001
end
item: End Block
end
item: Parse String
  Source=%LINES%
  Pattern=,
  Variable1=NAME
  Variable2=LINES
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=  Start Group
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=  Name = "Local Admins"
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=  ID = %COUNT%
  Line Number=0
  Flags=00010000
end
item: Remark
end
item: Remark
  Text=Add your organisation's name to the following line
end
item: Remark
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=  Class = "Replace this with your organisation name|Local Admins"
  Line Number=0
  Flags=00010000
end
item: Remark
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=  Start Attribute
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=     Name = "Administrator Name"
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=     ID = 1
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=     Type = String(50)
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=     Storage = Specific
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=     Value = "%NAME%"
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=  End Attribute
  Line Number=0
  Flags=00010000
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=  End Group
  Line Number=0
  Flags=00010000
end
item: Set Variable
  Variable=COUNT
  Flags=00000101
end
item: End Block
end
item: End Block
end
item: Remark
end
item: Insert Line into Text File
  Pathname=%WIN%\MS\SMS\NOIDMIFS\admins.MIF
  New Text=End Component
  Line Number=0
  Flags=00010000
end
item: Remark
end
item: Delete File
  Pathname=%TEMP%\userinfo.txt
end

Disclaimer: We hope that the information in these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided "as -is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by me. We shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

Email Print Digg This Add to del.icio.us

SMS Scripts Archives