[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 908
  • Last Modified:

how to find out inactive machines in a WIN2003 domain using WMI query from SMS

I need to delete inactive clients in my collection in SMS 2003. I am trying to find out a querty which will use WMI to find the inactive list in the domain and i do not have more rights in AD. i tried the last hardware scan option but it is not giving the correct list. My question: Can i use  a WMI query or a VB script to just find out inactive machines in my OU and use that query in SMS to find that list?
0
joseph7
Asked:
joseph7
1 Solution
 
weellioCommented:
found this, but not yet tested
'Obsolete_computer_accounts.vbs
'v1.5
'last modified April 2004
'Jeffery Hicks
'jhicks@jdhitsolutions.com
'http://www.jdhitsolutions.com
'Usage: cscript obsolete_computer_accounts.vbs
'Desc: Determine Obsolete Computer Accounts with user specified cutoff date
'You must have Domain Admin rights to properly use this script.
'You should use CSCRIPT to run this or you will get many, many
'dialog boxes.
 
' *********************************************************************************
' * THIS PROGRAM IS OFFERED AS IS AND MAY BE FREELY MODIFIED OR ALTERED AS        *
' * NECESSARY TO MEET YOUR NEEDS.  THE AUTHOR MAKES NO GUARANTEES OR WARRANTIES,  *
' * EXPRESS, IMPLIED OR OF ANY OTHER KIND TO THIS CODE OR ANY USER MODIFICATIONS. *
' * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED IN A SECURED LAB *
' * ENVIRONMENT. USE AT YOUR OWN RISK.                                            *
' *********************************************************************************
 
On Error Resume Next
 
dim DomainObj
dim wnet
 
set wnet=CreateObject("wscript.network")
DomainString=wnet.UserDomain
 
numDays=InputBox("What is the number of days for password age to use as a cutoff for Active Computer Accounts?  NO computer accounts will be deleted.","Check Active Computers","45")
 
if numDays="" then
 wscript.echo "No cutoff date specified or script cancelled."
 wscript.quit
end if
 
Set DomainObj = GetObject("WinNT://"&DomainString)
 
if err.number = 0 then
wscript.echo "Error connecting to " & DomainString    
wscript.echo "Err#" & err.number & " " & err.description
wscript.quit
end if
 
DomainObj.Filter = Array("computer")
Wscript.echo "Computer Accounts in " & DomainString & " older than " & numDays & " days based on password age."
For each Computer in DomainObj
    Set Account = GetObject("WinNT://" & DomainString & "/" & Computer.Name & "$")
    RefreshTime =  FormatNumber((Account.get("PasswordAge"))/86400,0)
    If CInt(RefreshTime) >= CInt(numDays) Then
       wscript.echo  "**DELETE** " & Computer.Name & "  (Password Age is " & RefreshTime & " days.)"
    End If
Next
 
set DomainObj=Nothing
Wscript.quit
 
'EOF

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now