Powershell profile Creation

vinay vernekar 1 Reputation point
2021-02-21T05:55:35.937+00:00

Need to create Powershell Profile and Every time start it should ask to load profile Y or N. it should load only when i type Y.
Can someone help me!

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
{count} votes

2 answers

Sort by: Most helpful
  1. SUNOJ KUMAR YELURU 14,011 Reputation points MVP
    2021-02-21T06:44:21.98+00:00

    Hi @vinay vernekar
    Please refer the settings on the below url.
    How To Create PowerShell Profile Step by Step with Examples

    If the Answer is helpful, please click Accept Answer and up-vote, this can be beneficial to other community members.

    0 comments No comments

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 32,326 Reputation points Microsoft Vendor
    2021-02-22T08:41:26.997+00:00

    Hi,

    Try adding this to your profile:

    $input=Read-Host -Prompt 'Do you want to load the profile?'  
    if($input -eq 'Y'){  
    #contents of the profile  
    }  
    

    This cannot stop the profile from being loaded but it makes powershell load nothing from the profile if you don't type Y.

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments