header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
How to change powershell configuration file at run time
Last Post 11 Aug 2010 07:04 AM by Joel "Jaykul" Bennett. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
powershellerUser is Offline
New Member
New Member
Posts:1
Avatar

--
29 Jul 2010 08:19 AM
    Hi,

    I have a .net project that is built upon powershell project template.
    The project contains cmdlets and snapin to register them.

    I want to be able to change powershell configuration file (that resides in powershel home directory) at run time and use the new settings without having to restart powershell session.

    How do change configuration file on the fly and use it immediately at the current session?
    Mihail StacanovUser is Offline
    New Member
    New Member
    Posts:15
    Avatar

    --
    11 Aug 2010 12:36 AM
    #You can use these commands

    #Put your code in your profile
    "Write-Host 'Test'" | Set-Content $profile

    #After that run your profile
    & $profile

    http://proproit.com
    Joel "Jaykul" BennettUser is Offline
    Basic Member
    Basic Member
    Posts:112
    Avatar

    --
    11 Aug 2010 07:04 AM
    First of all, you should dot-source your profile, not call it, so you need:
    . $Profile

    But it's a mistake to think that changing the profile and then executing it is the same as changing it and launching a new instance of PowerShell, because you're not clearing out what has already been done, you're merely layering the effects of a new profile on top of it. As long as you're aware of the difference, dot-sourcing your profile should be ok.
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer