This is beyond simple. I have spent now 10 times longer than doing this manually would have taken. Simple script saved as ps1 and trying to run the variable keeps not updating...
$test1 = Read-Host -Prompt "Input user"
get-mailbox -identity $test1
add-mailboxfolderpermission -identity ($test1.alias+':\calendar') -User Manager -AccessRights Reviewer
When I run this it prompts as expected, I enter the username to update, the "get-mailbox" shows the user I have entered, but then it fails to update saying the Manager user already has permissions.
At this point when the script fails if I do a "get-mailbox -identity $test1" it tells me a previous user I have attempted this with.
For example I run it and put in "john.smith", it runs, the "get-mailbox" line of the script returns john.smith, but then the add-permission line fails and if I do a manual get-mailbox it tells me the variable is instead "jane.smith" or some other user I have previously ran this manually with.
I just can't possibly work out what I am doing wrong... The variable reads as one user on one line, then another on another?? I'm at the point of a heart attack pulling my hair out stressing over this stupdi shit.