Are people even aware of this capability? For example, I like the vbscript Now function and would prefer to use Now instead of Get-Date and I don't want to set up an alias each time I launch PowerShell. I would also like to have instant access to just the date and time separately. So, I have edited my Profile to set this up for me at launch.
To edit your profile go to My Documents\PowerShell and edit the file Microsoft.PowerShell_profile.ps1 with notepad. Here is the contents of my file:
$Date = Get-Date -Format M/d/yyyy
$Time = Get-Date -Format hh:mm:ss
If the file does not already exist you will need to create it.
First determine if the Profile is created with
If you get an error then create the profile file and add data to it all in one shot.
Add-Content $Profile -value "$Date = Get-Date -Format M/d/yyyy"
Add-Content $Profile -value "$Time = Get-Date -Format hh:mm:ss"
Note that in order for profiles to work you have to have configured PowerShell security to execute scripts. To do that you need to execute the command:
Set-ExecutionPolicy -executionPolicy Unrestricted
Note that the above will allow all scripts to be run, if you use signed scripts then don't use the Unrestricted switch and instead use AllSigned. I suggest everyone look at the options with Help Set-ExecutionPolicy.
I want to point out also that it is possible from within a PS Session to export/import your Aliases. Use caution when doing this. By default ALL aliases will be exported or imported. You will then get a bunch of errors when the default aliases try to remap themselves at launch/import. It is however possible to export named aliases instead of all aliases. This is the preferred method to avoid unnecessary errors.
I hope you find this post helpful.
Check out my scripting solutions at http://www.thespidersparlor.com/vbscript