Avoid the use of~
to represent the home folder.The meaning of ~ is unfortunately dependent on the "current" provider at the time of execution. This isn't really a style issue, but it's an important rule for code you intend to share anyway. Instead, use${Env:UserProfile}
or(Get-PSProvider FileSystem).Home