| 
| 
| 
| #196993 - 2009-12-04 09:05 PM  How do you enumerate ADSI LanServerMan Objects? |  
| rick4him   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   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
 
 
$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_   MM club member
 
       
   Registered:  2005-01-17
 Posts: 1896
 Loc:  Hilversum, The Netherlands
 | 
And just for the fun of translating:
 
$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   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 |  |  |  |  
| 
| 
| #197013 - 2009-12-07 07:43 PM  Re: How do you enumerate ADSI LanServerMan Objects?
[Re:  Mart] |  
| rick4him   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 |  |  |  |  
 Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
 
 | 
| 
 
| 0 registered
and 456 anonymous users online. 
 | 
 |  |