Windows Vista Forums

map drives based on group membership

  1. #1


    PSnewbie Guest

    map drives based on group membership

    I need to create a logon script with powershell that will map network drives
    conditionally based on group membership. We currently have a vbs script that
    works but we are being told to test this using powershell. Please help!!

      My System SpecsSystem Spec

  2. #2


    Vadims Podans [MVP] Guest

    Re: map drives based on group membership

    mm..something like this:
    $filter = "(&(objectcategory=user)(Name=$env:username))"
    $ds = New-object
    System.DirectoryServices.DirectorySearcher([ADSI]"",$filter)
    $user = ($ds.Findone()).properties.memberof
    switch -wildcard ($user) {
    "*domain admins*" {net use v: \\server1\share1}
    "*special group*" {net use k: \\server2\share2}
    <..>
    }

    or like this:
    $filter = "(&(objectcategory=user)(Name=$env:username))"
    $ds = New-object
    System.DirectoryServices.DirectorySearcher([ADSI]"",$filter)
    $user = ($ds.Findone()).properties.memberof
    foreach ($grouppath in $user) {
    $group = ([adsi]"LDAP://$($grouppath.tostring())").sAMAccountname
    switch ($group) {
    "domain admins" {net use v: \\server1\share1}
    "special group" {net use k: \\server2\share2}
    <..>
    }
    }

    first script will map only one network drive, the second will map drives for
    each group matching in SWITCH statement.
    --
    WBR, Vadims Podans
    MVP: PowerShell
    PowerShell blog - www.sysadmins.lv

    "PSnewbie" <PSnewbie@xxxxxx> rakstīja ziņojumā
    "news:067B3666-5402-44BD-B6C8-41DC484B8395@xxxxxx"...

    > I need to create a logon script with powershell that will map network
    > drives
    > conditionally based on group membership. We currently have a vbs script
    > that
    > works but we are being told to test this using powershell. Please help!!

      My System SpecsSystem Spec

  3. #3


    Al Dunbar Guest

    Re: map drives based on group membership

    Just curious... does powershell see much service in logon scripts? I know it
    is more powerful than batch, vbscript, and kixtart, but it seems to me a bit
    of overkill. Other than one's familiarity with it, what powershell features
    make it more suitable than the other languages for this task?

    /Al

    "Vadims Podans [MVP]" <vpodans> wrote in message
    news:F5EF297C-893E-4535-9A3B-75DBE4959F71@xxxxxx

    > mm..something like this:
    > $filter = "(&(objectcategory=user)(Name=$env:username))"
    > $ds = New-object
    > System.DirectoryServices.DirectorySearcher([ADSI]"",$filter)
    > $user = ($ds.Findone()).properties.memberof
    > switch -wildcard ($user) {
    > "*domain admins*" {net use v: \\server1\share1}
    > "*special group*" {net use k: \\server2\share2}
    > <..>
    > }
    >
    > or like this:
    > $filter = "(&(objectcategory=user)(Name=$env:username))"
    > $ds = New-object
    > System.DirectoryServices.DirectorySearcher([ADSI]"",$filter)
    > $user = ($ds.Findone()).properties.memberof
    > foreach ($grouppath in $user) {
    > $group = ([adsi]"LDAP://$($grouppath.tostring())").sAMAccountname
    > switch ($group) {
    > "domain admins" {net use v: \\server1\share1}
    > "special group" {net use k: \\server2\share2}
    > <..>
    > }
    > }
    >
    > first script will map only one network drive, the second will map drives
    > for each group matching in SWITCH statement.
    > --
    > WBR, Vadims Podans
    > MVP: PowerShell
    > PowerShell blog - www.sysadmins.lv
    >
    > "PSnewbie" <PSnewbie@xxxxxx> rakstija zinojuma
    > "news:067B3666-5402-44BD-B6C8-41DC484B8395@xxxxxx"...

    >> I need to create a logon script with powershell that will map network
    >> drives
    >> conditionally based on group membership. We currently have a vbs script
    >> that
    >> works but we are being told to test this using powershell. Please help!!
    >


      My System SpecsSystem Spec

map drives based on group membership

Similar Threads
Thread Forum
Re: Enumerate User's AD Group Membership
"Dennis B." <dbiscontin@xxxxxx> wrote in message news:%236rXoqR%23JHA.4376@xxxxxx I have several VBScript functions linked here: ...
VB Script
Check group membership across domains
Hello, I am having the worst time trying to figure out how to use Powershell to search the entire forest for a user's universal group membership....
PowerShell
check group membership
I need to make a powershell script that i run while user logon. It should check if the user is in group called Testusers and then run command...
PowerShell
Script to query user information based upon group membership
Hi, I'm trying to write a script that pulls the following information based upon the group the user is a member of: Username First Name, Last...
VB Script
Get group membership
Hello, I am using the following code to obtain group membership: $group = "LDAP://cn=group,ou=OU,dc=domain,dc=org" $group.member This...
PowerShell
Get Group Membership for a User
I am trying to use the Quest AD stuff to get all of the groups a particular user belongs to. I am getting errors if I try to pipe the...
PowerShell
Group Membership
Am I missing something? In OE, if I click a contacts Properties there is an "Other" tab. Two things are in the Other tab: Notes and Group...
Vista mail