Hi Powershell Guru,
I am trying to create a Powershell 5.1 profile on Windows 10 Pro. with the following steps but kept encountering a persistent error:
( i ) C:\>dir c:\mypreferredconsole.psc 13-Jun-18 7:10 AM 159 mypreferredconsole.psc
( ii ) The content of C:\mypreferredconsole.psc is: <?xml version="1.0" encoding="utf-8"?> <PSConsoleFile ConsoleSchemaVersion="1.0"> <PSVersion>5.1.17134.81</PSVersion> <PSSnapIns /> </PSConsoleFile> ( iii ) Create a shortcut on the Desktop. Make the target (the destination) of that shortcut C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -psconsolefile c:\mypreferredconsole.psc
Yet I kept getting the error below in a Powershell window after double clicked the shortcut :
-psconsoleFile : The term '-psconsoleFile' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if apath was included, verify that the path is correct and try again.At line:1 char:1+ -psconsoleFile c:\mypreferredconsole.psc+ ~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (-psconsoleFile:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Changing suffix .psc to .psc1 did not make any difference.
Thanks in advance,
Looks like it's a requirement that the file have an extension of "psc1". Other than that, I think it's just a matter of reordering your statement since Powershell seems to want the -psconsoleFile switch to be the first argument. Try this:
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe -psconsolefile c:\mypreferredconsole.psc1 -noexit
That is because PS profiles are not .psc extensions and you only have to do this to create them.
To create a console host profile. Open powershell.exe and use the commands below, it takes care of the filename and extension for you.
To create an ISE profileOpen powershell.exe and use the commands below, it takes care of the filename and extension for you.
You'd do exactly the same thing in VSCode, if you later decide to use that for PS work vs the default console host or ISE.
How to Create a Windows PowerShell Profile
Test-path $profileNew-item –type file –force $profile
Windows PowerShell Profiles
Understanding the Profiles
You can have four different profiles in Windows PowerShell. The profiles are listed in load order. The most specific profiles have precedence over less specific profiles where they apply.• %windir%\system32\WindowsPowerShell\v1.0\profile.ps1
This profile applies to all users and all shells.
• %windir%\system32\WindowsPowerShell\v1.0\ Microsoft.PowerShell_profile.ps1
This profile applies to all users, but only to the Microsoft.PowerShell shell.
• %UserProfile%\My Documents\WindowsPowerShell\profile.ps1
This profile applies only to the current user, but affects all shells.
• %UserProfile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
This profile applies only to the current user and the Microsoft.PowerShell shell.
Thank you cmartin16 for generous suggestion that worked straight away.
Thank so much Postanote for providing exhaustive information to grasp this concept and fast track my Powershell learning experience.
I am endeavoring to make a Powershell 5.1 profile on Windows 10 Pro. by the accompanying advances yet continued experiencing a constant blunder:
13-Jun-18 7:10 AM 159 mypreferredconsole.psc
The substance of C:\mypreferredconsole.psc are:
Make an easy route on the Desktop. Make the objective (the goal) of that easy route
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe - noexit - psconsolefile c:\mypreferredconsole.psc
However I continued getting the mistake underneath where it can't find c:\mypreferredconsole.psc:
- psconsoleFile : The term '- psconsoleFile' isn't perceived as the name of a cmdlet, work, content record, or operable program. Check the spelling of the name, or if a way was incorporated, confirm that the way is right and attempt once more. At line:1 char:1 + - psconsoleFile c:\mypreferredconsole.psc + ~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (- psconsoleFile:String) , CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Evolving addition .psc to .psc1 did not have any effect.
Much obliged ahead of time,