How to connect to Exchange Online PowerShell via ISE with MFA the correct way

I had the issue that my ISE client timed out after 10 minutes and I could not re-logon to Exchange Online PowerShell and I had to start a new session each time. I asked on Twitter and got some great help from these guys, a big shout out to

It turned out I was doing it wrong. Here is how to do it right

  • Install the Exchange online PowerShell module for MFA
    • Go to Exchange Admin in portal.office.com
    • go to Hybrid and click download for the Exchange module
    • This will break in Chrome, so use Edge og IE
    • Note that you should run the installed module from time to time in order keep it up to date
  • Open PowerShell ISE or Visual Studio Code and use this code to connect to Exchange Online
#Import the module, requires that you are administrator and are able to run the script
Import-Module $((Get-ChildItem -Path $($env:LOCALAPPDATA+"\Apps\2.0\") -Filter CreateExoPSSession.ps1 -Recurse ).FullName | Select-Object -Last 1)
#connect specifying username, if you already have authenticated to another moduel, you actually do not have to authenticate
Connect-EXOPSSession -UserPrincipalName admin@contoso.com
#This will make sure when you need to reauthenticate after 1 hour that it uses existing token and you don't have to write password and stuff
$global:UserPrincipalName="admin@contoso.com"

How I create Microsoft Teams in PowerShell, January 2018

This is how I choose to create Microsoft Teams using PowerShell in the period of January 2018 as demoed in my NICconf session. This will probably change in the future so I need to specify the time this actually worked for me :)

  • I create the Office 365 Group in Exchange because then I can specify the email address and I also like to remove it from global addressbook since it is primarily used for Microsoft Teams
  • Then I Teams enable the group and typically it is created for projects so I create typical channels I want to use in the project, typically it is an Office 365 migration and deployment projects
  • Typically I leave it up to the group owners to add the members themselves in Microsoft Teams, but I use Teams PowerShell to add the owners and optionally members, because it is simpler to do it using Teams
  • The Microsoft Teams PowerShell module is based on Microsoft Graph and everything is in the context of your admin account, so in order to administer the Teams, you need to be an owner of those Teams
  • Be aware of that it can take up to 24 hours until members and channels are added to the Microsoft Teams because this is Microsoft Graph and the SLA is 24 hours to sync members over from Azure AD. Typically this should happen within 15 minutes
    • This is how it is as of January 2018
#Create the Office 365 Group
New-UnifiedGroup –DisplayName NICDemo96 –Alias NICDemo96 –EmailAddresses "NICDemo96@M365x963508.onmicrosoft.com" -owner GA-sha256@M365x963508.onmicrosoft.com -RequireSenderAuthenticationEnabled $False -Verbose
#This is optional, but may be a good practice initially since Office 365 Groups may clutter your Global Addressbook
Set-UnifiedGroup –Identity NICDemo96 –HiddenFromAddressListsEnabled $true
#Create the Team, provide the GUID object ID to specify the Group
$group = New-Team -Group (Get-UnifiedGroup NICDemo96).ExternalDirectoryObjectId -Verbose

#Check your Teams, will only list teams you are a member of
Get-Team

#Add Channels to the Team
New-TeamChannel -GroupId $group.GroupId -DisplayName "1 Adoption" -Verbose
New-TeamChannel -GroupId $group.GroupId -DisplayName "2 Deployment" -Verbose
New-TeamChannel -GroupId $group.GroupId -DisplayName "3 Operations" -Verbose
New-TeamChannel -GroupId $group.GroupId -DisplayName "4 Change Management" -Verbose
Set-TeamFunSettings -GroupId $group.GroupId -AllowCustomMemes true -Verbose

#add owners and members, easier to do with Teams cmdlet
$Owners = "PradeepG@M365x963508.onmicrosoft.com","PattiF@M365x963508.onmicrosoft.com","LidiaH@M365x963508.onmicrosoft.com","MiriamG@M365x963508.onmicrosoft.com"
$Users = "IrvinS@M365x963508.onmicrosoft.com","JohannaL@M365x963508.onmicrosoft.com","DebraB@M365x963508.onmicrosoft.com"
ForEach ($Owner in $Owners){Add-TeamUser -GroupId $group.GroupId -User $Owner -Role Owner}
ForEach ($User in $Users){Add-TeamUser -GroupId $group.GroupId -User $User -Role Member -Verbose}

#Check that members are added, know that it could take up to 24 hours until they are actually added to Microsoft Teams
Get-TeamUser -GroupId $group.GroupId
Get-UnifiedGroupLinks NICDemo96 -LinkType owner
Get-UnifiedGroupLinks NICDemo96 -LinkType member

If you want an updated approach, you should check out the Book I am co-authoring that is update weekly by MVP Tony Redmond, to match the ever-changing Microsoft Cloud. The book is called Office 365 for IT-Pros and comes highly recommended.

Check out my speaker profile @SessionizeCom

Check out my speaker profile here:  https://sessionize.com/StaleHansen/

I love sharing my thoughts, ideas and findings from the field at conferences and in user groups. I have been an active public speaker since 2011, my first English session in 2012 was at Nordic Infrastructure Conference in Oslo. My first talk at a conference in the US was in 2014 at the Lync Conference in Las Vegas. From there I have been talking at conferences such as TechEd US and EU, TechDays Sweden, IT/Dev Connections, UCDay UK, Communication Day Belgium and Microsoft Ignite. It has been and is a blast.

I have created a profile at Sessionize.com with links to my speaker experience and current sessions I am focusing on, but not limited to :) If you find any of the topics interesting, do not hesitate to contact me for a talk internally at your company, at your user group (remote via Skype for Business works), or at a conference. Most of the talks are updated frequently with my current experience and features from Microsoft, so they never get old or repetitive :)

Check out my profile here:  https://sessionize.com/StaleHansen/

Share a single document with external user in Microsoft Teams

Guest Access in Microsoft Teams is a great way to collaborate with external Office 365 users in chat, files and existing tabs. Sometimes you may want to collaborate on a single document with an external user without giving them access to your entire team. Turns out, this is disabled by default.

You need to enable it via SharePoint PowerShell, here is how

  • Connect to SharePoint Online via PowerShell
  • list all site collections for your Office 365 Groups and Teams
    • Get-sposite -template GROUP#0 -includepersonalsite:$false
  • Copy the URL you want to change
  • Run the following command to make the change
    • Set-SPOSite -Identity https://tenantname.sharepoint.com/sites/NewTeam -SharingCapability ExternalUserAndGuestSharing
    • The new sharing capability is called ExternalUserAndGuestSharing
      • External user sharing (share by email) and guest link sharing are both enabled
    • The default value is ExistingExternalUserSharingOnly
      • Allow sharing only with the external users that already exist in your organization’s directory

Now you are able to in to a document, click the sharing button, choose specific users and invite those you want to collaborate with on this specific document. It is important that you choose the option “only the people you specify”, then and only then will they be able to work with the document in their desktop client

 

 

 

 

 

References:

 

How to use Microsoft Flow to move email to OneNote

The send to OneNote plugin in Outlook for PC and Mac is awesome. The problem is when you are not in front of a computer and need to tag an email for processing later when you are on other platforms. My approach to solve this is to use flagging of email and send that to my collection section in OneNote using Microsoft Flow. In that way, I know when I have processed it and I know I can find it again in OneNote for when I process my OneNote and create actionable tasks.

Here is how to get started with using Microsoft Flow for moving flagged emails to your Collection section in Microsoft OneNote that is stored in OneDrive for Business in Office 365.

  1. Log on to your Office 365 portal
  2. Click on the Flow icon to get started
    • requires that Flow is enabled for your tenant and your user
  3. Search for Outlook, because that is our trigger
  4. Choose the trigger for when flagging an email in your inbox
  5. Click on Next Step and search for OneNote (Business)
  6. Choose create page in section
  7. Choose the notebook that is stored in OneDrive for Business
  8. Choose the section you want to store it in, which should be your collection section
  9. In order to get a good input from the email you need to paste in some HTML code in order to get subject as title and more info from the email in to OneNote
  10. From here, save the flow
    • it takes 10-15 minutes for first run
    • The free version runs every 15 minutes, the Office 365 flow version runs every 5 minutes
    • For Office 365 the number of times a flow can run is tenant wide and is aggregated by the number of user licenses in the tenant and is 2000 times per user per month
    • One user can consume a lot more runs than 2000, but the average is 2000 per user per month
    • Read more her: https://flow.microsoft.com/en-us/pricing/#plan-feature-table
  11. The flow with flagging of emails are only run when you actually do the flagging, so you will only consume a run when you actually do the flagging

Check out my OneNote LifeHacks video from Ignite on how to set this up.

References

Looking for coaching on being more productive with OneNote and get more stuff done, connect with me at CloudWay

Speaking at Microsoft Ignite about OneNote and Skype for Business

I am stoked to return to Microsoft Ignite as a speaker for the third time. This year is going to be a blast and I have several sessions and activities lined up

I will also be active in the community and expo area around the OneNote and Skype for Business booth during the week. Do not hesitate to search me out and talk about productivity :D

Set yourself unavailable with this open source PowerShell based Pomodoro timer

Update: An executable Windows app has been created based on this open source script to simplify the process. Read about it here

MVP Jan Egil Ring and I have created a GitHub PowerShell project called PsProductivityTools. There you will find a function called Start-Pomodoro with the following features

  • Count down for 25 minutes by default or a period specified by you
    • Start-Pomodoro -Minutes 10
  • The function will set your computer in presentation mode which will suppress all notifications and popups on your windows machine
  • Set your Skype for Business client in Do Not Disturb using a custom presence state called Pomodoro Sprint and set your personal note to when you will be available
  • You can mute and unmute your phone during the Pomodoro Sprint using IFTTT triggers
    • You need to have created the mute and unmute triggers, generated a webhook key and installed IFTTT on your mobile
    • Will write a tutorial in a later blogpost
  • It will make you available again after 25 minutes or your specified time, turning on notifications, making you available again in Skype for Business and unmute your phone. Awesome stuff :)

This is an open source project on GitHub so please feel free to add your own suggestions to the project.

How to get started

  1. Open PowerShell and run the following cmdlet
    • Install-Module -Name PSProductivityTools
    • if you need to update it later run Update-Module -Name PSProductivityTools and restart all PowerShell instances
    • You need to run PowerShell as administrator in order to install the module
  2. Now you can run Start-Pomdoro at any time from PowerShell
    • Start-Pomodoro
      • This will set your computer in presentation mode
    • Start-Pomodoro -Minutes 15 -EndPersonalNote “It’s a good day today”

What is the Pomodoro Technique?

The goal of the technique is to reduce the impact of internal and external interruptions on focus and flow. A pomodoro is indivisible. When interrupted during a pomodoro, either the other activity must be recorded and postponed (inform – negotiate – schedule – call back) or the pomodoro must be abandoned. The technique uses a timer to break down work into intervals, traditionally 25 minutes in length, separated by short breaks. These intervals are named pomodoros. Read more about the Pomodoro Technique here

Why the Pomodoro Technique?

If I can get one Pomodoro done in between meetings, workshops and calls, then I am happy. That Pomodoro is priceless and it helps me answer that long email, get started on that document or wrap my head around a problem. 25 minutes is long enough so that I can reach my flow state and short enough that I feel that I actually can do it. It may take between 5-10 minutes to reach the flow state. If I manage to interrupt myself with social media, coffee break or decide to do something else, then I may spend longer time in total on that email instead of just get it done during a Pomodoro. If you want to succeed with Pomodoro, you need to make yourself unavailable, but equally important, you need to make yourself available again when those 25 minutes have passed. That is why we created the Pomodoro PowerShell tool

What is flow?

Flow is the peak performance state where you feel your best and you perform your best. The good news is, it’s hackable. One of the hacks is inducing flow using the Pomodoro Technique. Read more about flow over at the Flow Genome Project

An important part of succeeding with the Pomodoro Technique is lists with your most important tasks that you can prioritize. I use OneNote for that. Check out how I do it in my OneNote LifeHacks YouTube series 

How to set custom presence states in Skype for Business on your Windows machine

This works on Windows 10, Windows 8, Windows 7, Lync and Skype for Business desktop clients. Requires administrative rights to your computer. Make sure you check out the Pomodoro Windows App that makes it even easier to set custom presence states

Wouldn’t it be cool if you could change your presence state in Skype for Business to match you current task such as busy in a Workshop, Do Not Disturb in a Pomodoro Sprint or Away Getting Coffee?

