question

vinayvernekar-4559 avatar image
0 Votes"
vinayvernekar-4559 asked IanXue-MSFT answered

Powershell profile Creation

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
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

To follow-up, Please let us know if you have further query on this.
Please don’t forget to Accept the answer

0 Votes 0 ·
learn2skills avatar image
0 Votes"
learn2skills answered

Hi @vinayvernekar-4559
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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.