bsharath
asked on
Need to find all machines without description
Hi,
I need a script which can find all machine which does not have a description in Mycomputer>properties>Comp uter name>computer description and another script to find whose machines in ads do not have a computer description.
Is there a way to get this info to a file.
Regards
Sharath
I need a script which can find all machine which does not have a description in Mycomputer>properties>Comp
Is there a way to get this info to a file.
Regards
Sharath
ASKER
Thanks the above script to query the computer description on ADS worked.
What about a script for
Mycomputer>properties>Comp uter name>computer description
What about a script for
Mycomputer>properties>Comp
copy and paste text between -----------start---------- - and --------end---- to a text file and save as computerdescription.vbs
you will need a inputfile input.txt in c:\ this file should contain all the machine name in such a way that one line should contain one machine name. you should not leave any space at last of input file.
you may change the line "set ofsfile=fso.opentextfile(" c:\input.t xt",ForRea ding, true)" to change input file name.
you may also use the command "dsquery * domainroot -scope subtree -attr cn -filter "(&(objectCategory=compute r)(!descri ption=*))" > c:\input.txt" to generate input file for you from AD.
you only have to delete the first line which should contain "cn". also make sure to replace all space to null
for this open the output file of above command i.e. c:\input.txt and in edit->replace ->"find ehat" type space (the spacebar" and leave the "replace with" blank, and click replace all, save the file and run following command on command prompt "cscript //nologo computerdescription.vbs > c:\descriptionout.txt"
you can then open the file in excel, use "|" as delimeter in text to column command for easy reading.
'--------------------start ---------- ---------
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const ForReading = 1
Const ForWriting = 2
set fso=CreateObject("Scriptin g.Filesyst emobject")
set ofsfile=fso.opentextfile(" c:\input.t xt",ForRea ding, true)
WScript.Echo "Computer Name|Computer Description"
do while not ofsfile.atendofstream
strline= ofsfile.readline
Set objWMIService = GetObject("winmgmts:\\" & strline & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("S ELECT * FROM Win32_OperatingSystem", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
if objItem.Description ="" then
WScript.Echo objItem.CSName & "|" & objItem.Description
end if
Next
loop
ofsfile.close
'------------------------- ------end- ---------- ---------- ----------
you will need a inputfile input.txt in c:\ this file should contain all the machine name in such a way that one line should contain one machine name. you should not leave any space at last of input file.
you may change the line "set ofsfile=fso.opentextfile("
you may also use the command "dsquery * domainroot -scope subtree -attr cn -filter "(&(objectCategory=compute
you only have to delete the first line which should contain "cn". also make sure to replace all space to null
for this open the output file of above command i.e. c:\input.txt and in edit->replace ->"find ehat" type space (the spacebar" and leave the "replace with" blank, and click replace all, save the file and run following command on command prompt "cscript //nologo computerdescription.vbs > c:\descriptionout.txt"
you can then open the file in excel, use "|" as delimeter in text to column command for easy reading.
'--------------------start
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const ForReading = 1
Const ForWriting = 2
set fso=CreateObject("Scriptin
set ofsfile=fso.opentextfile("
WScript.Echo "Computer Name|Computer Description"
do while not ofsfile.atendofstream
strline= ofsfile.readline
Set objWMIService = GetObject("winmgmts:\\" & strline & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("S
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
if objItem.Description ="" then
WScript.Echo objItem.CSName & "|" & objItem.Description
end if
Next
loop
ofsfile.close
'-------------------------
ASKER
This command is to get the Mycomputer description in windows ?
dsquery * domainroot -scope subtree -attr cn -filter "(&(objectCategory=compute r)(!descri ption=*))" > c:\input.txt
dsquery * domainroot -scope subtree -attr cn -filter "(&(objectCategory=compute
this will get you all the computer with blank description value in AD.
you can use this file as an input file for the script.
please cleanup the file before using it as input file to the script.
you can use this file as an input file for the script.
please cleanup the file before using it as input file to the script.
ASKER
What will the script do...
the script will read a line from c:\input.txt which is the name of the computer and use WMI to query if the description is available in computer properties. if it finds no description it writes computername on the console.
originally I have created this to query computer with or without description. you can change this to following to retrieve computer name and description of the computers for those there is any description set in the system properties. again the input file is c:\input.txt
'--------------------start ---------- ---------
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const ForReading = 1
Const ForWriting = 2
set fso=CreateObject("Scriptin g.Filesyst emobject")
set ofsfile=fso.opentextfile(" c:\input.t xt",ForRea ding, true)
WScript.Echo "Computer Name|Computer Description"
do while not ofsfile.atendofstream
strline= ofsfile.readline
Set objWMIService = GetObject("winmgmts:\\" & strline & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("S ELECT * FROM Win32_OperatingSystem", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
if objItem.Description <>"" then
WScript.Echo objItem.CSName & "|" & objItem.Description
end if
Next
loop
ofsfile.close
'------------------------- ------end- ---------- ---------- ----------
originally I have created this to query computer with or without description. you can change this to following to retrieve computer name and description of the computers for those there is any description set in the system properties. again the input file is c:\input.txt
'--------------------start
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const ForReading = 1
Const ForWriting = 2
set fso=CreateObject("Scriptin
set ofsfile=fso.opentextfile("
WScript.Echo "Computer Name|Computer Description"
do while not ofsfile.atendofstream
strline= ofsfile.readline
Set objWMIService = GetObject("winmgmts:\\" & strline & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("S
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
if objItem.Description <>"" then
WScript.Echo objItem.CSName & "|" & objItem.Description
end if
Next
loop
ofsfile.close
'-------------------------
ASKER
What does this mean
if you want to search GC use forestroot instead of domainroot in the command
if you want to search GC use forestroot instead of domainroot in the command
ASKER
I gave this command
C:\>cscript desc.vbs > c:\descriptionout.txt"
It still reading but no output...
C:\>cscript desc.vbs > c:\descriptionout.txt"
It still reading but no output...
if you are using domainrootthen this search is made against the domain database on DC.
when using forestroot the search is made against global catalogue database on the DC.
when using forestroot the search is made against global catalogue database on the DC.
how many computers are there in the input.txt
try running cscript desc.vbs and see any errors are there.
try running cscript desc.vbs and see any errors are there.
ASKER
it just goes on reading
C:\>cscript desc.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Computer Name|Computer Description
No output
C:\>cscript desc.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Computer Name|Computer Description
No output
i think tehre is something wrong with the input file. can you post first 10-15 lines of input.txt. this file should be in c:\
ASKER
Input file details
DEV-CHEN-PC160
DEV-CHEN-PC162
DEV-CHEN-SRV07
DEV-CHEN-PC146
DEV-CHEN-PC197
I get this when i run
Computer Name|Computer Description
DEV-CHEN-SRV07|
DEV-CHEN-PC183|
LORENT|
DEV-CHEN-PC746|
DEV-CHEN-PC160
DEV-CHEN-PC162
DEV-CHEN-SRV07
DEV-CHEN-PC146
DEV-CHEN-PC197
I get this when i run
Computer Name|Computer Description
DEV-CHEN-SRV07|
DEV-CHEN-PC183|
LORENT|
DEV-CHEN-PC746|
ASKER
I get this
C:\>cscript desc.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Computer Name|Computer Description
DEV-CHEN-SRV07|
DEV-CHEN-PC183|
LORENT|
DEV-CHEN-PC746|
C:\>cscript desc.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
Computer Name|Computer Description
DEV-CHEN-SRV07|
DEV-CHEN-PC183|
LORENT|
DEV-CHEN-PC746|
this is taking time because WMI takes some time in querying details.
if you have 100s of computer name in file this may take hours. this means these computers don't have description in their system properties. You may find some names missing in the list that means they have description set in system properties.
if you want to get name and description of all the machines with blank or non blank description
change
if objItem.Description <>"" then
WScript.Echo objItem.CSName & "|" & objItem.Description
end if
to
WScript.Echo objItem.CSName & "|" & objItem.Description
if you have 100s of computer name in file this may take hours. this means these computers don't have description in their system properties. You may find some names missing in the list that means they have description set in system properties.
if you want to get name and description of all the machines with blank or non blank description
change
if objItem.Description <>"" then
WScript.Echo objItem.CSName & "|" & objItem.Description
end if
to
WScript.Echo objItem.CSName & "|" & objItem.Description
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mailtosinghs:
It took 8 hrs to get the report.
But your script does not scall the machines in the network?
It took 8 hrs to get the report.
But your script does not scall the machines in the network?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@echo off
:: look for pc description
:: from NET VIEW if executed without parameters
:: or From File Ex.: chkall-desc.cmd filelist.txt
:: check only pc "alive"
:: v0.1
::by gastone canali
setlocal
pushd %~d0%~p0
set pclist=
set pclist=%~n1%~x1
set keyP=HKEY_LOCAL_MACHINE\SY STEM\Curre ntControlS et\Service s\lanmanse rver\param eters
set keyN=srvcomment
if "%pclist%"=="" (
echo PC list not found: look for pc in "net view"
for /f %%p in ('net view ^|find "\\"') do call :_CHKPC %%p
) else (
for /f %%p in ('type "%pclist%"') do call :_CHKPC %%p
)
goto :_END
:_CHKPC
set pc=%1
if +%pc:~0,+1%+==+\+ set pc=%pc:~2%
ping %pc% -n 1|find "TTL=" >nul && call :_DESCR %pc%
ping %pc% -n 1|find "TTL=" >nul || echo %pc%^|switched off
goto :_EOF
:_DESCR
(reg query \\%1\%KeyP% /v %keyN% 2>nul|find "srvcomment" 2>nul >nul)&&( call :_FOUND %1)||call :_NOTFOUND %1
goto :_EOF
:_FOUND
for /f "tokens=2*" %%a in ('reg query \\%1\%keyP% /v %keyN% 2^>nul^|find "srvcomment"') do (echo %1^|%%b)
goto :_EOF
:_NOTFOUND
echo %1^|EMPTY
goto :_EOF
:_END
:_EOF
::ciao da gas
:: look for pc description
:: from NET VIEW if executed without parameters
:: or From File Ex.: chkall-desc.cmd filelist.txt
:: check only pc "alive"
:: v0.1
::by gastone canali
setlocal
pushd %~d0%~p0
set pclist=
set pclist=%~n1%~x1
set keyP=HKEY_LOCAL_MACHINE\SY
set keyN=srvcomment
if "%pclist%"=="" (
echo PC list not found: look for pc in "net view"
for /f %%p in ('net view ^|find "\\"') do call :_CHKPC %%p
) else (
for /f %%p in ('type "%pclist%"') do call :_CHKPC %%p
)
goto :_END
:_CHKPC
set pc=%1
if +%pc:~0,+1%+==+\+ set pc=%pc:~2%
ping %pc% -n 1|find "TTL=" >nul && call :_DESCR %pc%
ping %pc% -n 1|find "TTL=" >nul || echo %pc%^|switched off
goto :_EOF
:_DESCR
(reg query \\%1\%KeyP% /v %keyN% 2>nul|find "srvcomment" 2>nul >nul)&&( call :_FOUND %1)||call :_NOTFOUND %1
goto :_EOF
:_FOUND
for /f "tokens=2*" %%a in ('reg query \\%1\%keyP% /v %keyN% 2^>nul^|find "srvcomment"') do (echo %1^|%%b)
goto :_EOF
:_NOTFOUND
echo %1^|EMPTY
goto :_EOF
:_END
:_EOF
::ciao da gas
ASKER
Thanks a lot
dsquery * domainroot -scope subtree -attr cn adspath -filter "(&(objectCategory=compute
above command will give you list of computers in whose description is not set in AD.
this will give you tab delimited output in table format. you can add > or >> and filename to redirect output in a file
example:
"dsquery * domainroot -scope subtree -attr cn adspath -filter "(&(objectCategory=compute
in case you want more attribute you can write list of attribute after -attr separated with a space
ex: -attr cn location samaccountname adspath
etc
.
if you want to search GC use forestroot instead of domainroot in the command