Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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
0
Antonio King
Asked:
Antonio King
1 Solution
 
Chris DentPowerShell 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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now