Posts

Showing posts with the label powershell

How to pass O365 credentials automatically and securely for scheduled tasks

Image
With everything we can do in any O365 Admin Portal possible to do, even easier and better, in PowerShell, I have tried to create scripts to automate as much of my tasks as possible. When I run these manually its fine, I enter my credentials and approve my MFA popup on Authenticator App.  But what about scripts I want to run regularly, or automatically based on another event happening? Well, basically we need a few things. The first is to have an O365 Admin account, with only the bare minimum role we need, created and NOT enabled for MFA. This is a risk of course but if it can be restricted and controlled (think Conditional Access here) within your environment then this will be more of a benefit than it is a risk. Once we create this account, we now need to securely save the credentials somewhere so they can be used in an automated/scheduled task. Storing credentials securely Step 1: Store your credentials in a variable - for this session only On the server you are going to run ...

Assigning Office 365 Licensing in PowerShell

Image
As part of my dive into automating as much as possible of a Microsoft Teams implementation or migration from Skype for Business On-Premise, I am focusing on scripting as much as possible. This post focuses on the licensing element. You are unable to enable users in Teams unless they have the correct licenses already assigned. The following commands will allow us to check what licensing is available to the tenant. To check this you must first connect to the Microsoft Online Service. Run: Connect-MsolService You will be prompted for your O365 credentials and any MFA (you have MFA enabled right...) Now run:  Get-MsolAccountSku You will see the output on the screen of the different licenses on the tenant: In the output the first element before the license type we have the tenant name XXXXX: followed by the License type and how many units of each, warnings and ConsumedUnits (Assigned Licenses) This ties in with what we see in the GUI in Office 365 Admin Center: ...