A question came up in a class I was teaching: “How do you share your Powershell profiles across accounts?”
Well, there’s documented way of sharing profiles on the same machine where you create an All Users profile. As stated in help about_Profiles Powershell will look in the following locations for profiles:
Name Description ----------- ----------- $Profile Current User,Current Host $Profile.CurrentUserCurrentHost Current User,Current Host $Profile.CurrentUserAllHosts Current User,All Hosts $Profile.AllUsersCurrentHost All Users, Current Host $Profile.AllUsersAllHosts All Users, All Hosts
The All Users profile creation is a little odd in that you would need to create your profiles in the $pshome directory instead of the $home directory. The $pshome directory is the location where powershell.exe is installed i.e. C:WindowsSystem32WindowsPowerShellv1.0 while $home is under <user>DocumentsWindowsPowershell.
I don’t like messing with storing my shared profiles in a system directory, so instead I use a different technique…
I’ve previously blogged about Symlinks, but I didn’t mention I use them for sharing profiles. Note: This requires Vista, Windows 7 or 2008 or higher OS. So here’s the steps to share profiles using symlinks:
- Create A WindowsPowershell folder or copy your existing WindowsPowershell to a shared location. I use C:UsersPublicDocuments.
- Make sure your accounts don’t have a WindowsPowershell folder under <user>Documents already.
- Start a classic Window command prompt as Administrator (that’s right don’t use Powershell to create symlinks)
- Change directories to the Documents folder for account you want to share profiles
- Run the following command
c:Usersu00Documents>mklink /D WindowsPowerShell C:usersPublicDocumentsWindowsPowerShell symbolic link created for WindowsPowerShell <<===>> C:usersPublicDocumentsWindowsPowerShell
Repeat steps 4 and 5 for each account.
You now can now share profiles and modules across accounts on the same computer.