Turns out, you can by creating an XML file and adding a setting in your local registry. How? The easy way is to download my script, change the custom presences that is predefined in the script and run it.

  1. Download the script from TechNet Gallery
  2. The default custom presence states are shown below
  3. To change the names you need to open the script and write your own presence states
    • Away does not work as a custom presence state, if you put that in no custom states will show up in the client
    • The presence states that works are: Online, Busy, and Do-Not-Disturb
  4. To run the script, just type the following in PowerShell in elevated mode from the location you saved it
    • .\Set-CsCustomPresence.ps1
    • It works for Lync and Skype for Business
    • It works for 64-bit and 32-bit office
    • It works for MSI installed Office and Click-to-Run Office
    • The xml file will get stored under c:\_CustomPresence\CustomPresence.xml if that is your systemdrive
  5. You need to sign out of the client and back in for the changes to take effect
  6. The presence states works in the following scenarios
    • On English Skype for Business clients for you and your colleagues
    • On Skype for Business clients in your local location retrieved using (Get-Culture).LCID
    • For everyone in your Colleagues relationship level as long as they are running a client language version specified above
    • If you want external contacts to see your custom presence state you need to elevate them as colleagues in the relationship pane
      • Understand that they will also see you as in a meeting, in a call, your note and your location as well
    • If you are in an environment with more than two languages for you Office deployment, make sure you add an LCID per language in the script

Download the script here and use PowerShell to control your presence using the Lync 2013 Client SDK described here

You can now control you custom presence states using PowerShell, if you have installed the SDK, using the Publish-SfBContactInformation.ps1 found on GitHub here with this syntax

Publish-SfBContactInformation -CustomActivityId 1 -PersonalNote "Getting Stuff Done" -Location "@HomeOffice"

You are now ready to use this in a Pomodoro context, read how to get started with the open source PowerShell based Pomodoro timer here: https://msunified.net/2013/11/25/lock-down-your-lync-status-and-pc-notifications-using-powershell/

How to install the Lync 2013 Client SDK

To install the Lync 2013 Client SDK you need to have administrator rights to your computer. This works on Windows 10, Windows 8, Windows 7, Lync and Skype for Business desktop clients.

Why would you install the SDK? Because you can then play with some of the client settings such as presence states using PowerShell. How can  you do that? Download and use this script. You can also use it with my Pomodoro PowerShell timer

How to installing the SDK without having to install Visual Studio

  1. Download the Lync SDK from this link, do not run the exe file
  2. To avoid the requirement to have Lync 2013 installed and the need to install Visual Studio, you need to extract the files using winrar
    • You will then get two msi files
    • Run the one that matches the bitness of your Office installation
      • To find out if you have a 64-bit Office or a 32-bit Office
        • Open Word, go to file->Account->About Word and see you version as in the picture
      • Install lyncsdk86.msi if you have a 32-bit Office
      • install lyncsdk64.msi if you have a 64-bit Office
  3. You have now successfully installed the Lync 2013 SDK
    • Microsoft has not released a SDK for Skype for Business, but the Lync 2013 Client SDK works great

To get the most out of the use of the SDK, read my blog post on creating custom presence states that you can control using the PowerShell script mentioned above with the example below

Publish-SfBContactInformation -Availability "Available" -ActivityId available -PersonalNote "Getting Stuff Done" -Location "@HomeOffice"

Launching OneNote LifeHacks YouTube series

I am starting a YouTube series called OneNote LifeHacks. I will share detailed tips on how to set up OneNote to work for you. My system has 5 steps

  1. You wanting to change your habits
  2. Capture to OneNote collection section from all platform
  3. Processing and organizing information
  4. Prioritize using custom tags and find tags to create todo lists
  5. Executing on the lists and induce flow using the Pomodoro Technique

The system is heavily inspired of Getting Things Done, Inbox Zero and the Pomodoro Technique, and you can incorporate good habits that resonates with well with you. It is a robust system and all you have to do is to get started with the capture process and the rest you can do as a bonus

Check out my OneNote LifeHacks explained video

The YouTube series is based on my popular OneNote talk from MVP Community Connect in Madrid 2017 and my article on getting started with OneNote in structured way that I wrote in august 2016. The article has more than 6000 views and are still very popular. The video has over 11500 views and over 130 likes with good feedback. This is very motivational and makes me want to share more of my tips and tricks to succeed with OneNote and get stuff done using some productivity methodologies like GTD and the Pomodoro Technique

Catch me at Microsoft Ignite 2017 where I am talking about OneNote LifeHacks in a 20 minute theater talk. Will be happy to share tips and tricks in OneNote productivity