Professional Documents
Culture Documents
Export-Alias c:\scripts\test.txt
# Alias File
# Exported by : kenmyer
# Date/Time : Saturday, May 06, 2006 4:12:53 PM
# Machine : TVSFRANK
"ac","Add-Content","","ReadOnly, AllScope"
"clc","Clear-Content","","ReadOnly, AllScope"
"cli","clear-item","","ReadOnly, AllScope"
Alternatively, you can export your aliases as a script file, a file that uses a
series of Set-Alias cmdlets (and thus a file that can be run as a Windows
PowerShell script in order to configure those aliases). To do that, tack on the -as
parameter, setting the value to script. That command looks like this:
# Alias File
# Exported by : kenmyer
# Date/Time : Saturday, May 06, 2006 4:14:04 PM
# Machine : TVSFRANK
set-alias -Name:"ac" -Value:"Add-Content" -Description:"" -Option:"ReadOnly,
AllScope"
set-alias -Name:"clc" -Value:"Clear-Content" -Description:"" -Option:"ReadOnly,
AllScope"
set-alias -Name:"cli" -Value:"clear-item" -Description:"" -Option:"ReadOnly,
AllScope"
Just for the heck of it, you might also want to export a single alias or set of
aliases. For example, suppose youve created a set of aliases, each one starting
with the letter X. To export these aliases as a script (thus making it easy for
someone else to configure those same aliases on their computer) use the -name
parameter along with the wildcard X*:
By default Export-Alias will overwrite any existing files with the same name; if a
file named Test.txt already exists then Export-Alias will overwrite that file. To
prevent that from happening, just add the -noclobber parameter:
Export-Alias c:\scripts\test.txt -noclobber
If you run this command and Test.xml already exists youll get back the following
error message:
Export-Alias Aliases
epal