Sep 29 2023 01:27 PM
I am running into wall attempting to complete the following:
1.) I am wanting to do a Get-Mailbox filtering only ResourceType -eq "workspace"
I am able to do this with this command
Get-Mailbox -Filter '(ResourceType -eq "workspace")' | Select Alias
2.) I am wanting to find AdditionalResponse that 'contains' a specific word "WORD"
I am UN-able to do this with a similar command.
Get-calendarprocessing -Filter '(AdditionalResponse -contains "WORD")' | Select Alias
ERROR: A parameter cannot be found that matches parameter name 'Filter'
3.) I would like to combine the 2 and export a list to a .csv file of mailboxes that are ResourseType 'workspace' AND AdditionalResponse that 'contains' a specific word "WORD"
Sep 29 2023 02:45 PM - edited Sep 29 2023 02:46 PM
Something like
$total = foreach ($mailbox in Get-Mailbox -Filter '(ResourceType -eq "workspace")') {
if (Get-CalendarProcessing -Filter '(AdditionalResponse -contains "WORD")') {
[pscustomobject]@{
DisplayName = $mailbox.displayname
Alias = $mailbox.alias
}
}
}
$total | Export-Csv -NoTypeInformation -Path c:\temp\mailboxes.csv -Encoding UTF8 -Delimiter ';'
Untested, don't have an Exchange Server available at this moment ;)
Sep 29 2023 06:15 PM
@Harm_Veenstralooks like Calendar-processing doesn't like filter.
A parameter cannot be found that matches parameter name 'Filter'.
+ CategoryInfo : Invalid Argument: (:) [Get-CalendarProcessing], ParameterBinding
Exception
+ FullyQualifiedErrorId : NamedParameterNotFound,Get-CalendarProcessing
+ PSComputerName : outlook.office365.com
Sep 29 2023 06:25 PM
2/ Try this command instead :
Get-CalendarProcessing | Where-Object { $_.AdditionalResponse -contains "WORD" } | Select Alias
Here is my attempt at writing an example :
# Get all mailboxes.
$mailboxes = Get-Mailbox -ResultSize Unlimited
# Filter mailboxes by ResourceType.
$mailboxes = $mailboxes | Where-Object { $_.ResourceType -eq "Workspace" }
# Filter mailboxes by AdditionalResponse containing "WORD".
$mailboxes = $mailboxes | Where-Object { $_ | Get-CalendarProcessing | Select-Object -ExpandProperty AdditionalResponse -like "*WORD*" }
# Select the Alias property.
$mailboxes = $mailboxes | Select-Object Alias
# Export the list to a CSV file.
$mailboxes | Export-Csv -Path "C:\path\to\output.csv" -NoTypeInformation
not tested yet,
Sep 29 2023 09:00 PM
Here's an example using the more recent Get-EXOMailbox (which is faster and more efficient (in most cases), but not necessary if you work for a small-to-medium-sized organisation).
Get-EXOMailbox (and the older Get-Mailbox) support server-side filtering, which is why they provide a -Filter parameter. Server-side filtering is always faster, however, it's not available on every commandlet.
Get-CalendarProcessing does not support server-side filtering, which is why there is no -Filter parameter. You have to do the filtering client-side.
Here's a functional example you can tailor to your needs.
Get-EXOMailbox -Filter "ResourceType -eq 'workspace'" -PropertySets StatisticsSeed -Properties Alias, ResourceType |
ForEach-Object {
$Mailbox = $_;
Get-CalendarProcessing -Identity ($_.Identity) |
ForEach-Object {
if ($_.AdditionalResponse -match "WORD")
{
[PSCustomObject] @{
Guid = $Mailbox.Guid;
ResourceType = $Mailbox.ResourceType;
Alias = $Mailbox.Alias;
AdditionalResponse = $_.AdditionalResponse;
}
}
}
} |
Export-Csv -NoTypeInformation -Path "C:\Data\someOutputfile.csv";
Cheers,
Lain