hi there.
I work as an it techician in a company and i need som help :-)
I am having some trouble getting login scripts, run quickly after we upgrade our terminal server to windows 2008.somehow the logon procedure slows down when vbscrips are added to the login, eventhou the scripts itselft run fast and smooth when running it manualy.. win2008 terminal server suck .. so i thought that if we made a powershell script instead of vbscript maby the logon process will run faster , but i only know a littlebit about powershell scripting so I hope some one here could translate my vbscipt to a powershell so I could test if powershell login script run faster that vbscript in a win2008 terminalserver inviroment.
here is the script :
Set WshNetwork = WScript.CreateObject("WScript.Network")
On Error Resume Next
'-------------------------finding the name of the printerserver from a system variable
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Environment",,48)
For Each objItem in colItems
If objItem.name = "printserver" Then
PrintServer= "\\" & objItem.VariableValue & "\"
Exit For
End If
Next
' ----------------------- removing printers if a check file isn't there.
dim Res
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("w:\windows\stopPrint.txt") Then
Else
SET objPrinters = WshNetwork.EnumPrinterConnections
FOR intCounter = 0 TO objPrinters.Count - 1 STEP 2
if objPrinters.Item(intCounter+1) = "Microsoft XPS Document Writer" then
else
Res=WshNetwork.RemovePrinterConnection(objPrinters.Item(intCounter+1),TRUE,TRUE)
end if
Next
' -----------------------installing printer
WshNetwork.AddWindowsPrinterConnection PrintServer & "printer1"
WshNetwork.AddWindowsPrinterConnection PrintServer & "printer2"
WshNetwork.AddWindowsPrinterConnection PrintServer & "printer3"
WshNetwork.AddWindowsPrinterConnection PrintServer & "printer4"
WshNetwork.AddWindowsPrinterConnection PrintServer & "printToFile"
Set objFile = objFSO.CreateTextFile("w:\windows\stopPrint.txt")
End If
'-----------------------setup systemvarables
'Set WSHShell = WScript.CreateObject("WScript.Shell")
'SET objEnv = WshShell.Environment("USER")
'objEnv.item("testVariable") = "q:\test"
'set objEnv = nothing
'------------------------saetter default printer
WshNetwork.SetDefaultPrinter PrintServer & "printer1"
'------------------------cleaning up
Set WshNetwork = Nothing
Set colItems = Nothing
Set objWMIService = Nothing
Set objPrinters = Nothing
Set objFile = nothing
Set objFSO = nothing