I am writing a script for a business. Just need some help. Basically I want to have the script run against multiple machines matching a certain department area.
The unc used in active directory is roomRoomNumber-comp#.
The code will be run through active directory so every computer in a sense will be local, even though the code wont work now since that machine is not avaliable from here I need to know that the wildcard will get all computers matching the first amount of characters.
For example, the code attached (targetComputer =) runs only on TRC210-10, however there are 30 computers in that room ranging from TRC210-01 to TRC210-30.
Each computer will run the script at login and it will integrate as though it were local through active directory.
Put in short, I need to make it so that my code uses TRC210-* (or some equivelent) and then runs the if then else statement against any computer that matches the beginning line "TRC210-"
Can you guys help me out a bit?
Kurt (Code below)
--------------
Dim objNetwork2
Set objNetwork = CreateObject("WScript.Network")
Set objNetwork2 = CreateObject("WScript.Network")
Set WshNetwork = CreateObject("WScript.Network")
strComputer = "TRC210-10"
If objNetwork2.Computername = UCase(strComputer) Then
' Mapping of Network Drives
objNetwork.MapNetworkDrive "X:" , "\\coho\groups"
objNetwork.MapNetworkDrive "Y:" , "\\coho\network"
objNetwork.MapNetworkDrive "Z:" , "\\coho\apps"
' Mapping of Remote Printers
WshNetwork.AddWindowsPrinterConnection "\\chinook\TC210_HP4250"
WshNetwork.AddWindowsPrinterConnection "\\chinook\TC218_HP2840"
WshNetwork.AddWindowsPrinterConnection "\\chinook\TC218_HP3500"
Else
WScript.Echo("Network Drives/Printers could not be assigned at this time")
End If
The unc used in active directory is roomRoomNumber-comp#.
The code will be run through active directory so every computer in a sense will be local, even though the code wont work now since that machine is not avaliable from here I need to know that the wildcard will get all computers matching the first amount of characters.
For example, the code attached (targetComputer =) runs only on TRC210-10, however there are 30 computers in that room ranging from TRC210-01 to TRC210-30.
Each computer will run the script at login and it will integrate as though it were local through active directory.
Put in short, I need to make it so that my code uses TRC210-* (or some equivelent) and then runs the if then else statement against any computer that matches the beginning line "TRC210-"
Can you guys help me out a bit?
Kurt (Code below)
--------------
Dim objNetwork2
Set objNetwork = CreateObject("WScript.Network")
Set objNetwork2 = CreateObject("WScript.Network")
Set WshNetwork = CreateObject("WScript.Network")
strComputer = "TRC210-10"
If objNetwork2.Computername = UCase(strComputer) Then
' Mapping of Network Drives
objNetwork.MapNetworkDrive "X:" , "\\coho\groups"
objNetwork.MapNetworkDrive "Y:" , "\\coho\network"
objNetwork.MapNetworkDrive "Z:" , "\\coho\apps"
' Mapping of Remote Printers
WshNetwork.AddWindowsPrinterConnection "\\chinook\TC210_HP4250"
WshNetwork.AddWindowsPrinterConnection "\\chinook\TC218_HP2840"
WshNetwork.AddWindowsPrinterConnection "\\chinook\TC218_HP3500"
Else
WScript.Echo("Network Drives/Printers could not be assigned at this time")
End If