powershell
41 TopicsEOL - DDG - EQ operator wildcard bug fix
EOL > MSFT recently announced (i/t Health - Message center - MC912176) a bug fix related to the -eq operator and use of wildcards ('*') to compile the member list for Dynamic Distribution Groups. When the update takes effect, the * character will be treated as a literal value and not a wildcard. Therefore, expressions using the -eq operator will only evaluate to true if the right-hand side value matches the property values exactly. For example, the expression (WindowsLiveID -eq '*@microsoft.com') will only return true if the recipient’s WindowsLiveID property is exactly "*@microsoft.com". The current behavior will no longer function after the fix, and this may impact any processes that rely on this behavior. To distinguish the DLs (for corporate communication) membership of internal employees only and external consultants/contractors, we've created several DDGs using PowerShell to define the Recipient filter options based on our internal naming conventions (FTEs get FN.LN@emaildomain whereas consultants/contractors get FN.LN.ext@emaildomain). The formula was based on -eq operator combined with '*' wildcard > formula extract > -RecipientFilter {(( RecipientType -eq 'UserMailbox') -and ((WindowsLiveID -eq '*.*.ext@emaildomain') ... When the bug fix is corrected the formulas will no longer return the expected members. We've tried already several alternatives w/t -like operator but were not able to retrieve the same list. Other operators as -contains and -match are not supported i/t context of EOL. Are there other operators or other parameters to compile a filtered list using wildcards?763Views0likes3Commentspowershell creation receive connector from csv
I'm trying to create a script that should create an exchange receive connector from a CSV file that contains the list of the connectors to create as well as some properties. The problem is not the creation of the connector, which we can create from the csv, but the "remoteiprange" properties that throw an error. The csv file has this format "Name","Bindings","DeliveryStatusNotificationEnabled","AdminDisplayName","RemoteIPRanges","PermissionGroups" "TestConn","0.0.0.0:25","True","","192.168.101.0/23 192.168.102.0/23","AnonymousUsers, ExchangeServers, Custom" So we read all the parameters from the file and try to create the new connector passing them to the command but the error we get is New-ReceiveConnector : Cannot bind parameter 'RemoteIPRanges'. Cannot convert value "192.168.101.0/23,192.168.102.0/23" to type "Microsoft.Exchange.Data.IPRange". Error: "The format of the IP address 192.168.101.0/23,192.168.102.0 is invalid. Example of a valid IP address: 192.168.1.10"Solved239Views0likes4CommentsGet-Mailbox Versus Get-ExoMailbox
Microsoft’s advice is to use the Get-ExoMailbox cmdlet instead of its older Get-Mailbox counterpart. Generally, this is good advice that you should follow. However, the older cmdlet can do a job in certain circumstances, so don’t write it off completely. More importantly, make sure that filtering of objects is done using server-side filters. This will improve script performance significantly. https://office365itpros.com/2024/09/19/get-exomailbox/546Views0likes0CommentsFolderId's not unique without factoring in case-sensitivity, PowerShell issues...
Hello, I like using Get-/Set-/Add-/Remove-MailboxFolderPermission cmdlets. One of my favorites. There are times when there are special characters in the folder names, so I use the FolderId instead. For example: Add-MailboxFolderPermission -Identity "User1:LgAAAAC5KVkA/5dLTL13II/kvsaqAWCosJLoiFIBRbYcQ3Ny3l9TAAAAfag/AAAB" -User "User2" -AccessRights FolderVisible,ReadItems This has been fantastic to save the day in those cases. My latest issue though is that there turn out to be many duplicate FolderId's if we disregard case-sensitivity. If I import a CSV which has UN-tampered FolderId's (case-preserved and confirmed) with Import-Csv, and then to this: Add-MailboxFolderPermission "User1:$($csv[0].FolderId)" -User "User2" -AccessRights FolderVisible, ReadItems ... the actual folder to be updated with this new permission entry (ACE) may be the one I intended, or it may be one of the other folders with a matching FolderId (ignoring case-sensitivity). What I've found is that it is possible but difficult to bounce back from that problem state. You need to report all permissions before and after and verify the differences are only the intended changes. Super tedious, effectively a dangerous exercise overall. I don't see any alternative solutions for this problem. MFCMAPI I think, as well as Outlook/OWA, are definite workarounds. Wondering if there is anything in-built with the *-MailboxFolderPermission / *-MailboxFolderStatistics cmdlets that can help PowerShell here?765Views0likes1CommentAmazing discovery about Guid's and how to use them to evenly distribute automation over time
I recently re-discovered something, only this time was equipped to take advantage. I place this post here in the Exchange forum since this is my area of most interest, especially relating to using this discovery. Guid's (ObjectGuid, ObjectId, ExchangeGuid, ArchiveGuid, ExternalDirectoryObjectId, etc.) are system-generated and are made up of hexadecimal characters. The amazing discovery is that the degree to which these things are alphabetically balanced is astonishingly perfect. That is, if you take a random sampling of say 16,000 Guid's, you will most likely find that 1000 of them start with '0', 1000 start with '1', 1000 start with '2', ...through until 1000 start with '9', then 1000 also start with 'a', 1000 start with 'b', and so on up to 1000 start with 'f'. It keeps getting better though! Every next character is again evenly distributed. So for example, of all the Guid's starting with '0', roughly 1/16th of them will have '0' for the 2nd character, 1/16th will have '1' for the 2nd characters, and so on up to 1/16th will have 'f' for their 2nd character. This continues but admittedly becomes less perfect the deeper we go. Also, this amazing phenomenon works best when all the Guid's are coming from the same place, such as the list of Azure AD accounts in your tenant, or the list of ExchangeGuid's for your EXO mailboxes. Where this amazing'ness comes into play that completes my reason for this post? It is for large organizations who need to perform reporting and/or automation against their high volume of users or mailboxes (or other entities that are plentiful and have Guid's). Knowing how perfectly distributed the Guid's are alphabetically, we can program around the clock and always be dealing with a consistent level of load. Think back to EXO PowerShell pre-V2 when everyone's scripts would fail if their organization had more than a few hundred mailboxes. Well in this example, we can spread the 16 hexadecimal characters over the days in the week and each day deal with only 1/16th, or 2/16th's, etc. For example: function getTodaysMailboxes { param ( [Object[]]$Mailboxes ) try { $_guidDay = @{ 'Monday' = '0', '1', '2', '3', '4' 'Tuesday' = '5', '6', '7', '8', '9' 'Wednesday' = 'a', 'b', 'c', 'd', 'e' 'Thursday' = 'f', '0', '1', '2', '3' 'Friday' = '4', '5', '6', '7' 'Saturday' = '8', '9', 'a', 'b' 'Sunday' = 'c', 'd', 'e', 'f' } $_todaysGuids = $_guidDay["$([datetime]::Today.DayOfWeek)"] $Script:TodaysMailboxes = @($Mailboxes | Where-Object { $_todaysGuids -contains $_.Guid.ToString().SubString(0,1) }) writeLog @writeLogParams -Message "Identified $($Script:TodaysMailboxes.Count) mailboxes to process today ($([datetime]::Today.DayOfWeek)'s = (EXO) Guid's starting with: $($_todaysGuids -join ', '))." } catch { throw } } And that example is just for daily script execution. You could instead pick a more frequent schedule, say hourly, with the goal to cover every mailbox in 1 week. There are 168 hours in the week, and there are 256 combinations of the first 2 characters in the Guid's. So, if you spread those 256 combos over those 168 hours, all 168 hours would process 1 combo's worth of Guid's, and then 88 of those hours could process 1 extra combo, covering all 256 combos. It would end up being a tiny amount of work every hour, which should lead to less long-running scripts, less data being pulled in short amounts of time, and less failures all around. I personally for now am making use of the code sample above to run scripts nightly which cover off 4-5/16th's all all my org's mailboxes. Every 1 weeks, all of my mailboxes have been processed twice. This could be for pulling mailbox statistics, or mailbox permissions, AAD sign-ins, all kinds of stuff. To summarize this is one cool and easy way to evenly distribute your scripting work over a set amount of time. I don't think you'll find another property on objects that is so well distributed as Guid's. One more reason to love the Guid.Solved4.1KViews0likes2CommentsModify Email Address Policy via powershell
We have to remove several accepted domain, via powershell, from our Exchange domain. Before doing so, however, we need to remove the references for that accepted domain from several email address policy. The idea is to cycle through all the email address policy searching for the accepted domain to be removed and remove it from the policy Is there a way of doing it, any example ?205Views0likes0CommentsCan't make a goup calendar readonly anymore with Powershell (again...)
About a year ago the command Set-UnifiedGroup -Identity "MYGROUP" -CalendarMemberReadonly was giving problems. See this post: Can't make a goup calendar readonly anymore with Powershell - Microsoft Community Hub This lasted from june 2023 to august 2023 and then it was fixed. After that, aside from the error message it gave, it used to work fine. But since about a week or 2 the command is giving problems again. I get this error message: Write-ErrorMessage : |Microsoft.Exchange.Configuration.Tasks.TaskException|We failed to update the unified group. Please try again later. At C:\Users\some.user\AppData\Local\Temp\tmpEXO_gny3w2ea.ldk\tmpEXO_gny3w2ea.ldk.psm1:1204 char:13 + Write-ErrorMessage $ErrorObject + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Set-UnifiedGroup], TaskException + FullyQualifiedErrorId : [Server=DBBPR04MB7929,RequestId=<xxx>,TimeStamp=Mon, 10 Jun 2024 06:36:03 GMT],Write-ErrorMessage Do other people get this error to? How can I fix this? Kind regards, Paul331Views0likes1CommentCan't make a goup calendar readonly anymore with Powershell
Hi, We have some groups where regular group members are not allowed to make changes to the group calendar. I was able achieve this with Powershell as described in this post: Calendar permissions in an Office 365 Group - Microsoft Community More info about the Set-UnifiedGroup command is found here: Set-UnifiedGroup (ExchangePowerShell) | Microsoft Learn All of a sudden I now am only able to read the settings and can't change them anymore. So this still works: Get-UnifiedGroup -Identity "MYGROUP" -IncludeAllProperties | Format-List *Calendar* But this gives an error: Set-UnifiedGroup "MYGROUP" -CalendarMemberReadOnly The error is: Write-ErrorMessage : Object reference not set to an instance of an object. The strange thing about this, is that I am able to change other attributes, like: Set-UnifiedGroup -Identity "MYGROUP" -AccessType Private I use an account with Global Admin rights to execute the commands and we have an educational tenant. What is going wrong here?8.4KViews1like39CommentsGet-MailboxExportRequest doesn't accept Export from date A to date B
Hi everyone, I'm faceing a strange error, when I want to export between 2 dates. We've tried infinite ways of exporting between 2 dates, but me and my colleagues can't get it. For easier reading, I reduced the following code to the minimum. We are successfully exporting with Case 1, but as soon as we want to set a end date, it will automatically fail with the wildest excuses. (See 2nd code) #Define Dates $start = (Get-Date -Day 1 -month 6 -year 2021 -Hour 00 -Minute 00) $end = (Get-Date -Day 31 -month 12 -year 2023 -Hour 23 -Minute 59) #Case 1: Export the MB works with following command WORKS. (So Export from Date X until today): New-MailboxExportRequest -Mailbox "PrimarySmtpAddress" -ContentFilter "((Received -ge '$start') -and (Sent -ge '$start'))" -FilePath "Path\file.pst" #Case 2: To keep it simple, I'll just export the received Messages (Export from Date X to Date Y (NOT NOW) doesn't work.: New-MailboxExportRequest -Mailbox "PrimarySmtpAddress" -ContentFilter "((Received -ge '$start') -and (Received -le '$end'))" -FilePath "Path\file.pst" Get-MailboxExportStatistics Error: ContentFilter is invalid. The value "31.12.2023 23:59:00" could not be converted to type System.DateTime. --> The value "31.12.2023 23:59:00" could not be converted to type System.DateTime. $end is definitely a system.datetime type; We've also used different System Cultures, f.e.: [System.Threading.Thread]::CurrentThread.CurrentCulture = "en-US" I've been working on this for a long time, please only respond, if you were able to reproduce this in your own Exchange Environment, since I want a confirmation, that this is a (currently) unhandable bug. Best regards, Florian edit: I updated the official MS docs.652Views0likes0CommentsTeams and Microsoft Exchange PowerShell Modules Clash Over Required DLL
After updating a bunch of PowerShell modules, I was dismayed to find a PowerShell module clash caused by a dependency on the Microsoft.Identity.Client DLL. The Exchange Online management module wanted a higher version of the DLL than the one loaded by the Teams module, so the Connect-ExchangeOnline cmdlet barfed. It’s easy to understand the logic behind the problem, but it’s hard to understand why Microsoft let it happen. https://office365itpros.com/2023/10/20/powershell-module-clash-exo/484Views0likes0Comments