locked
How to import list of users and rooms RRS feed

  • Question

  • Guys

    I need to set permissions from a list of users and a list of rooms,

    Import-Csv "C:\script\new.csv" | ForEach-Object {
    
    $Identity=$_.Identity
    $Permissions=$_.AccessRights
    $User=$_.User
    $path=$Identity+”:\Deleted Items”
    
    Add-MailboxFolderPermission –identity $path -user $user -AccessRights $Permissions}

    This is what I have at the moment but it'll only do each line, is there a way I can just have a list of users, a seperate list of rooms and then it works through each room applying the rights?

    Thanks

    Alex

    Wednesday, December 3, 2014 12:12 PM

Answers

  • Hi Alex,

    yes there is.

    Cheers,
    Fred

    Ps.: To avoid being completely troll'y, here's an example on how to do that:

    $Users = Import-Csv "C:\script\UsersAndAccessRights.csv"
    $Rooms = Get-Content "C:\script\Rooms.txt"
    
    foreach ($Room in $Rooms)
    {
    	$Path = $Room + "\Deleted Items"
    	foreach ($User in $Users)
    	{
    		Add-MailboxFolderPermission -Identity $Path -User $User.User -AccessRights $User.AccessRights
    	}
    }


    There's no place like 127.0.0.1

    • Marked as answer by Alexgreen312 Wednesday, December 3, 2014 1:35 PM
    Wednesday, December 3, 2014 12:44 PM

All replies

  • Hi Alex,

    yes there is.

    Cheers,
    Fred

    Ps.: To avoid being completely troll'y, here's an example on how to do that:

    $Users = Import-Csv "C:\script\UsersAndAccessRights.csv"
    $Rooms = Get-Content "C:\script\Rooms.txt"
    
    foreach ($Room in $Rooms)
    {
    	$Path = $Room + "\Deleted Items"
    	foreach ($User in $Users)
    	{
    		Add-MailboxFolderPermission -Identity $Path -User $User.User -AccessRights $User.AccessRights
    	}
    }


    There's no place like 127.0.0.1

    • Marked as answer by Alexgreen312 Wednesday, December 3, 2014 1:35 PM
    Wednesday, December 3, 2014 12:44 PM
  • Fred,

    I love you, I don't care, I'm going to admit my man love for that bit of code. I don't know why I didn't see it before!

    Thanks


    Alex

    Wednesday, December 3, 2014 1:29 PM