Sorry for the off topic post, but since many of you are powershell
whizzes, I thought I'd give it a try.  And forgive my inefficient
code...

So I am trying to put together a script to get the value of a registry
key for every computer in the domain - this case the WSUS susclientid
- and have come up with this (after plagiarizing the connection to
remote registry with the .NET object):

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$erroractionpreference = "SilentlyContinue"
Write-Host "Server                        Value"
Write-Host "------------------------------------------------------------------"

Foreach($srv in get-qadcomputer){

        $srvname = $srv.name
        $key = "SOFTWARE\Microsoft\Windows\CurrentVersion\windowsupdate"
        $type = [Microsoft.Win32.RegistryHive]::LocalMachine
        $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, 
$srvname)
        $regKey = $regKey.OpenSubKey($key)
        $val = $regKey.GetValue("susclientid")
                Write-host $srvname.PadRight(30) -nonewline
                Write-Host $val
        $val = "-----"
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

And it sort of works.  I think I have a few things to deal with in
error handling and output format, but debugging and figuring that out
is quite difficult since the script takes *hours* to run.  I think the
problem is that of the 725 computer objects in this domain, many of
them are offline and the .NET object needs to timeout on each system
that it cannot reach.  And the timeout period appears to be ~45
seconds.

Would anyone be able to tell me how I can set the timeout of the
[Microsoft.Win32.RegistryKey] connection down to like 5 seconds?

thanks and sorry again for the off topic question.

b

Reply via email to