Palito1916
Systems Engineer
So I have Windows Server 2003 AD with a lot of machines and PowerShell is not an option.
I run dsquery computer comand to give me devices inctive for 104 and removed some that could not be removed due to still being in use.
I am trying to come up with a VBScript to disable the devices in a TXT file with devices names but the script errors out.
This is what I am trying to use.
My Server errors out and says:
Line:16
Char:9
Error:Type mismatch
Error Code:800A000D
Appreciate all your help
I run dsquery computer comand to give me devices inctive for 104 and removed some that could not be removed due to still being in use.
I am trying to come up with a VBScript to disable the devices in a TXT file with devices names but the script errors out.
This is what I am trying to use.
Code:
Option Explicit
Dim strFileName, objFSO, objFile, strComputerName, objComputer
Dim arrComputerNames, intCount
' Specify the TXT file containing the list of computer names
strFileName = "C:\path\to\computers.txt"
' Read computer names from the TXT file into an array
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName, 1)
Do Until objFile.AtEndOfStream
strComputerName = Trim(objFile.ReadLine)
If strComputerName <> "" Then
ReDim Preserve arrComputerNames(intCount)
arrComputerNames(intCount) = strComputerName
intCount = intCount + 1
End If
Loop
objFile.Close
' Bind to each computer account and disable it
For Each strComputerName In arrComputerNames
On Error Resume Next
Set objComputer = GetObject("LDAP://" & strComputerName)
If Err.Number = 0 Then
' Check if the computer account is not already disabled
If Not objComputer.AccountDisabled Then
' Disable the computer account
objComputer.AccountDisabled = True
objComputer.SetInfo
WScript.Echo "Disabled computer account: " & strComputerName
Else
WScript.Echo "Computer account is already disabled: " & strComputerName
End If
Set objComputer = Nothing
Else
WScript.Echo "Error binding to computer account " & strComputerName & ": " & Err.Description
End If
On Error GoTo 0
Next
WScript.Echo "Script completed."
My Server errors out and says:
Line:16
Char:9
Error:Type mismatch
Error Code:800A000D
Appreciate all your help