Professional Documents
Culture Documents
Advanced
Windows PowerShell
Tips and Tricks
Module Overview
Create and safely use a Windows PowerShell profile script
Repackage scripts as script modules for easier distribution
modules
scripts
Why Profiles?
Each time you start a new PowerShell session, you begin
Default configurations
Default aliases
Default everything!
Profile Locations
Profile scripts can be found
Profile Security
Caution: Your profile script could be used as a vector for
It executes automatically
shell
Functions
A function is a way of writing your own command
The last module in this course teaches how to create your own
functions
scopes
elements execute
Dot Sourcing
Dot sourcing is a way of eliminating the box around a
When you need to use a library function, dot source the library
script that contains the function
Script Modules
Dot sourcing is effective, but it is also confusing
Script modules offer a more formal and structured way to
Dir env:\psmodulepath
functions
These functions are for use within the script itself, but are not
exposed to users who import the module into their shell.
Manifests list your script module and its supporting files, such
as formatting views, that must be loaded with your module.
Demonstration: Export-ModuleMember
Learn how to create private functions within a script
module
shell
Help
Youve already experienced the robust built-in help
Command syntax
Usage examples
Shell capabilities
You can build help into your own scripts and functions
Comment-Based Help
Comment-based help can be added to scripts or functions
function
Logon information
Virtual machine
LON-SVR1
Contoso\Administrator
Password
Pa$$w0rd
Lab Scenario
You are a system administrator and have been developing
Lab Review
Whats the difference between adding comment-based
current-host profile?