Check the Active Directory Server for the remote computer name

JimRon

New Member
Joined
Oct 22, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I am not exactly sure if this is the correct area to post this question. A bit of the backstory is I am attempting to code in VBA a small macro/program that does three things. Two of these I have got working correctly. The third one is proving to be a bit harder to get going as I have not been able to find any useful information about what I am trying to do. What the macro/program does is take the serial number scanned or keyed in, rename it the correct format for imaging and deployment based on machine type. What I having issues with is getting it verified on the domain server without manually checking. It becomes a problem when I have 6000+ units to verify. I am looking for a way to add to my code a few lines to allow excel to check and see if the computer is listed on the domain. I have copied and pasted some of my code to help.

Private Sub cmdRecord_Click()

' Defines Varibles to be used
Dim iRow As Long
Dim LValue As String
Dim ws As Worksheet
Dim NameCheck As String
Set ws = Worksheets("Renamed Units")

' Searches for the next blank row for data entry
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

' Checks for a blank textbox and request data to be enter. Sets focus back on the textbox.
If Trim(Me.txtAsset.Value) = "" Then
Me.txtAsset.SetFocus
MsgBox "Pease enter an asset number."
End If

' Rename the asset number to desired name based upon checkbox value.
' Modified to reflect change in naming convention. (2019)

With ws
If chkbxOutdoor.Value = False Then
Me.txtAsset.Value = WorksheetFunction.Substitute(txtAsset.Value, "PU3W", "DSK-AP")
.Cells(iRow, 1).Value = Me.txtAsset.Text
NameCheck = Me.txtAsset.Text
Me.txtAsset.Value = ""
Me.txtAsset.SetFocus
Else
lastfive = Right(Me.txtAsset.Value, 5)
LValue = "LAP-TOP" & lastfive
.Cells(iRow, 1).Value = LValue
chkbxOutdoor.Value = False
NameCheck = LValue
Me.txtAsset.Value = ""
Me.txtAsset.SetFocus
End If

' Check the Active Directory Server for the remote computer name

Here I need code that will allow the variable NameCheck be used to is if the computer name is on the domain.


End With
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi and welcome
my thoughts would be given the list in AD is going to be 99% static I would export the group from AD and then import it into excel by going to the group and choose export
you could then just do a simple lookup on your list in excel
the lookup could be refreshed as and when multiple changes are made in AD
its a few years since I have used vba and excel against AD but I will see if I can find any of my code to see if it does help in connecting directly
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,178
Members
448,871
Latest member
hengshankouniuniu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top