Page 1 of 1 1
Topic Options
#196993 - 2009-12-04 09:05 PM How do you enumerate ADSI LanServerMan Objects?
rick4him Offline
Just in Town

Registered: 2009-12-04
Posts: 4
Loc: AZ, USA
I posted this basics and did not get a response, hopefully better result here. Thanks.

have Scriptomatic and WMICodeCreator but neither give objects for LanManServer, In the example script below how does one know to use .Sessions or .Resources, I cannot fine these objects/properties in either of the tools listed above, for that matter I cannot find how to specify LANManServer, these only seem to list for the object winmgmts and not for WinNt. Is there a list somewhere or another tool? I am new at this and problably have hatcheted up how to state this but could someone shed light on this for me. BTW this code was lifted (leeched) off someone else, not sure how one would start without doing this, also I could not find the START forum to post this in and hope it is fine in here. Rick

On Error Resume Next

Set objConnection = GetObject("WinNT://" & "." & "/LanmanServer")
Set colSessions = objConnection.Sessions
Set colResources = objConnection.Resources

For Each objResource in colResources
wscript.echo objResource.Name
Next

For Each objSession in colSessions
wscript.echo objSession

Top
#196998 - 2009-12-05 04:21 AM Re: How do you enumerate ADSI LanServerMan Objects? [Re: rick4him]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I have messed with this a few different times, and never got good, consistent results.

For shares this works
 Code:
$fileservice=getobject("WinNT://" + @wksta + "/LanmanServer")
for each $share in $fileservice
  ? $share.name
  ? $share.path
  ? $share.description
  ? $share.currentusercount
next


But for Sessions and Resources, I was never able to get any reliable results.

Top
#196999 - 2009-12-06 10:48 AM Re: How do you enumerate ADSI LanServerMan Objects? [Re: Allen]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
And just for the fun of translating:
 Code:
$objConnection = GetObject("WinNT://" + "." + "/LanmanServer")
$colSessions = $objConnection.Sessions
$colResources = $objConnection.Resources

For Each $objResource in $colResources
  ? $objResource.Name
Next

For Each $objSession in $colSessions
  ? $objSession
Next

Top
#197005 - 2009-12-07 05:30 PM Re: How do you enumerate ADSI LanServerMan Objects? [Re: Allen]
rick4him Offline
Just in Town

Registered: 2009-12-04
Posts: 4
Loc: AZ, USA
I don't know this ? and $ syntax usage. It fails in vbscript, which language is this? I tried converting it to vbscript, using shares or fileservice as objects but it errors with property or method not supported. Thanks for you reply though, I have found the Resource object is very flaky, sometimes I get a good set other times I do not, I am trying to see if a share directory has locked files in it before attempting to move it. If does I will use the sessions to close the files, this appears to work through .net, if that fails I will execute a shell to close the files via the net files command. I tried the MMC route but got in way over my head. Fortunately most of our 400+ servers are 2003 and the win32_connectionshare object works. Thanks again.
Top
#197012 - 2009-12-07 07:40 PM Re: How do you enumerate ADSI LanServerMan Objects? [Re: rick4him]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: rick4him
I don't know this ? and $ syntax usage. It fails in vbscript, which language is this?
....


Well, you are on a KiXtart scripting board so it is kixtart and not VB.
$ defines a variable in kix and ? displays a new line on the console window.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#197013 - 2009-12-07 07:43 PM Re: How do you enumerate ADSI LanServerMan Objects? [Re: Mart]
rick4him Offline
Just in Town

Registered: 2009-12-04
Posts: 4
Loc: AZ, USA
Sorry did not know what Kixtart was, seems I have heard the name before but did not associate it with script until your message, sorry to bother you folks, have good day, Rick
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 456 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.128 seconds in which 0.1 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org