Zum Inhalt springen

Share Powershell Profiles and Modules accross multiple Computers

With OneDrive we have a possibility to sync several kind of content between a local computer and the cloud.
I put my scripts under development in a OneDrive Folder and have the possibility to work on them from any system that i have access to.

I use OneDrive to share the Powershell profile scripts and modules across all my systems, so that i can do changes on one point.
On my OneDrive i have create seperat folders PSProfiles and Modules for the content and then moved all the content to the correspondenting folders in the cloud. To use the profiles script from the OneDrive Folder i had to create hard links to the needed files at the Windows PowerShell profile script path. For this I use fsutil.exe in a priviled cmd box.

#PowerShell Profile for PowerShell Console
$psConsoleProfile = "$env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1"            

#PowerShell Profile for PowerShell ISE
$psISEProfile = "$env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1"            

#Create a hard link to PowerShell console profile
fsutil hardlink create $psConsoleProfile "C:\Users\XXX\OneDrive\Powershell\PSProfiles\Microsoft.PowerShell_profile.ps1"            

#Create a hard link to PowerShell console profile
fsutil hardlink create $psISEProfile "C:\Users\XXX\OneDrive\Powershell\PSProfiles\Microsoft.PowerShellISE_profile.ps1"

The same appoach I use to share some Powershell Modules with OneDrive. I have moved the entire module directory to the Onedrive Folder. With the sysinternals tool junction i had to create the directory hard link for the local module directory. It´s awesome.

junction.exe "C:\Users\XXX\Documents\WindowsPowershell\Modules" "C:\Users\XXX\OneDrive\Powershell\Modules"

Module Folder

Ensure that PowerShell can still see the module from your OneDrive Folder

Get-Module -ListAvailable

PowershellModules

You can use Dropbox instead of Onedrive, in the same way 🙂 For a free 15 GB Onderive klick here or for 2 GB free DropBox space.

Print Friendly, PDF & Email
Schlagwörter:

2 Gedanken zu „Share Powershell Profiles and Modules accross multiple Computers“

  1. Pingback: #PowerShell Weekly 20150825 – The Best New PowerShell Content of the Week @ Scott Ge

Die Kommentarfunktion ist deaktiviert.

%d Bloggern gefällt das: