Help with copying permissions and roles from one user to another. Issue with RoleDefinitions

I need help please. 
I’m trying to copy a role definition/name in SharePoint 2010 Powershell. 
The below is only a piece of my script, but I have to find '$SearchUser" and wherever it lives (webs, lists, groups), I need to add "$account" and copy permissions
from '$SearchUser" . We are doing this to limit certain users from access our farm (by adding a new AD domain that does not contain these users, then deleting the old domain). 
Every time I run it, it seems to mess up on this line: 
$role = $web.RoleDefinitions.[$newRoleDef].
 It is acting like the $newRoleDef is null, but it is not. 
When I outputfile the $newRoleDef, it has values, such as Read, Contribute.
foreach($Web in $Site.AllWebs)
if($Web.HasUniqueRoleAssignments -eq $True)
foreach($WebRoleAssignment in $Web.RoleAssignments )
if($WebRoleAssignment.Member.userlogin)
if($WebRoleAssignment.Member.LoginName -eq $SearchUser)
$WebUserPermissions=@()
foreach ($RoleDefinition in $WebRoleAssignment.RoleDefinitionBindings)
$newRoleDef = $RoleDefinition.Name
$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($account)
$role = $web.RoleDefinitions.[$newRoleDef]
$assignment.RoleDefinitionBindings.Add($role)
$_.RoleAssignments.Add($assignment)

Hi,
Glad to hear that you solve this issue, thanks for your sharing.
Thanks,
Linda Li
Linda Li
TechNet Community Support

