Bryce:As discussed, here's a KiX/ADSI script to create a file share on a local or remote workstation or server:
code:
break on
; This script demonstrates how to use Active Directory Services Interface (ADSI)
; to add shares on local and remote computers.
; use "net share" command to validate results
; Change these properties to suite your environment ...
$server_name = "dn1cov" ; *** change to your hostname ***
$share_path = "c:\winnt" ; *** change to valid path ***
$share_name = "@userid"
$share_maxusercount = 10
$share_description = "This is @userid's share"
$lms = olegetobject ( 0, "WinNT://$server_name/lanmanserver" )
if $lms = 0
?"Active Data Services Interface (ADSI) not installed on this machine" goto finish
endif
$share = val ( "&" + olecallfunc ( $lms, "create", "ss", "fileshare", "$share_name" ) )
$rs = oleputproperty ( $share, "path", "s", "$share_path" )
$rs = oleputproperty ( $share, "maxusercount", "s", "$share_maxusercount" )
$rs = oleputproperty ( $share, "description", "s", "$share_description" )
$rs = olecallproc ( $share, "setinfo" )
if @error
?"Error @error : @serror" goto finish
endif
:finish
if $share
$rs = olereleaseobject ( $share )
endif
if $lms
$rs = olereleaseobject ( $lms )
endif
?
exit
Here's a KiX/ADSI script to add a user to a local or remote workstation or server.
code:
break on; This script demonstrates how to use Active Directory Services Interface (ADSI)
; to add users on local and remote computers.
; Use the "net user" command to validate results
; Change these properties to suite your environment
$server_name = "dn1cov" ; *** Change to your hostname ***
$user_name = "kix.rules"
$user_password = "kixrules123"
$server = olegetobject ( 0, "WinNT://$server_name" )
if @error
?"Active Directory Interface Services not supported on this machine" goto finish
endif
$user = val ( "&" + olecallfunc ( $server, "create", "ss", "user", "$user_name" ))
$rs = olecallfunc ( $user, "setinfo" )
if @error = 0
$rs = olecallfunc ( $user, "setpassword", "s", "$user_password" )
if @error = 0
?"User $user_name successfully added to $server_name"
endif
endif
if @error
?"Error @error : @serror"
endif
:finish
if $user
$rs = olereleaseobject ( $user )
endif
if $server
$rs = olereleaseobject ( $server )
endif
?
exit
I've had the most success using Win2K as my Administration point - managing WinNT Servers and Workstations.
You can also get the WinNT (98?) version of ADSI right off the Microsoft Download site.
Obviously, these examples are just the "tip" of the ADSI "iceberg". They just bearly scratch the surface of Active Directory - but to be honest - once you start using them - you'll get one hell of an itch
!!!
Shawn.