header image

drive letter functions

Posted by: | July 30, 2013 | No Comment |

Have you ever looked at the functions available to you in PowerShell?

Get-ChildItem function:

shows the list of functions currently available in your PowerShell session.

function: is a PowerShell drive.  Other drives are available:

£ Get-PSDrive

Name           Used (GB)     Free (GB) Provider      Root
—-           ———     ——— ——–      —-
Alias                                  Alias
C                 103.58        129.21 FileSystem    C:\
Cert                                   Certificate   \
D                    .03           .06 FileSystem    D:\
E                                      FileSystem    E:\
Env                                    Environment
F                                      FileSystem    F:\
Function                               Function
HKCU                                   Registry      HKEY_CURRENT_USER
HKLM                                   Registry      HKEY_LOCAL_MACHINE
Variable                               Variable
WSMan                                  WSMan

These drives are created by PowerShell providers – functionality that exposes data stores as if they were file systems.  Other providers include AD, SQL Server and IIS if you have those installed.

The function drive enables you to work directly with functions. You can view their details:

£ get-command c: | fl *

PSPath              : Microsoft.PowerShell.Core\Function::C:
PSDrive             : Function
PSProvider          : Microsoft.PowerShell.Core\Function
PSIsContainer       : False
HelpUri             :
ScriptBlock         : Set-Location C:
CmdletBinding       : False
DefaultParameterSet :
Definition          : Set-Location C:
Options             : None
Description         :
Verb                :
Noun                :
HelpFile            : System.Management.Automation.dll-Help.xml
OutputType          : {}
Name                : C:
CommandType         : Function
Visibility          : Public
ModuleName          :
Module              :
RemotingCapability  : PowerShell
Parameters          : {}
ParameterSets       : {}

In this case the information is minimal because all the function does is set your location to the c: drive.

The important part is that you can investigate functions as you will see later

under: PowerShell original