Copy files based on "office" property for user on AD in VBscript.

Hi,

I'd like -using VBS - to copy some files to the desktop of users that have "London" as their Office in the Properties of their user account on the AD.

Please advise how to do this?
Many thanks
Antonio KingIT ManagerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Chris DentConnect With a Mentor PowerShell DeveloperCommented:

Were you looking to run that as a logon script?

Getting the office is moderately straight-forward, see the snippet below.

HTH

Chris

Set objADSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objADSysInfo.UserName)
 
strOffice = objUser.Get("physicalDeliveryOfficeName")
 
Set objUser = Nothing
Set objADSysInfo = Nothing
 
If InStr(strOffice, "London") > 0 Then
    ' Continue on to copying file ...
End If

Open in new window

0
All Courses

From novice to tech pro — start learning today.