Microsoft Windows Server - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Microsoft Windows Server

Description:

Web- When a VBScript is inserted into a HTML document, the Internet browser will ... The VBScript can be executed immediately, or at a later event. ... – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 20
Provided by: mte7
Category:

less

Transcript and Presenter's Notes

Title: Microsoft Windows Server


1
Microsoft Windows Server
2
Scripting Terms
  • VBScript
  • JavaScript
  • Script Objects
  • Attributes

3
Scripting
  • What is VBScript?
  • VBScript is a scripting language
  • A scripting language is a lightweight programming
    language
  • VBScript is a light version of Microsoft's
    programming language Visual Basic
  • How Does it Work?
  • Web-gtWhen a VBScript is inserted into a HTML
    document, the Internet browser will read the HTML
    and interpret the VBScript. The VBScript can be
    executed immediately, or at a later event.
  • Networking-gtA VBScript can be compared to a
    simple batch file. It is in essence a program
    that will be run by Windows Scripting Host. The
    benefit/advantage over the batch file is that it
    is extremely more powerful and flexible.

4
Windows Scripting Host
  • There are two ways to launch the scripts.
  • Wscript (default) GUI Windows scripting host

5
Windows Scripting Host
  • Cscript command line scripting host

6
Script editor
  • C\Program Files\Microsoft Office\OFFICE11\MSE7.EX
    E

7
Examples
  • Open Notepad
  • Type the following commands
  • Option Explicit
  • Wscript.Echo "Hello, World!
  • Save as hello.vbs

8
Examples
  • Mapping a network drive installing a service
    pack
  • Set WshNetwork WScript.CreateObject("WScript.Net
    work")
  • WshNetwork.MapNetworkDrive "Z", \\dp2\shared
  • WshNetwork.MapNetworkDrive "R",
    "\\dp2\SPx\i386\update"
  • set ws WScript.CreateObject ("WScript.Shell")
  • ws.Run("\\dp2\SPx\i386\update\update.exe")

9
Examples
  • 'Function to set a user's password
  • '
  • 'For more scripts, visit www.wshscripting.com
  • Function SetPassword(domain, username, password)
  • 'Call this Function to set a user's password
  • On Error Resume Next
  • Dim user
  • Set user GetObject("WinNT//" domain "/"
    username "",user)
  • user.SetPassword(password)
  • SetPassword Err.Number
  • On Error Goto 0End Function
  • 'example
  • Dim username, password, domain
  • domain InputBox("On what domain", "Domain", "")

10
Examples
  • Defragmenting a computer.
  • ..\..\..\Scripts\Dfrg2prt.vbs

11
Examples
  • Creating an OU
  • Set objDomain GetObject("LDAP//dcfabrikam,dcc
    om")
  • Set objOU objDomain.Create("organizationalUnit",
    "ouManagement")
  • objOU.SetInfo

12
Examples
  • Move a Group Within a Domain
  • Moves a group account from the HR OU to the Users
    container.
  • Set objOU GetObject("LDAP//cnUsers,dcNA,dcfa
    brikam,dccom")
  • objOU.MoveHere "LDAP//cnatl-users,ouHR,dcNA,dc
    fabrikam,dccom", _vbNullString

13
Examples
  • Create User Account
  • Creates a user account in Active Directory. This
    script only creates the account, it does not
    enable it.
  • Set objOU GetObject("LDAP//OUmanagement,dcfab
    rikam,dccom")
  • Set objUser objOU.Create("User", "cnMyerKen")
    objUser.Put "sAMAccountName", "myerken
  • objUser.SetInfo 

14
Example
  • Create 1000 users in AD
  • Set objRootDSE GetObject("LDAP//rootDSE")
  • Set objContainer GetObject("LDAP//cnUsers,"
    _ objRootDSE.Get("defaultNamingContext"))
  • For i 1 To 1000
  • Set objLeaf objContainer.Create("User",
    "cnUserNo" i)
  • objLeaf.Put "sAMAccountName", "UserNo" I
  • objLeaf.SetInfo
  • Next
  • WScript.Echo "1000 Users created."

15
Assigning Login Scripts
  • Policy based within Group Policy
  • Computer Specific
  • Startup/Shutdown Scripts
  • User Specific
  • Logon/Logoff Scripts
  • Run asynchronously (hidden, behind the scenes)
  • W2k3 Machines create share called NETLOGON
  • \winnt\sysvol\domain name\scripts for backwards
    compatibility

16
Scripting Resources
  • http//www.microsoft.com/technet/scriptcenter/defa
    ult.mspx
  • http//www.winnetmag.com/WindowsScripting/
  • http//www.w3schools.com/vbscript/default.asp

17
CSVDE LDIFDE
  • CSVDE CSV Directory Exchange
  • Can import/export objects from Active Directory
  • Bulk import of only NEW objects.
  • Cannot modify existing objects
  • LDIFDE Lightweight Data Interchange Format Data
    Exchange
  • Can import/export objects from Active Directory
  • Bulk import of objects.
  • Modification of EXISTING Active Directory
    accounts.
  • Resources
  • http//support.microsoft.com/default.aspx/kb/32762
    0
  • http//www.computerperformance.co.uk/Logon/CSVDE_L
    DIFDE.htm

18
CSVDE LDIFDE
  • Examples
  • For example, you can use the following command to
    export all objects with the users.swynk.com as
    part of their Distinguished Name (including both
    users and groups) into userlist.csv file
  • csvde.exe -f userlist.csv -d "cnusers,DCswynk,DC
    com
  • The following will export all objects of the user
    object class (user and computer accounts, but not
    groups)
  • csvde.exe -f userlist.csv -r "(objectClassuser)"

19
CSVDE LDIFDE
  • The import is less straightforward. Some of
    attributes are owned by the system, so when
    running the import using the same file format,
    errors will result. Running export with -m
    switch, excludes them (by using so called SAM
    logic). Once the list is known, it can be
    populated with data for new user accounts. 
  • For example, the following allows you to create
    Marcin Policht account in swynk.com domain
  • csvde.exe -i -f indata.csv
  • indata.csv contains the following
    fieldsDN,cn,displayName,distinguishedName,objectC
    ategory,objectClass,name,sAMAccountName,givenName,
    sn,userPrincipalName"CNMarcin
    Policht,CNUsers,DCswynk,DCcom",Marcin
    Policht,Marcin Policht,"CNMarcin
    Policht,CNUsers,DCswynk,DCcom","CNPerson,CNSc
    hema,CNConfiguration,DCswynk,DCcom",user,Marcin
    Policht,MarcinPolicht,Marcin,Policht,MarcinPolich
    t_at_swynk.com
Write a Comment
User Comments (0)
About PowerShow.com