Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do something on computer via using FQDN name

Status
Not open for further replies.

fAisha

IS-IT--Management
Jan 13, 2010
7
PL
I have the script who check something.
I need give my colleagues the possibility to run script on the computer, which name he write in Message Box.

So i have a conception:

Give FQDN name to script
And do my script.

Any idea how to realize it?
 
I wrote something like it.
It works, but wscript.echo return 2 message "Something is wrong". Script don't want do process my loop. Anybody know how to do it? :(


On Error Resume Next

Dim ComputerName
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20


strComputer = "."
Set dict = CreateObject("Scripting.Dictionary")

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
If Len(objItem.DNSDomain) > 0 And Len(objItem.DNSHostName) Then
dict.Add (objItem.DNSHostName & "." & objItem.DNSDomain), dict.Count
End If
Next



fqdnArray = dict.Keys

For Each fqdn In fqdnArray
if fqdn = "HR-Computers.miami.contoso.com." then
WScript.Echo fqdn
else
wscript.echo "Something is wrong"
end if


Next
 
can you have more than one network adapter which has a configuration other than HR-Computers.miami.contoso.com?

comment out the On Error Resume Next to clarify if you have any run time errors which are causing issues.

if you have no runtimes, then your script is behaving as you have coded it. if that is the case then i would add some more information gathering so you can see waht you are 'really' returning in your WMI query.

For Each objItem In colItems
If Len(objItem.DNSDomain) > 0 And Len(objItem.DNSHostName) Then
Wscript.Echo "adding to dictionary " & objItem.DNSHostName & "." & objItem.DNSDomain & " dic.count = " & CStr(dict.Count)
dict.Add (objItem.DNSHostName & "." & objItem.DNSDomain), dict.Count

End If
Next

'then later

For Each fqdn In fqdnArray
wscript.echo "will compare " & fqdn & " against " & "HR-Computers.miami.contoso.com."
if fqdn = "HR-Computers.miami.contoso.com." then
WScript.Echo fqdn
else
wscript.echo "Something is wrong"
end if
Next
 
i guess my real point is that we work in IT, information technology. 'information' is the important part. you have lots of information in your script, but you choose not to share it with yourself. This is your limiting factor
 
>if fqdn = "HR-Computers.miami.contoso.com." then
[tt]if strcomp(fqdn,"HR-Computers.miami.contoso.com",1)=0 then[/tt]

ps. Are you sure there is a dot at the end, after com?
 
No, it will be without dot.

There's one network adapter.
But I found a mistake: FQDN is case - sensitive, becaust when I imporive it, everything works perfectly :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top