Jon Klein
Jon Klein

Reputation: 1

How to use a variable in Get-MailboxFolderPermission

I wanted to use a variable for a lawyer's name so I could recycle the same Get-MailboxFolderPermission command, but the syntax doesn't seem to work.

The command by itself would be: Get-MailboxFolderPermission jdoe:\calendar

But if I try to put "jdoe" in a variable ($lawyer = "jdoe") and then try to invoke it in the command Get-MailboxFolderPermission $lawyer:\calendar it gives an error: Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to delimit the name. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : InvalidVariableReferenceWithDrive

Get-MailboxFolderPermission "$($jdoe):\calendar" doesn't give an error, but it also doesn't produce an accurate output of his calendar permission.

I suspect it has to do with the ":" that is part of the command, but I can't find an article that addresses this particular issue.

Upvotes: 0

Views: 1475

Answers (1)

Jon Klein
Jon Klein

Reputation: 1

Sorry, I just figured it out based on the error. Get-CalendarPermission ${jdoe}:\calendar works properly.

Upvotes: 0

Related Questions