Re: Enumerate computer names through LDAP

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: new2wmi (wmiposts_at_hotmail.com)
Date: 12/01/04


Date: 30 Nov 2004 19:49:36 -0800

Could you explain how this ("Wscript.Echo Mid(ObjItem.Name, 4)") works
differently? Or better yet, point me to where I can figure this out
for myself? I'm using wbemtest and scriptomatic primarily right now,
but beyond playing around with the already available scripts, I'm not
sure where to go.

Thanks.

"Torgeir Bakken \(MVP\)" <Torgeir.Bakken-spam@hydro.com> wrote in message news:<u7SJqDy1EHA.1264@TK2MSFTNGP12.phx.gbl>...
> new2wmi wrote:
>
> > I'm trying to get a list of all computers in a given OU. Using the
> > script below, I'm able to almost do this. The problem is that my
> > output looks like: "CN=Computer1", when I need it to look like
> > "Computer1". Am I echoing the wrong item? Should it be something
> > besides .Name? Or do I need to do modify the formatting of the
> > output?
>
> I suggest you use this:
>
> Wscript.Echo Mid(ObjItem.Name, 4)
>
>
> >
> > script:
> > Set colItems = GetObject ("LDAP://ou=SUS,ou=Computers,ou=NA,dc=ad,
> > dc=local")
> > colItems.Filter = Array("Computer")
> > For each objItem in colItems
> > Wscript.Echo ObjItem.Name
> > Next
> >
> > Output:
> > CN=Computer1
> > CN=Computer2



Relevant Pages

  • Screen Resolution revisited
    ... The only slight oddity, was that the very new Intel chipsets are producing more than one 'item' in the collection and the second item takes about four seconds to retrieve, and then returns 'null' for both horizontal and vertical with both scripts. ... For Each objItem in colItems ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Enumerate computer names through LDAP
    ... I'm using wbemtest and scriptomatic primarily right now, ... > but beyond playing around with the already available scripts, ... seems like you are not only new to wmi but also new to scripting (VBScript);-) ... HTH ...
    (microsoft.public.win32.programmer.wmi)
  • Coding Practices, Best methods?
    ... take most scripts and modify them to fit my needs. ... Set AdRec = CreateObject ... Set AdRec1 = CreateObject ... FOR EACH objItem IN Win32_QuickFixEngineering_colItems ...
    (microsoft.public.scripting.vbscript)
  • C drive name
    ... Unfortunetely all the scripts I see and play with want to look at all ... Dim objWMIService, objItem, colItems, strComputer ... Set objWMIService = GetObject _ ...
    (microsoft.public.scripting.vbscript)
  • Help needed: SWbemRefresher, impersonation, and XP-SP2, WMI
    ... having trouble with all the samples which use the SWbemRefresher object ... It would seem that these scripts are supposed to work, ... use a refresher (always "Invalid Class" on AddEnum line). ... Set colItems = objRefresher.AddEnum _ ...
    (microsoft.public.scripting.vbscript)