Skip to content

Commit 3c2a3e0

Browse files
author
Daniele Catanesi
committed
Revert "Added new post"
This reverts commit 17f89f5.
1 parent 17f89f5 commit 3c2a3e0

File tree

2 files changed

+34
-93
lines changed

2 files changed

+34
-93
lines changed
Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,57 @@
11
---
2-
title: "PowerShell - Get day of weekday"
3-
excerpt: "In this short post we will see how we can use PowerShell to get an integer representing the number associated with the day of the week for the current date."
2+
title: "Cannot bind argument to parameter TokenExpiryTime because it is null - Error Message"
3+
excerpt: "When opening a PowerShell session to both on-prem and Exchange online in the same window cannot bing argument to parameter TokenExpiryTime because is null error message could be displayed. Let's explore how to solve this."
44
categories:
55
- PowerShell
6-
- Howto
6+
- Exchange
7+
- Office 365
78

89
tags:
910
- PowerShell
10-
- Tips
11-
- HowTo
11+
- Office365
12+
- Exchange
1213

1314
toc: true
1415
header:
1516
teaser: "/assets/images/PowerShell_Logo.png"
1617
---
1718

18-
## PowerShell Get current date
19+
## Exchange Online Certificate Based authentication
1920

20-
PowerShell natively supports getting the current, or specific, date via the following cmdlet:
21+
Microsoft is, _finally_, disabling **basic authentication** (read username and password) in Exchange Online in favor of **Certificate Based authentication**.
2122

22-
```powershell
23-
Get-Date
24-
```
25-
Which, by default, will produce the following output:
23+
Once this change is fully implemented, around mid February at least for some tenants, connecting via username and passwords to Exchange Online will not be possible anymore.
2624

27-
```powershell
28-
Monday, February 21, 2022 10:11:39 PM
29-
```
25+
You can read my article on how to implement _Certificate Based authentication_ for Exchange Online [here](https://pscustomobject.github.io/powershell/office365/exchange/Exchange-Online-Certificate-Based-Authentication/).
3026

31-
Cmdlet supports methods which can be used to display/return the day of the week for the selected date
27+
As a result of this change I started updating one of our automations, responsible for the whole life-cycle of our mailboxes, to ditch old credential objects in favor of the more secure Certificate Authentication.
3228

33-
```powershell
34-
(Get-Date).DayOfWeek
35-
```
29+
This is when I encountered the _cannot bind argument to parameter 'token expiry time' because it is null._ error message.
30+
31+
## Multiple PowerShell Exchange Sessions
3632

37-
There are situations where rather than returning a string with the day name it can be useful to return the **number** (1 to 7) associated with the day's name, this can easily be accomplished with the following command
33+
When operating an hybrid environment it is pretty common to open, in the same window/session, a PowerShell connection to both Exchange on-prem and Exchange Online.
34+
35+
This is required as part of the configuration, usually creation of the mailbox, takes place in on-prem for example via the _New-RemoteMailbox_ cmdlet while other parts of the configuration are performed directly online for example when delegating mailbox permissions.
36+
37+
While debugging my workflow I have noticed that, while trying to retreive mailbox information from the on-prem server, an exception was being thrown
3838

3939
```powershell
40-
(Get-Date).DayOfWeek.value__
40+
# Cmdlet I was running
41+
Get-RemoteMailbox -Identity $userUpn
4142
42-
# Output
43-
1
43+
# Part of the exception message
44+
Cannot bind argument to parameter 'token expiry time' because it is null.
4445
```
4546

46-
This is specially handy when inserting data into SQL datbase supporting dates as *TinyInt* data types.
47+
It took me a bit to figure this out as no exception was thrown during the connection *phase* either nor there was any other obvious pointer.
48+
49+
When I was about to give up and open a ticket with Microsoft, which is usually as helpful as freezer in the North Pole, I discovered that establishing a connection to Exchange Online followed by a connection to the on-prem server was yielding the desired result. In my workflow I had this the other way around, first local Exchange and then Online service, which was causing the issue.
50+
51+
**Note:** I have experienced/tested this with version 2.0.4 and 2.0.5 of Exchange Online PowerShell module but other versions could be affected as well.
52+
{: .notice--warning}
53+
54+
I did not dig deep into the root cause of the issue but plan to do this tomorrow and already sent my feedback to exocmdletpreview {at} service {dot} microsoft {dot} com but I doubt I will hear anything from that channel.
55+
I will anyhow open a ticket with support to at least have an official statement/clarification on this.
56+
57+
As soon as I have any news I will update the post until then I hope you can find the information useful.

_posts/2022-02-22-PowerShell-Get-Weekday.md

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)