I'm still a bit confused about what you are trying to do.

Is it simply:
  • Identify the network
  • Identify the printers on the network
  • Add them


If this is the case you would be better off using a parameter file. The ini file format is ideal for this sort of thing. Each section key is the network, each entry is the printer path. The entry value is not important, but you can use it to identify the default printer for the network.

Your parameter file looks something like this:
Code:
[192.168.0.0]
\\PS1\Printer1=default
\\PS1\Printer2=printer
\\PS1\Printer2=printer
[192.168.1.0]
\\PS2\Printer10=printer
\\PS2\Printer14=default



The additional benefit of using a parameter file is that if you make any typing mistakes it only breaks the section that the mistake is in, it doesn't cause the entire script to fail.


Here is an example of how to dereference a variable:
Code:
$sVar1="This is the target variable"
$sVar2="$$sVar1"
$sVar3="This is the dereference variable"

$vDiscard=Execute("$$sVar3="+$sVar2)
"Dereference of $$sVar2='"+$sVar3+"'"+@CRLF



In this example the variable target is stored in $sVar1 the name is stored in $sVar2. $sVar3 is assigned the value of $sVar1 by using the variable name store in $sVar2.

So it can be done, however it is probably not the most appropriate solution for you.