i am testing a simple printer/netdrive logon script. here is the code...
-CODE---------------------------------------------------
option explicit
on error resume next
dim oNet, adsi, curUser
const cert_group = "OU=ACCESSBILITY GROUP"
const fin_group = "OU=FINANCE SUPPORT GROUP"
const test_group = "OU=TESTHQ"
set oNet = CreateObject("Wscript.Network"
set adsi = CreateObject("ADSystemInfo"
set curUser = GetObject("LDAP://" & adsi.UserName)
oNet.MapNetworkDrive "T:", "\\Server\Share"
'Cert
if instr(adsi.username, cert_group) then
oNet.MapNetworkDrive "P:", "\\Server\Share"
oNet.AddWindowsPrinterConnection "\\Server\Printer"
oNet.SetDefaultPrinter "\\Server\Printer"
'Finance
elseif instr(adsi.username, fin_group) then
oNet.AddWindowsPrinterConnection "\\Server\Printer"
oNet.SetDefaultPrinter "\\Server\Printer"
'TESTHQ
elseif instr(adsi.username, test_group) then
oNet.MapNetworkDrive "N:", "\\Server\Share"
oNet.AddWindowsPrinterConnection "\\Server\Printer"
oNet.SetDefaultPrinter "\\Server\Printer"
Wscript.Echo "TESTHQ - Executed"
end if
set oNet = nothing
set adsi = nothing
set currentUser = nothing
-CODE---------------------------------------------------
i have created a test user in 'TESTHQ' OU. The script gets executed through GPO (Echo gets executed), but it doesnt add printers.
-CODE---------------------------------------------------
option explicit
on error resume next
dim oNet, adsi, curUser
const cert_group = "OU=ACCESSBILITY GROUP"
const fin_group = "OU=FINANCE SUPPORT GROUP"
const test_group = "OU=TESTHQ"
set oNet = CreateObject("Wscript.Network"
set adsi = CreateObject("ADSystemInfo"
set curUser = GetObject("LDAP://" & adsi.UserName)
oNet.MapNetworkDrive "T:", "\\Server\Share"
'Cert
if instr(adsi.username, cert_group) then
oNet.MapNetworkDrive "P:", "\\Server\Share"
oNet.AddWindowsPrinterConnection "\\Server\Printer"
oNet.SetDefaultPrinter "\\Server\Printer"
'Finance
elseif instr(adsi.username, fin_group) then
oNet.AddWindowsPrinterConnection "\\Server\Printer"
oNet.SetDefaultPrinter "\\Server\Printer"
'TESTHQ
elseif instr(adsi.username, test_group) then
oNet.MapNetworkDrive "N:", "\\Server\Share"
oNet.AddWindowsPrinterConnection "\\Server\Printer"
oNet.SetDefaultPrinter "\\Server\Printer"
Wscript.Echo "TESTHQ - Executed"
end if
set oNet = nothing
set adsi = nothing
set currentUser = nothing
-CODE---------------------------------------------------
i have created a test user in 'TESTHQ' OU. The script gets executed through GPO (Echo gets executed), but it doesnt add printers.