Ok, I think I've got the concept down, but its pretty ugly to look at. There's a couple of way I could go to 'clean' it up a bit, a sub or a function. I don't think the function will work correctly, the sub will most likely work better, but I'd like few opinions first. Keep in mind I'm covering all the OS's starting with Win95 to Win2K. WSH has not been installed unless the OS has it built in. The possible workstation names are "SxxxxYxx" or "(W/L)xxxxxx".
Code:
$machine = "W094562a154"
$computername = "Failed"
$sType=SubStr($machine,1,1)
Select
Case $sType = "S"
$sLocation=SubStr($machine,2,4)
$sFunction=SubStr($machine,6,1)
$sNode=SubStr($machine,7,2)
$sLocation2=Val($sLocation)
Select
Case Len($sLocation2) = 1
$sLocation3 = SubStr($sLocation,4)
If $sLocation2=$sLocation3
Select
Case $sLocation >= "0002" AND $sLocation <= "0999"
Select
Case $sFunction = "N" OR $sFunction = "L" OR $sFunction = "R" OR $sFunction = "H"
OR $sFunction = "E" OR $sFunction = "K" OR $sFunction = "S" OR $sFunction = "V"
Select
Case $sNode >= "01" AND $sNode <= "99"
$computername = "Store"
EndSelect
EndSelect
EndSelect
EndIf
Case Len($sLocation2) = 2
$sLocation3 = SubStr($sLocation,3)
If $sLocation2=$sLocation3
Select
Case $sLocation >= "0002" AND $sLocation <= "0999"
Select
Case $sFunction = "N" OR $sFunction = "L" OR $sFunction = "R" OR $sFunction = "H"
OR $sFunction = "E" OR $sFunction = "K" OR $sFunction = "S" OR $sFunction = "V"
Select
Case $sNode >= "01" AND $sNode <= "99"
$computername = "Store"
EndSelect
EndSelect
EndSelect
EndIf
Case Len($sLocation2) = 3
$sLocation3 = SubStr($sLocation,2)
If $sLocation2=$sLocation3
Select
Case $sLocation >= "0002" AND $sLocation <= "0999"
Select
Case $sFunction = "N" OR $sFunction = "L" OR $sFunction = "R" OR $sFunction = "H"
OR $sFunction = "E" OR $sFunction = "K" OR $sFunction = "S" OR $sFunction = "V"
Select
Case $sNode >= "01" AND $sNode <= "99"
$computername = "Store"
EndSelect
EndSelect
EndSelect
EndIf
EndSelect
Case $sType = "W" OR $sType = "L"
$sAsset=SubStr($machine,2,6)
$sAsset2=Val($sAsset)
If Len($sAsset2) < 6
$sAsset = SubStr($machine,3,5)
EndIf
Select
Case $sAsset=$sAsset2
If $sAsset >= "000001" AND $sAsset <= "999999"
$computername = "Corp"
EndIf
EndSelect
EndSelect
? $computername
Any one?