Powershell profiles are great. Remember settings, add personal functions, variables and aliases.

Nice.

But what about other devices? Create and maintain new profiles on each device you own? Copy the profile from device to device. And remember doing this over and over? Pffff… what a hassle.

Sync your PowerShell profile on a cloud location

Get your sync going

First, choose your favorite cloud storage location. Also make sure this location is accessible from Windows Explorer.

I’m using my OneDrive for Business account as my storage solution. The next-gen sync client works like a charm.

For a list of cloud storage service you can check out this great article.

Reference another location (dot-sourcing)

The default location for the $profile variable refers to $Home\[My ]Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1. According to Microsoft this is a read-only variable. So, we cannot change this location. But, if you know how to adjust this variable to a different path… That would be great.

In the mean time we can “link” our cloud storage location. For example you could create a new .ps1 script in your OneDrive for Business folder. I placed mine in this location: “C:\Users\YvesRosius\OneDrive – Flexamit\Documents\Scrippies\Powershell\Roaming_Profile.ps1”.

Make sure you created a PowerShell profile before. Once all files in place, you can make changes to your profile by editing it in your favorite text editor. The built-in Windows PowerShell ISE suits our needs fine.

Add a new line in your profile. In my case this would be: . “C:\Users\YvesRosius\OneDrive – Flexamit\Documents\Scrippies\Powershell\Roaming_Profile.ps1”. Don’t forget to insert a space between your dot and your path!

Note

The Windows PowerShell execution policy determines whether you can run scripts and load a profile. The default execution policy, “Restricted,” prevents all scripts from running, including profiles. If you use the “Restricted” policy, the profile cannot load. For more information about execution policy, see about_Execution_Policies [v4].

Sync all devices

Ok, great. We have completed all steps on this system. Now, for ultimate roaming capability, we need to perform these steps on all of your devices.

  • Install cloud sync tool
  • Check if $profile exists
  • Adjust PowerShell execution policy (see note)
  • Dot-source our script from within you $profile
  • Repeat on all devices

Have fun roaming 🙂