That’s probably what you want. This “extracts” the values from the Name properties of the objects, leaving you with plain-old strings. This is one of the many fun and interesting techniques, using this exact example along with others, in “Learn PowerShell in a Month of Lunches,” and it’s an excellent example of how PowerShell is very object-oriented in how it works.
I have another problem, which I suspect is of the same nature:
I want to rename a room calendar mailbox. I begin by displaying a grid view of all the existing room names:
Get-Mailbox -RecipientTypeDetails RoomMailbox | select name | sort name |
out-gridview -OutputMode Single -Title "Which room do you want to rename?" -OutVariable oldname
This fills the variable $oldname with the name of the room I want to rename.
I fill in a few other variables with the new name, the alias and the email address.
Cannot process argument transformation on parameter ‘Identity’. Cannot convert value “” to type
“Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter”. Error: “Parameter values of type
Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter can’t be empty. Specify a value, and try again.
Parameter name: identity”
+ CategoryInfo : InvalidData: ( [Set-Mailbox], ParameterBindin…mationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Mailbox
+ PSComputerName : ps.outlook.com
If I fill in the identity with a hard-coded string everything works fine, including the other variables.
I have tried a hundred different ways, but I cannot get the trick to this!
As I may have mentioned, I am a noobie to PowerShell!
Hi Stewart,
I’m fairly new to some of the more intricate parts of PowerShell, but what appears to be happening is that the parameter
-outvariable
is not actually storing any output inside your variable. This might be because Out-Gridview is meant for displaying information after you have done all the processing, I am just guessing.
What I would try is
$oldname = Get-Mailbox -RecipientTypeDetails RoomMailbox | select name | sort name |
out-gridview -OutputMode Single -Title "Which room do you want to rename?"
Set-Mailbox -identity $oldname -Name $newname -Alias $alias -DisplayName $newname -Emailaddresses $email
Iam new to the powershell world but I have observed that OGV is storing the values in hash table where set-mailbox identity parameter is asking for a array format.