Similar Messages

  • Is it possible to copy formats and styles from one document to another?

    Is it possible to copy formats and styles from one document to another?
    Or use a commen styledocument as a masterdocument?

    Only by creating a template with what you want.
    Apple has removed the ability to import styles inPAges 5 along with almost 100 other features.
    Peter

  • HT4878 How do i share my pictures, music and videos from one user to another on the same computer?

    How do i share my pictures, music and videos from one user to another on the same computer?

    lots of ways... you could use a thumb drive, you could drag files to the users public folder drop box, you could send it through email, you could use the internet servic called drop box (not to be confused with Apple's user public foldelr drop box).

  • I want to copy all the objects from one user to another... Please help

    Hii Experts.... I have a problem here. Please give me solution for this...
    I am using Oracle 11g on my windows XP system.
    I created a new user named "some"
    I want to copy all the objects from scott user to some user... Please help me
    Please Explain me in detailed way
    Thank you

    SowmyRaj wrote:
    Hii Experts.... I have a problem here. Please give me solution for this...
    I am using Oracle 11g on my windows XP system.
    I created a new user named "some"
    I want to copy all the objects from scott user to some user... Please help me
    If all what you are interested is Scott schema than no need to use the datapump or CTAS. Run demobld.sql in your schema and it would have all the objects of Scott.
    http://www.oracle.com/technology/sample_code/tech/sql_plus/htdocs/demobld.html
    HTH
    Aman....

  • How to transfer/ copy data and setting from one iPhone to another

    Hi,
    I recently cracked the screen on my 3G iPhone and a have fortunately managed to convince the insurance company to pay for a new one.
    I'd like to be able to transfer all my contacts, apps aand setting to the new phone. Only problem is I have to give back the old phone to get the new one.
    Any advice much appreciated, and thanks in advance to anyone who spend time to help

    The iPhone is designed to be synced with the supported applications on your computer for contact info, calendar events, and bookmarks. To transfer iTunes content and photos from your computer to your iPhone requires syncing with iTunes. Photos captured by your iPhone should be imported by your computer as with any other camera. The imported photos can be transferred back to your iPhone via the iTunes sync process.
    iTunes also creates and maintains a backup of your iPhone that includes data such as most iPhone settings, email account settings, SMS messages, notes, recent calls, call favorites, 3rd party app settings and data created and stored by 3rd party apps, contact info, and photos captured by your iPhone - but not a good idea to depend on the backup only for the last 2. Sync contact info with a supported application on your computer and import photos that were captured by your iPhone before giving up your iPhone. You can restore your new iPhone from your existing iPhone's backup followed by a sync.

  • How to copy procedures and packages from one server to another?

    Hi,
    I have 439 packages and 178 procedures located in one server called MAXWELL.
    I need to copy these objects to another server called TITAN.
    The schema names is SPCBR in both servers.
    So both servers have an instance running with this schema SPCBR.
    SPCBR in TITAN server has their tables with table data which was generated by an export/import process from MAXWELL server.
    However, procedures and packages were not copied by the export/import because I used the clause 'tables'.
    Now, what can I do in order to equalize procedures and packages in both databases? I can't risk in damaging or duplicating data in my database located in TITAN server, ok?
    Thanks,

    Another simple alternative, according to AskTom (http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:454220160386)
    ---------------- getcode.sql ----------------------------
    set feedback off
    set heading off
    set termout off
    set linesize 1000
    set trimspool on
    set verify off
    spool &1..sql
    prompt set define off
    select decode( type||'-'||to_char(line,'fm99999'),
    'PACKAGE BODY-1', '/'||chr(10),
    null) ||
    decode(line,1,'create or replace ', '' ) ||
    text text
    from user_source
    where name = upper('&&1')
    order by type, line;
    prompt /
    prompt set define on
    spool off
    set feedback on
    set heading on
    set termout on
    set linesize 100
    ------------------- eof --------------------------------
    it extracts one procedure, function or package to a file. Thats it. If you
    wanted to get all of the procedures in a schema extracted to the current working
    directory, you would run a script:
    --------------- getallcode ---------------------------
    set termout off
    set heading off
    set feedback off
    set linesize 50
    spool xtmpx.sql
    select '@getcode ' || object_name
    from user_objects
    where object_type in ( 'PROCEDURE', 'FUNCTION', 'PACKAGE' )
    spool off
    spool getallcode_INSTALL.sql
    select '@' || object_name
    from user_objects
    where object_type in ( 'PROCEDURE', 'FUNCTION', 'PACKAGE' )
    spool off
    set heading on
    set feedback on
    set linesize 130
    set termout on
    @xtmpx.sql
    ---------------- eof ---------------------------------
    You can see how to filter on that one by adding to the where clause if you want.
    Just run @getallcode_INSTALL to run all of the scripts...

  • How do i copy my iTunes folders from one user to another?

    i am setting up a duplicate user account on my MAC and wand to replicate my itunes folder and set up the same on my new user account as my original one.

    Before you change the country, note the following:
    - you must use any remaining store credit on your account
    - download all purchased content
    - ensure you have no current rentals(if you do, you'll have to wait for them to expire)
    - provide a new payment(such as a credit or debit card) associated with a valid billing address in the UK or an iTunes Gift Card purchased in the UK
    - content purchased from the iTunes Store is country-specific. If you wish to upgrade any of your iTunes Store content to iTunes Plus, you'll need to do this before you change countries. The content you purchased while your account was set to the previous country will not be eligible for upgrade once you've changed countries.
    - after you change countries, you will no longer receive application update notifications in iTunes for the apps you purchased in your original country. However, you'll still receive update notifications on your iOS device for any applications installed on it. In addition, you'll be able to download previously purchased applications again for free if they are available on your new country's store. You will not be charged and the download will not appear on your Purchased page. If a previously purchased application is not available in your new country, you will not be able to download it again for free.
    - If you have an iTunes Match subscription, you can't change countries until the subscription has expired.
    - If you have purchased a Season Pass, you cannot change the country associated with your account until that season is done airing and the last episode of the season has been added to the iTunes Store.
    Taking the above into consideration, here's how to change your country:
    1. Open iTunes and click Sign In.
    2. Enter your iTunes Store account name and password, then click Account Info.
    3. On the Apple Account Information page, click Change Country or Region.
    4. Enter the updated information and save your changes.

  • Move Mail from one user to another user on same iMac?

    How do I move my Mail (library and preferences) from one user to another user on the same Imac? This way I want to split afterwards the mailaccounts that now sit in one user over the old and the new user by deleting those mailaccounts that I do not want to have in one or the other user account. Appreciate the help.

    How do I move my Mail (library and preferences) from one user to another user on the same Imac? This way I want to split afterwards the mailaccounts that now sit in one user over the old and the new user by deleting those mailaccounts that I do not want to have in one or the other user account. Appreciate the help.

  • How to move database objects from one user to another user

    Could someone help how to move database objects from one user to another user
    Thanks in advance

    Thanks a lot for the reply.
    Actually I wanted to know whether there is any command to change the owner ship of the table.
    For ex table1 belongs to user1. can the owner of table1 to be changed to owner2.
    directly using an oracle command. I knew that it can be done using import and export, since the table was 200 million thought the rename command would be faster instead of import and export.
    Thanks Billy for letting me know that it is not possible using oracle query.

  • How can i move settings from one user to another?

    How do I move all settings and permiions from one user to another?

    http://discussions.apple.com/thread.jspa?messageID=11320719&#11320719
    http://discussions.apple.com/thread.jspa?messageID=12317222
    http://discussions.apple.com/thread.jspa?messageID=6331229

  • I would like to copy all the songs from one Ipod into another. All the songs are into my Itunes account, I tried to drag and drop the songs from the old Ipod to the new one but it doesn't work. Is there a way to do it ?

    Hello everybody,
    I would like to copy all the songs from one Ipod into another. All the songs are into my Itunes account, I tried to drag and drop the songs from the old Ipod to the new one but it doesn't work. Is there a way to do it ?
    I share one Itunes account with other people from my family and one person would like to keep the same songs on the new Ipod as the ones which were on the old one.
    Thanks in advance for your answer.
    Yan

    Hello Chris,
    Thanks for your answer. I was hoping for an easier answer. Too bad there is no drag and drop solution, it would have been much easier.
    Thanks for answering so fast.
    Bye.
    Yan

  • Copy a folder from one user to another  with the enterprise SDK

    Can anyone tell me how to copy a request in "My favorites" from one User to another with the enterprise SDK ?
    thanks in advance
    a great day to you'all
    Quentin

    Please post this query to the .NET Development - BusinessObjects Enterprise forum:
    .NET SDK Application Development
    That forum is monitored by qualified technicians and you will get a faster response there. Also, all BOE queries remain in one place and thus can be easily searched in one place.
    Thank you for your understanding,
    Ludek

  • (v 5.5) I can no longer copy and paste from one layer to another.

    I can no longer copy and paste from one layer to another in Illustrator (5.5). This started happening a few days ago. Restarting Illustrator and also my computer (Mac) didn't help. Any ideas?

    To clarify: If I select an object in layer 1 using command/c or command/x then select layer 2 and press command/v the object gets pasted back into layer 1 instead of layer 2. I've tried everything I can think of and can't correct the problem.
    Now the only way I can get an object from one layer to another is to drag it into another layer in the layers window.

  • Trouble with permission to open current PDF from one user to another user. what is the cure. i am running nthe current Server and updated Os 10.9.2

    Trouble with permission to open current PDF from one user to another  What is the cure ? I'm running the latest Server and OS 10.9.2.

    I had the same problem.
    Try this.
    https://igppwiki.ucsd.edu/groups/publichelpwiki/wiki/a1538/Howto_Disable_Acrobat _as_the_Safari_PDF_Viewer.html

  • Copy UDF fields from one user to another user with similar authorizations.

    Hi,
    Is there a way to copy UDF fields viewable to one user to another user wihtout manually checking the boxes in Form Manage User Fields?
    if so how can it be done?
    Jyoti

    For copying Form settings, user field settings, read the following 2 threads for complete details
    Replicate User Defined Field settings
    Form Settings

Maybe you are looking for

  • EPM 11.1.1 product interaction

    Hi all, I'm pretty new to hyperion Please explain me about interaction within EPM 11.1.1 products. 1. What are the differences between EPM application types (consolidation, planning, essbase, profitability)? Just dimension set? 2. Essbase application

  • Remote control for admin - again

    Sorry, I clicked the wrong button and sent before I finished... I'm using: NW 6.5 SP7 Zen 7 eDirectory 8.7.3.9 Windows XP workstations I'm having a problem remoting into workstation when a regular user is logged in. If the remote workstation has the

  • 2 renderers in layout set reading from different areas of km repository

    Good Day I have a layout set which contains 2 collection renderers. Each renderer must display content from different areas of the km repository in a way that is controlled by the KM Navigation iView parameters "Path to root folder" & "Path to initia

  • 'SAVE PAGE AS' DOWNLOAD GIVES ONLY TEXT DISPLAY!!

    When 'save page as' no diagrams, pictures and text areas as shown on website webpage is repeated ofline. Same on all websites offline downloads !

  • Adding the customer screen to enhance the header for Enjoy PO

    Dear Expert's, My requirement is to add a new tab on Header for Enjoy PO by enhancing ME21N/ME22N and ME23N. I have already implemented the BADI's ME_GUI_PO_CUST and ME_PROCESS_PO_CUST. Actions Taken: I have created a custom Function group and subscr