Map Network Drive Based on Usershared drive attribute.

Tagged: 

This topic contains 6 replies, has 2 voices, and was last updated by Profile photo of Wilfredo Perez Wilfredo Perez 1 year, 7 months ago.

  • Author
    Posts
  • #33240
    Profile photo of Partho Sankar Roy
    Partho Sankar Roy
    Participant

    Hi, Guys, Would you be able to help me to create a script to map a network drive based on file share mapped on usershareddrive attribute in AD. Any idea would be helpful. I am not sure if this can be done via GPO. Thanks in advance.

  • #33242
    Profile photo of Wilfredo Perez
    Wilfredo Perez
    Participant

    Can we see your code. You will need to capture the username, look it up in AD and ..... Lets see some code. This would be done via GPO or make it part of your login script.

  • #33243
    Profile photo of Partho Sankar Roy
    Partho Sankar Roy
    Participant

    Here is what I was trying to but seems not getting it properly. I would then use it as logon script.

    $share=Get-ADUser -Identity $env:USERNAME -Properties * |select userSharedFolder

    New-PSDrive -Name G -PSProvider FileSystem -Root "$share"

  • #33244
    Profile photo of Partho Sankar Roy
    Partho Sankar Roy
    Participant

    $share=Get-ADUser -Identity $env:USERNAME -Properties * |select userSharedFolder

    New-PSDrive -Name G -PSProvider FileSystem -Root $share.userSharedFolder -Persist

    Tried this one now, seems its happening, but cant see the drive in windows explorer.

  • #33250
    Profile photo of Wilfredo Perez
    Wilfredo Perez
    Participant

    This worked for:
    $shared = (get-aduser -Identity $env:USERNAME -Properties *).HomeDirectory
    new-psdrive -Name G -PSProvider FileSystem -Root $shared

    No need to use Quotation marks in "$share"

  • #33252
    Profile photo of Partho Sankar Roy
    Partho Sankar Roy
    Participant

    Yeah you are right mate. But the problem is the script will run on win 7 clients. Now not all of them would have AD module installed. Do you think we can run it there somehow. I am thinking of using invoke command to some server where ad moudle would be there. Or if you have some other idea.

  • #33254
    Profile photo of Wilfredo Perez
    Wilfredo Perez
    Participant

    You can always import the modules from another computer

You must be logged in to reply to this topic.