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 for business | Windows Server | User experience | PowerShell
{count} votes

2 answers

Sort by: Most helpful
  1. SUNOJ KUMAR YELURU 17,321 Reputation points MVP Volunteer Moderator
    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. Anonymous
    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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.