locked
Add-SPShellAdmin function to add multiple users powershell RRS feed

  • Question

  • Hi, 

    Is there a way to add a function to a PowerShell script to add multiple users to add-spshelladmin? I have three admins that need to have Add-SPShellAdmin every time we create a new content db. 

    Any ideas? 

    Thursday, March 2, 2017 8:39 PM

Answers

  • It would look something like the script below

    $users = @("domain\user1", "domain\user2")
    foreach ($user in $users)
    {
        AddSPShellAdmin -Username $user
    }


    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    • Marked as answer by GeekzInside Monday, March 13, 2017 5:10 PM
    Friday, March 3, 2017 12:25 PM

All replies

  • Sure,  create the account names in array and then call a ForEach Loop on the array feeding the accountname into the Add-SPShellAdmin inside the loop.

    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    Thursday, March 2, 2017 8:59 PM
  • Thank you Paul - would you happen to have any examples? 

    Thursday, March 2, 2017 10:32 PM
  • It would look something like the script below

    $users = @("domain\user1", "domain\user2")
    foreach ($user in $users)
    {
        AddSPShellAdmin -Username $user
    }


    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

    • Marked as answer by GeekzInside Monday, March 13, 2017 5:10 PM
    Friday, March 3, 2017 12:25 PM
  • This worked - thank you Paul!
    Monday, March 13, 2017 5:10 PM