Search This Blog


Invoke-RestMethod and self-signed certificates

As part of my study of Powershell I tried to connect to some REST API using an encrypted connection to a dev webserver. As it's a dev server the certificate is self signed so not "valid" for Powershell scripts

First problem

PS C:\Users\Frank> $headers = @{accept = "application/json"}
PS C:\Users\Frank> Invoke-RestMethod -Uri $uri/session -Method Post -Body $jsonCred -ContentType application/json -SessionVariable xsSession -Headers $headers

Invoke-RestMethod : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
At line:1 char:1
+ Invoke-RestMethod -Uri $uri/session -Method Post -Body $jsonCred -ContentType ap ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Wrong solution found on Internet

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
This command will work only for the first call of invoke-restmethod or invoke-webmethod, any further call to Invoke-RestMethod will FAIL with this message
"Invoke-RestMethod : The underlying connection was closed: An unexpected error occurred on a send."

Good solution

I found the following piece of code to work perfectly. Copy paste it in your script or directly in the powershell windows shell.
Original solution post

# Only to ignore certificates errors
add-type @"
        using System.Net;
        using System.Security.Cryptography.X509Certificates;

            public class IDontCarePolicy : ICertificatePolicy {
            public IDontCarePolicy() {}
            public bool CheckValidationResult(
                ServicePoint sPoint, X509Certificate cert,
                WebRequest wRequest, int certProb) {
                return true;
[System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy
# From now on the Invoke-restMethod and Invoke-webmethod calls will work with an invalid certificate



How do I lock and unlock the Fn key on a surface computer

Just press Fn+Caps will lock/unlock the Fn key

No tooltip will indicate the change of state


How to keep LIFE, sleep and work in harmony

Hi everyone

In this previous post I list my values, sharing is among those.
I feel particularly proud of my the balance and the harmony of my life and I want to share how you can achieve it in a dedicated blog.

By Jaime Fearer –

The first post is here and it's not yet available to the public, because I need your help, as privileged editors. Please review and comment for the blog to start with the right foot.

Don't be shy, comment on typos; graphics; why you'll (or will not) follow it; which topics you'd like to see discussed.

"The moving thinking tank" will continue to exist as a representation of all the ideas, technicalities and curiosities I've in my brain. There will be a post a week as usual.

Thank you

PS: John, please follow the new blog


Receipe: Pasta with Salmon

Lets have a change, this evening I've got a subliminal message from my wife: "Tonight you cook, I bought pasta and salmon". So here we go for all of you a recette just tested

Come on guys lets prepare a very simple dish for your lady! 10 minutes, one boiling pan, one frying pan and some steps.

Initially I wrote the post with 11 steps to prepare the pasta then discovered that bbc has a receipe in 4 steps. I'm including both, mine is for 2 with less onion and allow for more mistakes.

Frank's style
  • 200g of pasta. Tradition would say "penne" but take what you have
  • 200g of salmon. Smoked or freshed is not that important
  • 70g of single cream (or double or creme fraiche)
  • 1/8 or onion 
  • 10 g of butter (cut an angle) 
  • 10 g of olive oil (throw 2 coffee spoon in the pan)
  • Pamiggiano reggiano
You need one boiling pan and a frying pan

1) Bring 1 liter of water to boil in the boiling pan with a fist of big salt
2) Drop the pasta in the boiling pan and put a timer as indicated on the pasta package
3) Put the frying pan over high fire
4) put in the butter and oil together in the frying pan. FYI "the mix oil and butter is to reach the right temperature without burning the butter"
5) meanwhile cut the 1/8 or onion. 
6) when the butter is melted drop the onion in the pan and wait for a couple of minutes while you...
7) ... cut the salmon in small pieces, and drop them in with the butter and onion
8) reduce the frying pan fire to medium (not to burn it all)
8) one minute before the pasta time is over put the single cream in the frying pan and mix
9) pasta is ready, drain the pasta and put it in the frying pan with all the other ingredients, while the fire is still on. 
10) mix mix mix and serve.
11) bring parmiggiano on the table so she can add it as preferred
12 Enjoy



