Not able to create Powershell profile - psconsolefile

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 a
path 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,

Mary

Parents
  • 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 profile
    Open 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 $profile
    New-item –type file –force $profile


    'technet.microsoft.com/en-us/library/ff461033.aspx'


    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.


    'technet.microsoft.com/en-us/library/bb613488(v=vs.85).aspx'

Reply Children
No Data