powershell modules

Write a powershell script.  Change the name to name.psm1.  Save it in a folder called “name” (per Jaykul, a module is BOTH a file and a directory.)  And the directory is…?

You can provide the full path to the directory when you load the module.  More often, it is found in one of several places stored in the environmental variable PSModulePath.  (you can get a list of the env: variables with get-childitem Env:.  This will also tell you if JAVA_HOME has been set.).  You can invoke it directly with $Env:PSModulePath.

You can also modify the $Env:PSModulePath variable to add a Working Directory for modules.

Typically, the modules are loaded into one of them (folder + file (psm1, dll or psd1), then you can load it with import-module NAME (loads it into the current session.  If you want it always loaded, add to your profile).  If you want to see your choices, use get-module -listAvailable to see what is available to import.  And if load something, you can remove it from the current session with Remove-module NAME.  You need to use Get-Module to know what the name is.   Otherwise, get-module|remove-module will unload everything loaded.

So you went and loaded it.  Now – what can you DO with it?  try get-command -module NAME to list the commandType and Name of various cmdlets.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.