Preparation method

  1. Cook the pasta according to packet instructions in a pan of salted boiling water, then drain.
  2. Meanwhile, heat the oil in a frying pan, add the garlic and red onion and fry for 3-4 minutes or until the onion has softened.
  3. Add the salmon cubes and double cream and continue to cook over a gentle heat for five minutes, or until the salmon has cooked through.
  4. Stir in the drained pasta and season, to taste, with salt and freshly ground black pepper. Stir in the parsley.


How to stop new e-mails to kill your productivity

Unless kept under control, reading and writing e-mail can become the only activity of the working hours. Valuable work or Brain work, the one requiring thinking and psychic energy is left for the worst hours.

To do brain work you need to reduce distractions as much as possible.

The reason for most of the interruptions in an office is a new e-mail in the inbox. It's almost automatic, you look at the e-mail, take time to decide if it should be read and answered. By doing this you loose your focus and lots of psychic energy.

So first thing to do when starting a brain work is to block new e-mails from coming, while being able to read old e-mail and write new one.

In Outlook 2013 you can achieve this by turning on the "Offline mode"!

Accessible from the Send/Receive tab it tells Outlook to stop sending and receiving new mail while allowing to access old e-mail and prepare new email to be sent after the brain work is done.

Here is where you can find the button in Outlook 2013

This is the icon of Outlook indicating that offline mode is ON
Offline is ON

To turn if off, simply press the Work Offline button again

A bientot
Frank Contrepois


How do I print long documents in OneNote as a continuous paper?

Check this blog article (


"Live by your values, pursue your goals to achieve your mission in life"

Hi all

"Live by your values, pursue your goals to achieve your mission in life" - Frank Contrepois

Finding your values, mission and goals is a great way toward a better life. Here is why you should search yours now.

Values are the filter your action need to go through to be good ones. You have values, coming from education, tradition, family and experience. You might not have a list of them but you have them. Values help you  make decisions every day and shape your day and how others see you. Finding the  most important values allow you to make YOUR right decisions, the ones that you'll accept and that will not leave any regrets.
Find them, share them, live them.

My values are:

  • Trust - to build long term relashionship
  • Honesty - I believe in what I say
  • Improvement - to evolve, survive and be a better person
  • Sharing - as in team work
  • Fair - I understand others views
  • Open Minded - I believe in the brain and actions as the way to value people

Mission is next. I do not mean a James Bond style mission, I mean a life mission, one or more statements that define your life goal. Following your mission might requires courage, patience, perseverance (all are great values to have), it needs to be valid for a life.
By following your mission you'll have the energy to do, the commitment to succeed and the recognition of others. Having your mission clear help other understand you and your actions. It helps finding the right persons and find a job that align with your ultimate goal.

My mission is: "Live and share a happy and balanced life between family, new achievements and continuous improvements"

The short version is "No WOW is left behind": which explain that for life and work I'll be there for the most important moments not matter what.

Goals, present a shorter timeline toward your mission. A kind of what's next on the road. I recommend choosing goals with a 1 year, 3 years and 5 years horizon and try to align your activities to them. You should have goals for life, work and community (The triple bottom line) and make them hard to reach but in line toward your longer term goals and ultimately your mission.

I share my family goals only with my wife, my work goals with my wife, collegues and some friends, my community goals with everyone.

My community goals are:

  • Selling a book presenting a framework of how to maintain a life/work balance
  • Receive a prestigious award for my contribution to the world
  • Receive more than 1'000'000 positive feedback from my activities
As an example, this blog is due to the need to improve my writing skills to write the book and achieve 1'000'000 positive feedback. Comments on blog count, so don't hesitate

In conclusion, we all have values, we all have a mission and goals, but writing them down and sharing them will expand their reach and will help you live a better live. 

NB: Finding values, mission and goals is not easy and take time and mind power, so patience.

Reading related to the post:
GTD and the altitude view
7 Habits  to help on the mission creation