Windows Vista Forums

search workstations and servers by os version
  1. #1


    drew Guest

    search workstations and servers by os version

    for a particular missing Access file, the location of which i know not, and
    has been lost to species memory. i know we have active directory somewhere
    too, but not how to query it for the list of computers, but assuming i can
    get a list of computers from net view and send it to compters.txt, how do i
    get to be able to do something like



    foreach ($computer in $computers) {
    get-childitem \\$computer\c:\MyMissing.MDB recurse>>\\myHostMachine.Found.txt
    }
    i mean, that's what i want, but something(s) missing...
    isn't there a way to redirect the error flow to null so that i dont get
    those pesky Access Denied nags that seem to ignore the silently continue?
    2>null? where does it go?

    Still, it would be nice to be able to log the denying maching name too,
    since the MDB must be found, by ethernet or sneaker net.
    thanks very much gang

      My System SpecsSystem Spec

  2. #2


    Bob Landau Guest

    RE: search workstations and servers by os version

    Assuming you have a list of machines names (IP Address, FQDN, hostname)
    doesn't matter. You will need to figure out what drives are on these
    machines. The below WMI classes will help

    Win32_Share/Win32_DiskDrive/Win32_LogicalDisk

    i.e.

    Get-WmiObject -Computer $c -Class Win32_Share

    But to keep things simple which may be good enough


    foreach ($computer in $computers) {
    get-childitem "\\$computer\c$" -Filter MyMissing.MDB
    -Recurse -ErrorAction SilentlyContinue
    -ErrorVariable StdERR

    >> myHostMachine.Found.txt
    }

    Couple of corrections you need a UNC name which for a root drive takes the
    form of \\<MachineName>\<Drive>$

    By using the -Filter parameter all work is done on the remote machine. Only
    if a match is found will any network traffic be generated.

    By using -ErrorAction SilentContinue all non terminating errors will be
    swallowed.

    By specifying -ErrorVariable <VarName> WITHOUT the $ the errors will be
    stored in that variable which you can process as you see fit


    "drew" wrote:

    > for a particular missing Access file, the location of which i know not, and
    > has been lost to species memory. i know we have active directory somewhere
    > too, but not how to query it for the list of computers, but assuming i can
    > get a list of computers from net view and send it to compters.txt, how do i
    > get to be able to do something like
    >
    > foreach ($computer in $computers) {
    > get-childitem \\$computer\c:\MyMissing.MDB recurse>>\\myHostMachine.Found.txt
    > }
    > i mean, that's what i want, but something(s) missing...
    > isn't there a way to redirect the error flow to null so that i dont get
    > those pesky Access Denied nags that seem to ignore the silently continue?
    > 2>null? where does it go?
    >
    > Still, it would be nice to be able to log the denying maching name too,
    > since the MDB must be found, by ethernet or sneaker net.
    > thanks very much gang

      My System SpecsSystem Spec

  3. #3


    OldDog Guest

    Re: search workstations and servers by os version

    On Feb 25, 9:54*pm, drew <d...@xxxxxx> wrote:

    > for a particular missing Access file, the location of which i know not, and
    > has been lost to species memory. i know we have active directory somewhere
    > too, but not how to query it for the list of computers, but assuming i can
    > get a list of computers from net view and send it to compters.txt, how doi
    > get to be able to do something like
    >
    > foreach ($computer in $computers) {
    > get-childitem \\$computer\c:\MyMissing.MDB recurse>>\\myHostMachine.Found..txt}
    >
    > i mean, that's what i want, but something(s) missing...
    > isn't there a way to redirect the error flow to null so that i dont get
    > those pesky Access Denied nags that seem to ignore the silently continue?*
    > 2>null? where does it go?
    >
    > Still, it would be nice to be able to log the denying maching name too,
    > since the MDB must be found, by ethernet or sneaker net.
    > thanks very much gang
    Try this. Make sure the machine you are running it on has Excel.
    The list of computers
    $row = 2
    $xl = New-Object -c excel.application
    $xl.visible = $true
    $wb = $xl.workbooks.add()
    $sh = $wb.sheets.item(1)
    #The list of computers
    $computerlist = Get-Content 'c:\scripts\Servers.txt'
    foreach ($srv in $computerlist)
    {
    $sh.Cells.Item($row, 1) = $srv
    $response = Get-WmiObject -query "Select * From Win32_PingStatus Where
    Address = '$srv'"

    if( ($response -eq $null) -or ($response.StatusCode -ne 0)) {
    $sh.Cells.Item($row, 2) = "Does Not Ping"
    $row++
    } else { if ($response.TimeToLive -le 64)
    {
    $sh.Cells.Item($row, 2) = "probably is a Unix host"
    $row++
    }
    Else {
    $Var3 = Get-ChildItem -path \\$srv\c$ -recurse -
    include w2000events.mdb -ea continue

    if ($Var3) {
    $sh.Cells.Item($row, 3) = $Var3.FullName }
    Else { $sh.Cells.Item($row, 2) = $error[0].tostring() }
    $row++
    }
    }
    }

      My System SpecsSystem Spec

  4. #4


    OldDog Guest

    Re: search workstations and servers by os version

    On Feb 25, 9:54*pm, drew <d...@xxxxxx> wrote:

    > for a particular missing Access file, the location of which i know not, and
    > has been lost to species memory. i know we have active directory somewhere
    > too, but not how to query it for the list of computers, but assuming i can
    > get a list of computers from net view and send it to compters.txt, how doi
    > get to be able to do something like
    >
    > foreach ($computer in $computers) {
    > get-childitem \\$computer\c:\MyMissing.MDB recurse>>\\myHostMachine.Found..txt}
    >
    > i mean, that's what i want, but something(s) missing...
    > isn't there a way to redirect the error flow to null so that i dont get
    > those pesky Access Denied nags that seem to ignore the silently continue?*
    > 2>null? where does it go?
    >
    > Still, it would be nice to be able to log the denying maching name too,
    > since the MDB must be found, by ethernet or sneaker net.
    > thanks very much gang
    OK try this;

    < --- start script ----->

    $row = 2
    $xl = New-Object -c excel.application
    $xl.visible = $true
    $wb = $xl.workbooks.add()
    $sh = $wb.sheets.item(1)
    $computerlist = Get-Content 'c:\scripts\Servers.txt'
    foreach ($srv in $computerlist)
    {
    $sh.Cells.Item($row, 1) = $srv
    $response = Get-WmiObject -query "Select * From Win32_PingStatus Where
    Address = '$srv'"

    if( ($response -eq $null) -or ($response.StatusCode -ne 0)) {
    $sh.Cells.Item($row, 2) = "Does Not Ping"
    $row++
    } else { if ($response.TimeToLive -le 64)
    {
    $sh.Cells.Item($row, 2) = "probably is a Unix host"
    $row++
    } Else {
    $Var3 = Get-ChildItem -path \\$srv\c$ -recurse -include
    MyMissingMDB.mdb -ea continue
    if ($Var3) {
    $sh.Cells.Item($row, 3) = $Var3.FullName }
    Else { $sh.Cells.Item($row, 2) = $error[0].tostring() }
    $row++
    }
    }
    }

    # <---- End Script ------>

    Make sure the workstation you run it on has Excel installed. And watch
    the wrap!!

      My System SpecsSystem Spec

  5. #5


    OldDog Guest

    Re: search workstations and servers by os version

    On Feb 25, 9:54*pm, drew <d...@xxxxxx> wrote:

    > for a particular missing Access file, the location of which i know not, and
    > has been lost to species memory. i know we have active directory somewhere
    > too, but not how to query it for the list of computers, but assuming i can
    > get a list of computers from net view and send it to compters.txt, how doi
    > get to be able to do something like
    >
    > foreach ($computer in $computers) {
    > get-childitem \\$computer\c:\MyMissing.MDB recurse>>\\myHostMachine.Found..txt}
    >
    > i mean, that's what i want, but something(s) missing...
    > isn't there a way to redirect the error flow to null so that i dont get
    > those pesky Access Denied nags that seem to ignore the silently continue?*
    > 2>null? where does it go?
    >
    > Still, it would be nice to be able to log the denying maching name too,
    > since the MDB must be found, by ethernet or sneaker net.
    > thanks very much gang
    OK, if this is a joke, I don't get it. The Header does not match the
    question.

    Anyway, Here is a POSH script that will do what you ask for in the
    body of your post.
    You need Excel on the machine you run this script on. The

    #<---- Begin Script -------->

    $a = get-date -format g
    $row = 2
    $xl = New-Object -c excel.application
    $xl.visible = $True
    $wb = $xl.workbooks.add()
    $sh = $wb.sheets.item(1)
    $sh.Range("A1:T1").Font.Bold = $true
    $sh.Range("A:A").Font.Bold = $True
    $sh.Cells.Item(1, 1) = "Computer Name"
    $sh.Cells.Item(1, 2) = "Date Run " + $a
    $computerlist = Get-Content 'c:\compters.txt'
    foreach ($srv in $computerlist)
    {
    $sh.Cells.Item($row, 1) = $srv
    $response = Get-WmiObject -query "Select * From Win32_PingStatus Where
    Address = '$srv'"

    if( ($response -eq $null) -or ($response.StatusCode -ne 0)) {
    $sh.Cells.Item($row, 2).Font.ColorIndex = 3
    $sh.Cells.Item($row, 2) = "Does Not Ping"
    $row++
    } else { if ($response.TimeToLive -le 64)
    {
    $sh.Cells.Item($row, 2).Font.ColorIndex = 5
    $sh.Cells.Item($row, 2) = "probably is a Unix host"
    $row++
    } Else {
    $Var3 = Get-ChildItem -path \\$srv\c$ -recurse -include *.mdb -ea
    continue
    if ($Var3) {
    $sh.Cells.Item($row, 3) = $Var3.FullName }
    Else {
    $sh.Cells.Item($row, 2).Font.ColorIndex = 3
    $sh.Cells.Item($row, 2) = $error[0].tostring() }
    $row++
    }
    } $sh.Cells.EntireColumn.AutoFit()
    }

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    $wb.SaveAs("C:\temp\find_MDB.xls")
    # close and release resources
    $wb.close($false)
    $xl.quit()
    spps -n excel

      My System SpecsSystem Spec

  6. #6


    OldDog Guest

    Re: search workstations and servers by os version

    On Feb 25, 9:54*pm, drew <d...@xxxxxx> wrote:

    > for a particular missing Access file, the location of which i know not, and
    > has been lost to species memory. i know we have active directory somewhere
    > too, but not how to query it for the list of computers, but assuming i can
    > get a list of computers from net view and send it to compters.txt, how doi
    > get to be able to do something like
    >
    > foreach ($computer in $computers) {
    > get-childitem \\$computer\c:\MyMissing.MDB recurse>>\\myHostMachine.Found..txt}
    >
    > i mean, that's what i want, but something(s) missing...
    > isn't there a way to redirect the error flow to null so that i dont get
    > those pesky Access Denied nags that seem to ignore the silently continue?*
    > 2>null? where does it go?
    >
    > Still, it would be nice to be able to log the denying maching name too,
    > since the MDB must be found, by ethernet or sneaker net.
    > thanks very much gang
    OK, if this is a joke, I don't get it. The Header does not match the
    question.

    Anyway, Here is a POSH script that will do what you ask for in the
    body of your post.
    You need Excel on the machine you run this script on.
    The output goes to C:\temp\find_MDB.xls

    #<--- Start Script --------->

    $a = get-date -format g
    $row = 2
    $xl = New-Object -c excel.application
    $xl.visible = $True
    $wb = $xl.workbooks.add()
    $sh = $wb.sheets.item(1)
    $sh.Range("A1:T1").Font.Bold = $true
    $sh.Range("A:A").Font.Bold = $True
    $sh.Cells.Item(1, 1) = "Computer Name"
    $sh.Cells.Item(1, 2) = "Date Run " + $a
    $computerlist = Get-Content 'c:\compters.txt'
    foreach ($srv in $computerlist)
    {
    $sh.Cells.Item($row, 1) = $srv
    # This is all one line -->
    $response = Get-WmiObject -query "Select * From Win32_PingStatus Where
    Address = '$srv'"
    # <---
    if( ($response -eq $null) -or ($response.StatusCode -ne 0)) {
    $sh.Cells.Item($row, 2).Font.ColorIndex = 3
    $sh.Cells.Item($row, 2) = "Does Not Ping"
    $row++
    } else { if ($response.TimeToLive -le 64)
    {
    $sh.Cells.Item($row, 2).Font.ColorIndex = 5
    $sh.Cells.Item($row, 2) = "probably is a Unix host"
    $row++
    } Else {
    # This is all one line -->
    $Var3 = Get-ChildItem -path \\$srv\c$ -recurse -Filter "MyMissing.MDB"
    -ea continue
    # <---
    if ($Var3) {
    foreach ($objItem in $Var3) {
    $sh.Cells.Item($row, 3) = $objItem.FullName
    $row++ }
    } Else {
    $sh.Cells.Item($row, 2).Font.ColorIndex = 3
    $sh.Cells.Item($row, 2) = $error[0].tostring() }
    $row++
    }
    } $sh.Cells.EntireColumn.AutoFit()
    }

    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #
    $wb.SaveAs("C:\temp\find_MDB.xls")
    # close and release resources
    $wb.close($false)
    $xl.quit()
    spps -n excel

    #<------ End Script -------->

      My System SpecsSystem Spec

  7. #7


    drew Guest

    Re: search workstations and servers by os version

    thanks very much for your help, i will try it out.
    was away from the net for two days <g>
    i appreciate the Excel tutorial too!
    drew

    "OldDog" wrote:

    > On Feb 25, 9:54 pm, drew <d...@xxxxxx> wrote:

    > > for a particular missing Access file, the location of which i know not, and
    > > has been lost to species memory. i know we have active directory somewhere
    > > too, but not how to query it for the list of computers, but assuming i can
    > > get a list of computers from net view and send it to compters.txt, how do i
    > > get to be able to do something like
    > >
    > > foreach ($computer in $computers) {
    > > get-childitem \\$computer\c:\MyMissing.MDB recurse>>\\myHostMachine.Found..txt}
    > >
    > > i mean, that's what i want, but something(s) missing...
    > > isn't there a way to redirect the error flow to null so that i dont get
    > > those pesky Access Denied nags that seem to ignore the silently continue?
    > > 2>null? where does it go?
    > >
    > > Still, it would be nice to be able to log the denying maching name too,
    > > since the MDB must be found, by ethernet or sneaker net.
    > > thanks very much gang
    >
    > OK, if this is a joke, I don't get it. The Header does not match the
    > question.
    >
    > Anyway, Here is a POSH script that will do what you ask for in the
    > body of your post.
    > You need Excel on the machine you run this script on. The
    >
    > #<---- Begin Script -------->
    >
    > $a = get-date -format g
    > $row = 2
    > $xl = New-Object -c excel.application
    > $xl.visible = $True
    > $wb = $xl.workbooks.add()
    > $sh = $wb.sheets.item(1)
    > $sh.Range("A1:T1").Font.Bold = $true
    > $sh.Range("A:A").Font.Bold = $True
    > $sh.Cells.Item(1, 1) = "Computer Name"
    > $sh.Cells.Item(1, 2) = "Date Run " + $a
    > $computerlist = Get-Content 'c:\compters.txt'
    > foreach ($srv in $computerlist)
    > {
    > $sh.Cells.Item($row, 1) = $srv
    > $response = Get-WmiObject -query "Select * From Win32_PingStatus Where
    > Address = '$srv'"
    >
    > if( ($response -eq $null) -or ($response.StatusCode -ne 0)) {
    > $sh.Cells.Item($row, 2).Font.ColorIndex = 3
    > $sh.Cells.Item($row, 2) = "Does Not Ping"
    > $row++
    > } else { if ($response.TimeToLive -le 64)
    > {
    > $sh.Cells.Item($row, 2).Font.ColorIndex = 5
    > $sh.Cells.Item($row, 2) = "probably is a Unix host"
    > $row++
    > } Else {
    > $Var3 = Get-ChildItem -path \\$srv\c$ -recurse -include *.mdb -ea
    > continue
    > if ($Var3) {
    > $sh.Cells.Item($row, 3) = $Var3.FullName }
    > Else {
    > $sh.Cells.Item($row, 2).Font.ColorIndex = 3
    > $sh.Cells.Item($row, 2) = $error[0].tostring() }
    > $row++
    > }
    > } $sh.Cells.EntireColumn.AutoFit()
    > }
    >
    > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    > #
    > $wb.SaveAs("C:\temp\find_MDB.xls")
    > # close and release resources
    > $wb.close($false)
    > $xl.quit()
    > spps -n excel
    >

      My System SpecsSystem Spec

search workstations and servers by os version problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
OS Windows Version of Servers in AD atorres PowerShell 2 29 Dec 2009
no logon servers available when connecting to most servers in trus 2010 Server General 1 16 Oct 2009
Windows Search - Failed upgrade from Version V3 to V4 Danny O'Sullivan Vista General 0 10 Oct 2008
How to limit AD search to just servers. Jacob Sampson PowerShell 1 26 Sep 2008
Windows search empty after hibernate (home premium danish version) binderup Vista General 0 30 Apr 2007