0

Morning,

I wander if you guys can help.

here is the sample

$From = Read-Host "Alias of the User Please?"

 Add-MailboxFolderPermission ${From}:\Calendar –User Test01 –AccessRights Editor
 Add-MailboxFolderPermission ${From}:\Calendar –User Test02 –AccessRights Editor
 Add-MailboxFolderPermission ${From}:\Calendar –User Test03 –AccessRights Editor
 Add-MailboxFolderPermission ${From}:\Calendar –User Test04 –AccessRights Editor
 Add-MailboxFolderPermission ${From}:\contacts –User Test01 –AccessRights Editor
 Add-MailboxFolderPermission ${From}:\contacts –User Test02 –AccessRights Editor
 Add-MailboxFolderPermission ${From}:\contacts –User Test03 –AccessRights Editor
 Add-MailboxFolderPermission ${From}:\contacts –User Test04 –AccessRights Editor

So if I run this, the user get replace and its add and blank space after the name, consequently the command failed.

Weird is, if I write-Host in front of the command, it get replace without the blank space.

What can i edit in the command to work successfully.

Cheers

E

MaiLBoMB
  • 15
  • 3

1 Answers1

0

I can't reproduce your problem. Are you sure you're not adding a space in the user-input?

It may be haiving a problem with casting your two values together as a string. You should define the path as a string and let the variable expand automatically, instead of trusting auto-cast. You could also add Trim() to your user-input to remove any leading og trailing whitespaces that the user might have typed. Try:

$From = (Read-Host "Alias of the User Please?").Trim()

Add-MailboxFolderPermission "$From:\Calendar" –User Test01 –AccessRights Editor
.....
Frode F.
  • 52,376
  • 9
  • 98
  • 114
  • Thanks Frode F. The addition of the quotes did do the trick, didnt need the .Trim(). Again, thank you. – MaiLBoMB Jul 11 '14 at 12:07