Once upon a time I was a *nix administrator and I used to make use of Message Of The Day (MOTD) files to communicate with users at logon time.

These messages would appear prior to the logon prompt blinking. All you'd have to do is place your message in /etc/motd and the *nix system would take care of the rest.


"Hello, World!"

How to do something similar in PowerShell?

As in *nix, in PowerShell we have the concept of a profile script that is loaded at user logon, prior to the logon prompt appearing. I make good use of my PowerShell $PROFILE script to customise my console, e.g. change its appearance, load certain functions, dictate specific behaviours...

$PROFILE gives you the path to this profile script. The path returned is dependant upon which console you execute $PROFILE in:



Now, you can also run a profile script under the following conditions:


Current User / Current Hosts is what I have discussed so far and it's what we think of as our PowerShell $PROFILE.

Now, notice that we have an All Users. All Hosts option, i.e. a script that will run for every user on every PowerShell host. This is perfect for our MOTD!

$Command = "Write-Host 'Hello, World!'"

$Command > $PSHOME\profile.ps1


Here we write a Message of the Day to a profile file that will execute prior to any other profile file:


Cool. Now for a new MOTD:


And they all lived happily ever after. The end. For now.


Comments (0)

Skip to main content