Featured post
How do I make a PowerShell profile if my profile path contains an apostrophe? -
i'm trying set powershell profile of machines have common profile. i'm making each machine's profile run script in dropbox can update of them easier.
i thought problem didn't know dot-source syntax well, turns out powershell doesn't path documents folder has apostrophe. full path is:
d:\owen's documents\windowspowershell\microsoft.powershell_profile.ps1
if delete file, powershell starts fine (of course, without modifications want.) if create file, error when powershell starts up:
the string starting: @ line:1 char:75 + . 'd:\owen`'s documents\windowspowershell\microsoft.powershell_profile.ps1 <<<< ' missing terminator: '. @ line:1 char:76 + . 'd:\owen`'s documents\windowspowershell\microsoft.powershell_profile.ps1' <<<< + categoryinfo : parsererror: (:string) [], parentcontainserrorrecordexception + fullyqualifiederrorid : terminatorexpectedatendofstring
it can't fault, because script empty. deleting empty file makes go away, creating new file makes error come back. surely microsoft anticipated profile paths apostrophes?
update crud. looks old issue. maybe there's not workaround. :(
update 2 had conversation @lee_holmes on twitter this. apparently it's been fixed in super-awesome internal microsoft version, there's no hotfix available , no time table fixes since psh windows component. makes roman kuzmin's answer below appropriate answer (use 1 of global profiles), or perhaps "rename documents folder" hasn't been mentioned yet.
the similar bug reported , presumably acknowledged: powershell errors apostrophe in path
the error message different though, due different powershell version, more likely.
perhaps there no direct workaround: faulty call not under our control. if renaming of troublesome directory not option perhaps alternative location of profile can suitable solution. try put profile $pshome
.
> man about_profiles ... example, windows powershell console supports following basic profile files. profiles listed in precedence order. first profile has highest precedence. description path ----------- ---- current user, current host $home\[my ]documents\windowspowershell\profile.ps1 current user, hosts $home\[my ]documents\profile.ps1 users, current host $pshome\microsoft.powershell_profile.ps1 users, hosts $pshome\profile.ps1 ...
the last 2 profile locations should work (unless $pshome
contains problem characters, indeed).
- Get link
- X
- Other Apps
Comments
Post a Comment