Powershell Profile -- If we place any .ps1 powershell file in this profile location that file will run everytime when powershell startup.
To know the profile location
PS> $profile # It displays full path of the powershell profile. It shows Microsoft.Powershell_profile.ps1 file along with path that means that file doesn't have to exist, If you create profile the system will create fil in that path
C:\Users\kalyan\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# We can check whether the profile is already exists or not using test-path, If the file exists it returns true otherwise false
PS > test-path $Profile
False
### Using the below syntax we can creat powershell profile ###
Type the below command and hit enter key to create profile
PS > New-Item -Type file -Path $profile -Force
Directory: C:\Users\kalyan\Documents\WindowsPowerShell
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/9/2014 3:46 PM 0 Microsoft.PowerShell_profile.ps1
# Now test-path returns true
PS > test-path $Profile
True
You can browse the profile file using the above path and include the below string and save the file, Now open the powershell It displays good day to you everytime when you open powershell
echo "good day"
To know the profile location
PS> $profile # It displays full path of the powershell profile. It shows Microsoft.Powershell_profile.ps1 file along with path that means that file doesn't have to exist, If you create profile the system will create fil in that path
C:\Users\kalyan\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# We can check whether the profile is already exists or not using test-path, If the file exists it returns true otherwise false
PS > test-path $Profile
False
### Using the below syntax we can creat powershell profile ###
Type the below command and hit enter key to create profile
PS > New-Item -Type file -Path $profile -Force
Directory: C:\Users\kalyan\Documents\WindowsPowerShell
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/9/2014 3:46 PM 0 Microsoft.PowerShell_profile.ps1
# Now test-path returns true
PS > test-path $Profile
True
You can browse the profile file using the above path and include the below string and save the file, Now open the powershell It displays good day to you everytime when you open powershell
echo "good day"
No comments: