PowerShell – Search-Mailbox script to go through all mailboxes, find a target message, and remove it

When looking at the title of this post, one might notice I used a target word, and it is on purpose. This script below is useful when trying to remove all types of messages from users' mailboxes whether it's a spam, scam, virus or a an important message that needs to be "recalled". This script is based on Search-Mailbox cmdlet, works well but it has its own pros and cons, more on some of them below. Later I will have another post showing a different and more advanced script to do the same and even better. So stay tuned. Pros: Doesn't search through Purged Items (a bit more about the 3rd layer of Trash is here - https://365basics.com/script-to-search-through-recoverable-and-purged-items-and-restore-those/ ). Can copy messages to another mailbox (IT Help in that example). Cons: Per Microsoft Search-Mailbox will be depreciated, we don't know when it will happen though. Slow (if a target message…

Continue ReadingPowerShell – Search-Mailbox script to go through all mailboxes, find a target message, and remove it

PowerShell – change the storage space for a specific user’s OneDrive

As an admin you can easily make an adjustment of a OneDrive storage limit for all users through a OneDrive admin center. If you need to do the same for a specific user, here is a Microsoft article that describes that - https://docs.microsoft.com/en-us/onedrive/change-user-storage Truth is, it only takes a single line of code to make an adjustment; however, my script below takes care of most little things, requirements, and inconveniences: you only need an email address of a user; the minimum size of allocated space is 1 GB; the maximum size is 5 TB. $email = Read-Host "Please provide an email address of the user" $convertedemail = $email -replace "\.","_" -replace "@","_" $partofthelink = "-my.sharepoint.com/personal/" + $convertedemail $onedriveurl = Get-SPOSite -IncludePersonalSite $true -Limit all -Filter "Url -like $partofthelink" $onedriveurl Do { Try { $num = $true [int]$sizegb = Read-Host "Please specify the size of OneDrive storage space to be set…

Continue ReadingPowerShell – change the storage space for a specific user’s OneDrive

SharePoint – enable or disable Share option per each library within a site

This post is about how to enable or disable Share option for each library within a SharePoint subsite. There are different suggestions that worked for some but didn't for the others in this stackexchange topic - https://sharepoint.stackexchange.com/questions/208090/how-do-i-disable-get-a-link-share I found a way to control it by adjusting Access Requests Settings and Permission levels. Unfortunately it's almost impossible to find any documentation on what each Permission option does. Let's see how it all works together. Microsoft is known to change things down the road, so the settings that work today might not in the future. Please test everything before moving forward in your production environment. So here is a test subsite with two document libraries: The first requirement is Allow members to share the site and individual files and folders must be checked: Second, on your main site within a site collection you need to create a copy of the Contribute permission level, name it Contribute…

Continue ReadingSharePoint – enable or disable Share option per each library within a site

PowerShell – show and adjust resource booking configuration according to 4 scenarios

There is an amazing article (https://itpro.outsidesys.com/2017/11/06/exchange-configuring-the-resource-booking-attendant-with-powershell/) published by John Dougherty on how to adjust resource booking configuration having 4 different scenarios. Those 4 scenarios are: Anyone can book the resource. No delegate approval required. Anyone can book the resource. Delegate approval required for all requests. Only a list of people can book the resource without delegate approval. All others require delegate approval. Only a list of people can book the resource. All others are denied. There are no delegates. Not everything can be done through an Admin portal, that's why having such a PowerShell script is crucial. I decided to do several things to improve that process: Added code to check an existing configuration for every single Room and Resource. If the configuration is any different than these 4 above, then the script notifies you about it. Combined scripts into a single one. Added more user input to not adjust the…

Continue ReadingPowerShell – show and adjust resource booking configuration according to 4 scenarios

Script to search through Recoverable and Purged items and restore those

The purpose of this script is to find deleted messages in a specified user's mailbox. There are 3 levels (when configured) of Trash in a mailbox: Level 1 - Deleted Items (e.g. 30 days) Level 2 - Recoverable items (e.g. 15 days) Level 3 - Purged items (e.g. 15 days) Users usually know about the first two. Moreover, they can only work with the first two from both Outlook and OWA. Only admins have access to Purged items. It makes sense to use this script in at least 2 cases: A user is being terminated on bad terms, decided to permanently delete everything from both Deleted and Recoverable items. A user deleted an email at some point, missed the first 30-day period, then missed the second 15-day period, and then wants to recover that email. If it's less than 60 days (30+15+15) overall then that email can be restored. The script…

Continue ReadingScript to search through Recoverable and Purged items and restore those

Skype for Business – using Banner logo from Azure-Company Branding in a Skype Logo URL

It's a good practice to display your Company logo in the places where it makes sense, e.g.: Login page (for users to be 100% sure they are trying to access their Company resource) Email signature (Company branding) Skype for Business meeting (Company branding) Configuring Logo in the Skype for Business is pretty straightforward and fully described in this Microsoft article - https://docs.microsoft.com/en-us/SkypeForBusiness/set-up-skype-for-business-online/customize-meeting-invitations Since it has to be a URL, it must be pointing to a web resource whether it's your Company website, SharePoint document library with enabled anonymous access or anything else. In my opinion, these are all unnecessary dependencies. Why not using something that is already configured? PREREQUISITES - Company Branding To configure Company branding you must follow these steps: Go to Microsoft 365 admin center - Admin centers - Azure Active Directory Then Azure Active Directory admin center - Azure Active Directory - Company branding - Banner logo Upload your Company logo image following the…

Continue ReadingSkype for Business – using Banner logo from Azure-Company Branding in a Skype Logo URL

Script to add or replace distribution groups of a target user with groups a source user has

This PowerShell script has two use cases combined in it - ADD and REPLACE. Before any change is made the script also shows a group membership for both a target and a source users. Note, the script only processes those distribution groups that are managed in the cloud. If you have some groups synced with Active Directory, those should be processed separately. USE CASE #1 - ADD When Add is chosen, the scripts only adds distribution groups of the source user to the target user's list. Use this part of the script when a target user assumes new responsibilities that another user has but keeps the old responsibilities as well. In other words, the target user needs to have a combination of new and old distribution groups to perform job tasks. USE CASE #2 - REPLACE Essentially, the 2nd part of the script is a combination of the 1st part…

Continue ReadingScript to add or replace distribution groups of a target user with groups a source user has

Script to removeĀ a user from all distribution groups managed in the cloud

The purpose of this PowerShell script is to remove a user from all distribution groups. The script is interactive, it will show the list of groups first, then you have an option to process your request. While the same can be done using Exchange Admin or Microsoft 365 Admin Center, it is much faster using PowerShell. Note, the script only processes those distribution groups that are managed in the cloud. If you have some groups synced with Active Directory, those should be processed separately. $email = Read-Host "Please provide a user's email address to remove from all distribution groups" $mailbox = Get-Mailbox -Identity $email $DN=$mailbox.DistinguishedName $Filter = "Members -like ""$DN""" $DistributionGroupsList = Get-DistributionGroup -ResultSize Unlimited -Filter $Filter Write-host `n Write-host "Listing all Distribution Groups:" Write-host `n $DistributionGroupsList | ft $answer = Read-Host "Would you like to proceed and remove $email from all distribution groups ( y / n )?" While…

Continue ReadingScript to removeĀ a user from all distribution groups managed in the cloud

Script to show my computer name and IP address

If you need to know the name of the computer of a user or the IP address, then this tiny PowerShell script can become handy. For example, that information might be required for remote assistance software. There are some tools out there that show this info, e.g. BgInfo, but they don't always work. Moreover, some users insist on seeing an unobstructed photo of their puppy they just got from a shelter. That's a big one! 1) Create a PowerShell script file with this content: Add-Type -AssemblyName System.Windows.Forms $ip=get-WmiObject Win32_NetworkAdapterConfiguration|Where {$_.Ipaddress.length -gt 1} $ipaddress = $ip.ipaddress[0] $pcname = [System.Net.Dns]::GetHostName() [System.Windows.Forms.MessageBox]::Show("My PC name - $pcname `n`nMy IP address - $ipaddress",'About my PC','OK','Information') This script is a modified combination of scripts out there that other people made, so by no means I'm trying to take any credits for it. 2) Put this script to a network location that every user has Read access to.…

Continue ReadingScript to show my computer name and IP address

List all Corporate Contacts and Distribution Lists they belong to

There are times when your company needs to keep a list of Corporate Contacts that are used by your own users on a daily basis. You can find them in Microsoft 365 Admin Center - Users - Contacts or Exchange Admin Center - Recipients - Contacts. It gets more complicated when those contacts are added to several Distribution Lists, more so when they are mixed with your users. The issue is that unlike working with Internal Users, you cannot open a contact and see which groups it belongs to. This is where PowerShell comes handy. The script below finds every single contact and all groups it belongs to (if any). To show the result I use a Grid View (Out-GridView) because it provides an easy column sorting and filtering. This script might help to find a user error if some contact should or should not be in a group. Side…

Continue ReadingList all Corporate Contacts and Distribution Lists they belong to