Mark Pietersz
(Getting the hang of it)
2002-06-17 09:48 AM
Getting The OS Of A Remote Machine

Folks,

Kix provides the wonderful macro @PRODUCTTYPE. Is there something similar that I can use to get the OS of a remote machine. I have already tried

$oDomain = getobject("WinNT://$sDomainName")
$oDomain.filter = "computer",""
For each $oComputer in $oDomain
$oComputer.operatingsystem
$oComputer.operatingsystemversion
etc...

however the return values are
Windows NT
4.0
I was wanting to know whether the target machine is a server or workstation

The verbage for the ".role" property suggests that it may be useful however in my environment the return value is nothing.
"Role Gets and sets role of this computer (server, workstation, and so on) "

Furthermore, the curious thing is that the following produces no screen output
$x = "Role=" + $oComputer.role + ""
? $x
The following at least outputs the text "Role=" to the screen
$x = "Role=" ;+ $oComputer.role + ""
? $x

What is it about some of these properties that seems to zap the contents of variables ?


LonkeroAdministrator
(KiX Master Guru)
2002-06-17 10:10 AM
Re: Getting The OS Of A Remote Machine

mmm...
is there any specific reason why you don't want to use normal script like:
code:
$pp = ReadValue("\\machines_name_or_IP\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType")

select
Case $pp="WinNT"
$os="Windows NT/2k Workstation"
Case $pp="LANMANNT"
$os="Windows NT 4.0 Domain Controller"
Case $pp="ServerNT"
$os="Windows NT 4.0 Member Server"
endselect

to get all wintosh tree, need little bit more intelligence, but you probably get my point...


Mark Pietersz
(Getting the hang of it)
2002-06-17 11:31 AM
Re: Getting The OS Of A Remote Machine

Lonkero,

The only reason that I didn't do that is that I didn't know about it !! Sensational. Thanks.
There's so much in the registry that is not clear. Why do I have CurrentControlSet, CurrentControlSet001 and CurrentControlSet002 ?
I also need to know what logical/physical drives exist on a machine. Can the registry provide that info ? I've looked under "Diskcontroller" and DeviceMap\Scsi but is there makes little sense to me.
Is there a "Dummies Guide To The MS Registry" book available ?


LonkeroAdministrator
(KiX Master Guru)
2002-06-17 01:24 PM
Re: Getting The OS Of A Remote Machine

dummy book for reg...
I think it's called power users or sys admins
or something like that...
but it's for dummies.

currentcontrolset is what it says.
currentcontrolset001 is the one before that.
so when you try to load crashing machine from
last working config, I think it tries to use that.
002 is older.
I'm not sure, I've allways thought that they get updated on every boot.
so currentcontrolset001 changes are moved on the next bootup to 002.

affective things are anyway in the set without numbers [Smile]

about that hardware stuff, I remember more than few scripts been posted in here, so try searching on scripts forum and from http://home.wanadoo.nl/scripting/ you get some tools and bases for scripts on stable base.

cheers,


LonkeroAdministrator
(KiX Master Guru)
2002-06-17 02:14 PM
Re: Getting The OS Of A Remote Machine

for drives currently available on remote machine you could use registry or:
code:
break on
$machine= "\\what_ever_you_want_to_check_on"
$ascii = 67 ; "C"
while $ascii < 91 ; "Z"
$drive = $machine+"\"+chr($ascii)+"$"
if exist ( $drive )
?"Drive $drive has "+getdiskspace($drive)+" bytes free"
endif
$ascii=$ascii+1
loop
exit

this works only NT/2000/XP without any tricks.


Radimus
(KiX Supporter)
2002-06-17 06:02 PM
Re: Getting The OS Of A Remote Machine

I love my UDF...

code:
? wmiquery("Caption","Win32_OperatingSystem","$computername")
? wmiquery("CSDVersion","Win32_OperatingSystem","$computername")
? wmiquery("SerialNumber","Win32_OperatingSystem","$computername")
? wmiquery("OSProductSuite","Win32_OperatingSystem","$computername")
? wmiquery("Description","Win32_OperatingSystem","$computername")
? wmiquery("InstallDate","Win32_OperatingSystem","$computername")



[ 17 June 2002, 18:03: Message edited by: Radimus ]


LonkeroAdministrator
(KiX Master Guru)
2002-06-17 06:07 PM
Re: Getting The OS Of A Remote Machine

didn't even think about that!
chees, if one has complete UDF, it'd be sin not to use it, right?


Radimus
(KiX Supporter)
2002-06-17 06:57 PM
Re: Getting The OS Of A Remote Machine

I am starting to collect the 'essential UDF kit' my scripts are getting smaller, but my UDF lib is getting bigger.

The WMIQuery() was the first one in... along with WshShortCut, XlsInputBox, ServiceRun, ServiceStartup, regwrite, FindPROC(modified killproc), Groupmembers, DelDir (once I neutered it for null input), and Ping. there are a few others, but are my lan-specific

Hopefully, the IE library will get working better...


ShawnAdministrator
(KiX Supporter)
2002-06-17 07:02 PM
Re: Getting The OS Of A Remote Machine

Radimus, you got a web site, right ? Why don't you post some of this stuff in downloadable form, like your work-in-progress IE GUI Library, that way, we can always get the latest and greatest, instead of copy-pasting it from the board.

Radimus
(KiX Supporter)
2002-06-17 07:23 PM
Re: Getting The OS Of A Remote Machine

I though about that...

okey dokey... I'll do it tonight.

I have some there now, but it is my office's logon script. my boss wants me to rename the names and addresses in them anyway, for security.. I can understand that


Radimus
(KiX Supporter)
2002-06-18 02:03 AM
Re: Getting The OS Of A Remote Machine

I have uploaded the scripts and UDFs to http://www.wheelerfam.com/kixtart.htm

Mark Pietersz
(Getting the hang of it)
2002-06-25 07:46 AM
Re: Getting The OS Of A Remote Machine

Guys - thanks for the help to date
Is there any answer to my second question

"Furthermore, the curious thing is that the following produces no screen output
$x = "Role=" + $oComputer.role + ""
? $x
The following at least outputs the text "Role=" to the screen
$x = "Role=" ;+ $oComputer.role + ""
? $x

What is it about some of these properties that seems to zap the contents of variables "

Regards

Mark


**DONOTDELETE**
(Lurker)
2002-06-27 12:06 AM
Re: Getting The OS Of A Remote Machine

I have been using WMIQuery to retrieve the OS information from remote machines. It only seems to work on some machines. I thought at first that it only worked on Win2k, but it works on some NT4SP6 machines as well. It doesn't work on any of our NT 4 Terminal Servers (SP6).

What are the dependencies for WMIQuery?

Thanks,
Michael.


LonkeroAdministrator
(KiX Master Guru)
2002-06-27 12:11 AM
Re: Getting The OS Of A Remote Machine

wmi should be only one.
this means, the machine where it's run on, should have wmi installed.

if not working, report to:
http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=12;t=000117

cheers,