locked
Power Shell RRS feed

  • Question

  • Hi I want to be able to make life easier and create some power shell scripts so that who ever runs then, it prompts them just to in put, the variables 

    eg:  set-MailboxPermission -Identity user1 -User users2 -AccessRight FullAccess -InheritanceType All -Automapping $false

    basically i want it to prompt for  to enter user1 and user 2, rather than people amanding eth scripts and then copy and pasting it.
    Any Ideas?
    I have tried this but it doesn't work

    $user = Read-Host "Mailbox That you are giving access to"
    $identity = Read-Host "User who wants access"
    set-MailboxPermission -Identity $identity -User $user -AccessRight FullAccess -InheritanceType All -Automapping $false

    Thursday, April 16, 2015 9:47 AM

Answers

  • $a = Read-Host -Prompt 'Mailbox Name'

    $b = Read-Host -Prompt 'User Name'

    Set-MailboxPermission -Identity $a -User $b -AccessRight FullAccess -InheritanceType All -Automapping $false


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help.

    • Proposed as answer by Johnpaul J Wednesday, April 29, 2015 11:49 AM
    • Marked as answer by Riley00008888 Tuesday, June 16, 2015 1:32 PM
    Thursday, April 16, 2015 10:08 AM
  • any update on this?

    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help.

    • Marked as answer by Riley00008888 Tuesday, June 16, 2015 1:32 PM
    Friday, April 17, 2015 6:54 AM
  • Thanks, yeah i pasted in the wrong script i am running it as "add"
    can can run the script fine from a non exchange serer, with the import module and connect commends ect,
    and the script above runs fine from there

    however in the EMS Exchange management shell
    the script will not run

    • Marked as answer by Riley00008888 Tuesday, June 16, 2015 1:32 PM
    Friday, April 17, 2015 9:07 AM

All replies

  • $identity = Read-Host "Mailbox That you are giving access to

    $user = "Read-Host "User who wants access"

    set-MailboxPermission -Identity $identity -User $user -AccessRight FullAccess -InheritanceType All -Automapping $false

    This should do,you were giving access the other way

    Thursday, April 16, 2015 9:59 AM
  • $a = Read-Host -Prompt 'Mailbox Name'

    $b = Read-Host -Prompt 'User Name'

    Set-MailboxPermission -Identity $a -User $b -AccessRight FullAccess -InheritanceType All -Automapping $false


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help.

    • Proposed as answer by Johnpaul J Wednesday, April 29, 2015 11:49 AM
    • Marked as answer by Riley00008888 Tuesday, June 16, 2015 1:32 PM
    Thursday, April 16, 2015 10:08 AM
  • Thanks but when I save that as a powershell file, and then copy the file path in to the Exchange management Console, it doesn't actually run,
    it just goes to the next line, to enter a new command?
    Thursday, April 16, 2015 12:26 PM
  • $a = Read-Host -Prompt 'Mailbox Name'
    $b = Read-Host -Prompt 'User Name'
    Set-MailboxPermission -Identity $a -User $b -AccessRight FullAccess -InheritanceType All -Automapping $false

    save the file as .ps1 and go to the path of the file and run like below

    D:\scripts\./test.ps1


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help.

    • Proposed as answer by Johnpaul J Wednesday, April 29, 2015 11:48 AM
    Thursday, April 16, 2015 3:46 PM
  • any update on this?

    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help.

    • Marked as answer by Riley00008888 Tuesday, June 16, 2015 1:32 PM
    Friday, April 17, 2015 6:54 AM
  • Hi,

    From your description, I would like to clarify that you need to use the following cmdlet to grant one user full access to another's mailbox. Use "Add-MailboxPermission" not "Set-MailboxPermission".

    Add-MailboxPermission -Identity "user1" -User user2 -AccessRights FullAccess -InheritanceType All

    Hope this can be helpful to you.

    Best regards,


    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    Amy Wang
    TechNet Community Support

    Friday, April 17, 2015 6:57 AM
  • Thanks, yeah i pasted in the wrong script i am running it as "add"
    can can run the script fine from a non exchange serer, with the import module and connect commends ect,
    and the script above runs fine from there

    however in the EMS Exchange management shell
    the script will not run

    • Marked as answer by Riley00008888 Tuesday, June 16, 2015 1:32 PM
    Friday, April 17, 2015 9:07 AM