ProfileCreation in Powershell
ProfileCreation in Powershell
If the result = True. Profile exists (skip steps 2 & 3). Unless you want to create a new profile, which will delete the current profile. Step 2. Create a new profile. New-Item -Path $Profile -ItemType file -Force <enter> Step 3. Verify new profile was created. Repeat step 1. Result should equal True. Lets open our new profile in notepad: notepad $Profile <enter>
Image 3.9 Isnt that great! We have a blank page! The important thing to note: We have a script file called Microsoft.PowerShell_profile.ps1 This script file will be called using the $Profile variable each time a PowerShell session is launched. What goes into the script file will be up to you, how you decide to configure your PowerShell environment. For now, lets have our profile load our custom user-defined PowerShell alias. Edit and Save the profile as shown below:
Image 3.10 After you have saved the profile, close notepad, and exit the PowerShell session. Launch a new PowerShell session and verify that your custom alias is functional: gs <enter> Viola! your profile has loaded successfully and your alias is working. Use Get -Alias cmdlet to verify the existence of your new alias: Get-Alias <enter> -or- a more refined search: Get-Alias -Name gs <enter>