Tag Archives: Scope

Get-PSDrive

NAME
    Get-PSDrive

SYNOPSIS
    Gets the Windows PowerShell drives in the current session.

SYNTAX
    Get-PSDrive [-LiteralName] <string[]> [-PSProvider <string[]>] [-Scope <string>] [-UseTransaction] [<CommonParameters>]

    Get-PSDrive [[-Name] <string[]>] [-PSProvider <string[]>] [-Scope <string>] [-UseTransaction] [<CommonParameters>]

DESCRIPTION
    The Get-PSDrive cmdlet gets the Windows PowerShell drives in the current session. You can get a particular drive or all drives in the console.

    Get-PSDrive gets the following drives:

    — Windows logical drives on the computer, including drives mapped to network shares.

    — Drives exposed by Windows PowerShell providers (such as the Certificate:, Function:, and Alias: drives) and the HKLM: and HKCU: drives that are exposed by the Windows PowerShell Registry provider.

    — Drives that you create by using New-PSDrive.

    Get-PSDrive does not get Windows mapped drives that are added or created after the Windows PowerShell console is opened.

PARAMETERS
    -LiteralName <string[]>
        Specifies the name of the Windows PowerShell drive.

        The value of LiteralName is used exactly as it is typed. No characters are interpreted as wildcards. If the name includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -Name <string[]>
        Gets only the specified drives. Type the drive name or letter without a colon (:).

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -PSProvider <string[]>
        Gets only the drives supported by the specified Windows PowerShell provider. Type the name of a provider, such as FileSystem, Registry, or Certificate.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -Scope <string>
        Gets only the Windows PowerShell drives in the specified scope. Valid values are “Global”, “Local”, or “Script”, or a number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent). “Local” is the default. For more information, see about_scopes.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -UseTransaction [<SwitchParameter>]
        Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_transactions.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        You cannot pipe objects to Get-PSDrive.

OUTPUTS
    System.Management.Automation.PSDriveInfo
        Get-PSDrive returns objects that represent the Windows PowerShell drives in the session.

NOTES

        The Get-PSDrive cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type “Get-PSProvider“. For more information, see about_providers.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Get-PSDrive

    Name     Provider     Root
    —-     ——–     —-
    Alias     Alias
    C         FileSystem    C:\
    cert     Certificate \
    D         FileSystem    D:\
    Env        Environment
    Function Function
    HKCU     Registry     HKEY_CURRENT_USER
    HKLM     Registry     HKEY_LOCAL_MACHINE
    Variable Variable
    X         FileSystem    X:\

    Description
    ———–
    This command gets the Windows PowerShell drives in the current session.

    The output shows the hard drive (C:) and CD-ROM drive (D:) on the computer, the drives exposed by the Windows PowerShell providers (Alias:, Cert:, Env:, Function:, HKCU:, HKLM:, and Variable:), and a drive mapped to a network share (X:).

    ————————– EXAMPLE 2 ————————–

    C:\PS>Get-PSDrive d

    Name     Provider     Root
    —-     ——–     —-
    D         FileSystem    D:\

    Description
    ———–
    This command displays the D: drive on the computer. Note that the drive letter is not followed by a colon.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Get-PSDrive -PSProvider FileSystem

    Name     Provider     Root
    —-     ——–     —-
    C         FileSystem    C:\
    D         FileSystem    D:\
    X         FileSystem    X:\
    Y         FileSystem    \\Server01\Public
    Z         FileSystem    C:\Windows\System32

    Description
    ———–
    This command displays all of the drives that are supported by the Windows PowerShell FileSystem provider. This includes fixed drives, logical partitions, mapped network drives, and drives that you create by using New-PSDrive that are mapped to the file system drives.

    This example shows that drives created by New-PSDrive have the name of the mapped location in the value of the Root property. Windows drives just have the root of the drive letter.

    ————————– EXAMPLE 4 ————————–

    C:\PS>if (!(Get-PSDrive X)) {
        New-PSDrive -Name X -PSProvider Registry -root HKLM:\Network
    }
    else { Write-Host “The X: drive is already in use.” }

    Description
    ———–
    This command checks to see whether the X drive is already in use as the Windows PowerShell drive name. If it is not, the command uses the New-PSDrive cmdlet to create a Windows PowerShell drive that is mapped to the HKLM:\Network Registry key.

    ————————– EXAMPLE 5 ————————–

    C:\PS>Get-PSDrive -provider FileSystem

    C:\PS> Get-PSDrive -provider FileSystem

    Name     Provider     Root
    —-     ——–     —-
    C         FileSystem    C:\
    D         FileSystem    D:\
    X         FileSystem    X:\
    Y         FileSystem    \\Server01\Public
    Z         FileSystem    C:\Windows\System32

    C:\PS> net use
    New connections will be remembered.

    Status     Local     Remote                    Network
    ——————————————————————————-
                 X:        \\Server01\Public         Microsoft Windows Network

    C:\PS> [System.IO.DriveInfo]::getdrives()

    Name             : C:\
    DriveType         : Fixed
    DriveFormat        : NTFS
    IsReady            : True
    AvailableFreeSpace : 39831498752
    TotalFreeSpace     : 39831498752
    TotalSize         : 79900368896
    RootDirectory     : C:\
    VolumeLabel        :
    Name             : D:\
    DriveType         : CDRom
    DriveFormat        :
    IsReady            : False
    AvailableFreeSpace :
    TotalFreeSpace     :
    TotalSize         :
    RootDirectory     : D:\
    VolumeLabel        :
    Name             : X:\
    DriveType         : Network
    DriveFormat        : NTFS
    IsReady            : True
    AvailableFreeSpace : 36340559872
    TotalFreeSpace     : 36340559872
    TotalSize         : 36413280256
    RootDirectory     : X:\
    VolumeLabel        : D_Drive

    C:\PS> Get-WmiObject win32_logicaldisk

    DeviceID     : C:
    DriveType    : 3
    ProviderName :
    FreeSpace    : 39831252992
    Size         : 79900368896
    VolumeName :
    DeviceID     : D:
    DriveType    : 5
    ProviderName :
    FreeSpace    :
    Size         :
    VolumeName :
    DeviceID     : X:
    DriveType    : 4
    ProviderName : \\server01\public
    FreeSpace    : 36340559872
    Size         : 36413280256
    VolumeName : D_Drive

    C:\PS> Get-WmiObject win32_networkconnection
    LocalName                     RemoteName
    ————–             ————
    x:                            \\server01\public

    Description
    ———–
    This example compares the types of file system drives that are displayed by Get-PSDrive to those displayed by using other methods. This example demonstrates different ways to display drives in Windows PowerShell, and it shows that the drives created by using New-PSDrive are accessible only in Windows PowerShell.

    The first command uses Get-PSDrive to get all of the file system drives in the Windows PowerShell console. This includes the fixed drives (C: and D:), the mapped network drive (X:), and two Windows PowerShell drives (Y: and Z:) that were created by using New-PSDrive.

    A “net use” command, which displays Windows mapped network drives, displays only the X drive. It does not display drives that are created by New-PSDrive. It shows that the X: drive is also mapped to \\Server01\Public.

    The third command uses the GetDrives method of the Microsoft .NET Framework System.IO.DriveInfo class. This command gets the Windows file system drives, including drive X:, but it does not get the drives created by New-PSDrive.

    The fourth command uses the Get-WmiObject cmdlet to display the instances of the Win32_LogicalDisk class. It returns the C:, D:, and X: drives, but not the drives created by New-PSDrive.

    The last command uses the Get-WmiObject cmdlet to display the instances of the Win32_NetworkConnection class. Like “net use”, it returns only the X: drive.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113327
    about_providers
    New-PSDrive
    Remove-PSDrive
    Get-Help
    Get-Command
    Get-Member

Get-ExecutionPolicy

NAME
    Get-ExecutionPolicy

SYNOPSIS
    Gets the execution policies for the current session.

SYNTAX
    Get-ExecutionPolicy [[-Scope] {Process | CurrentUser | LocalMachine | UserPolicy | MachinePolicy}] [-List] [<CommonParameters>]

DESCRIPTION
    The Get-ExecutionPolicy cmdlet gets the execution policies for the current session.

    The execution policy is determined by execution policies that you set by using Set-ExecutionPolicy and the Group Policy settings for the Windows PowerShell execution policy. The default value is “Restricted.”

    Without parameters, Get-ExecutionPolicy gets the execution policy that is effective in the session. You can use the List parameter to get all execution policies that affect the session or the Scope parameter to get the execution policy for a particular scope.

    For more information, see about_execution_policies.

PARAMETERS
    -List [<SwitchParameter>]
        Gets all execution policy values for the session listed in precedence order. By default, Get-ExecutionPolicy gets only the effective execution policy.

        Required?                    false
        Position?                    named
        Default value                False
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Scope <ExecutionPolicyScope>
        Gets the execution policy in the specified scope. By default, Get-ExecutionPolicy gets the effective execution policy for the current session.

        Valid values are:

        — MachinePolicy: The execution policy set by a Group Policy for all users of the computer.
        — UserPolicy: The execution policy set by a Group Policy for the current user of the computer.
        — Process: The execution policy that is set for the current Windows PowerShell process.
        — CurrentUser: The execution policy that is set for the current user.
        — LocalMachine: The execution policy that is set for all users of the computer.

        Required?                    false
        Position?                    1
        Default value                Effective execution policy
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        You cannot pipe input to this cmdlet.

OUTPUTS
    Microsoft.PowerShell.ExecutionPolicy
        Get-ExecutionPolicy returns an object for each execution policy that it gets.

NOTES

        You cannot use Get-ExecutionPolicy to get particular execution policies set for a particular scope or to get the execution policy set by a Group Policy. Get-ExecutionPolicy only gets the effective execution policy that results from applying all precedence rules.

        The execution policy is part of the security strategy of Windows PowerShell. It determines whether you can load configuration files (including your Windows PowerShell profile) and run scripts, and it determines which scripts, if any, must be digitally signed before they will run.

        The effective execution policy is determined by the policies that you set by using Set-ExecutionPolicy and the “Turn on Script Execution” group policies for computers and users. The precedence order is Computer Group Policy > User Group Policy > Process (session) execution policy > User execution policy > Computer execution policy.

        For more information about Windows PowerShell execution policy, including definitions of the Windows PowerShell policies, see about_execution_policies.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Get-ExecutionPolicy

    Restricted

    Description
    ———–
    This command gets the current execution policy for the shell.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Set-ExecutionPolicy RemoteSigned; Get-ExecutionPolicy

    RemoteSigned

    Description
    ———–
    These commands set a new user preference for the shell execution policy and then display the effective execution policy. The commands are separated by a semicolon (;). In this example, because there is no Group Policy setting, the user preference is the effective policy for the shell.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Get-ExecutionPolicy -List

            Scope ExecutionPolicy
            —– —————
    MachinePolicy Undefined
     UserPolicy Undefined
         Process Undefined
     CurrentUser AllSigned
     LocalMachine RemoteSigned

    C:\PS> Get-ExecutionPolicy
    AllSigned

    Description
    ———–
    These commands get all execution policies in the current session and the effective execution policy.

    The first command gets all execution policies that affect the current session. The policies are listed in precedence order.

    The second command gets only the effective execution policy, which is the one set in the CurrentUser scope.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113315
    Set-ExecutionPolicy
    Get-AuthenticodeSignature
    Set-AuthenticodeSignature
    about_execution_policies
    about_Signing

Get-Alias

NAME
    Get-Alias

SYNOPSIS
    Gets the Aliases for the current session.

SYNTAX
    Get-Alias [[-Name] <string[]>] [-Exclude <string[]>] [-Scope <string>] [<CommonParameters>]

    Get-Alias [-Definition <string[]>] [-Exclude <string[]>] [-Scope <string>] [<CommonParameters>]

DESCRIPTION
    The Get-Alias cmdlet gets the Aliases (alternate names for commands and executable files) in the current session. This includes built-in Aliases, Aliases that you have set or imported, and Aliases that you have added to your Windows PowerShell profile.

    By default, Get-Alias takes an Alias and returns the command name. When you use the Definition parameter, Get-Alias takes a command name and returns its Aliases.

PARAMETERS
    -Definition <string[]>
        Gets the Aliases for the specified item. Enter the name of a cmdlet, Function, script, file, or executable file.

        This parameter is called Definition, because it searches for the item name in the Definition property of the Alias object.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? true

    -Exclude <string[]>
        Omits the specified items. The value of this parameter qualifies the Name and Definition parameters. Enter a name, a definition, or a pattern, such as “s*”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Name <string[]>
        Specifies the Aliases to retrieve. Wildcards are permitted. By default, Get-Alias retrieves all Aliases defined for the current session. The parameter name (“Name”) is optional. You can also pipe Alias names to Get-Alias.

        Required?                    false
        Position?                    1
        Default value
        Accept pipeline input?     true (ByValue, ByPropertyName)
        Accept wildcard characters? false

    -Scope <string>
        Gets only the Aliases in the specified scope. Valid values are “Global”, “Local”, or “Script”, or a number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent). “Local” is the default. For more information, see about_scopes.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    System.String
        You can pipe Alias names to Get-Alias.

OUTPUTS
    System.Management.Automation.AliasInfo
        Get-Alias returns an object that represents each Alias.

NOTES

        An Alias is an alternate name or nickname for a cmdlet, Function, or an executable file. To run the cmdlet, Function, or executable, you can use its full name or any Alias. For more information, see about_aliases.

        To create a new Alias, use Set-Alias or New-Alias. To delete an Alias, use Remove-Item.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Get-Alias

    Description
    ———–
    This command gets all Aliases in the current session.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Get-Alias -Name g*, s* -Exclude get-*

    Description
    ———–
    This command gets all Aliases that begin with “g” or “s”, except for Aliases that begin with “get-“.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Get-Alias -definition Get-ChildItem

    Description
    ———–
    This command gets the Aliases for the Get-ChildItem cmdlet.

    By default, the Get-Alias cmdlet gets the item name when you know the Alias. The Definition parameter gets the Alias when you know the item name.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Get-Alias | Where-Object {$_.Options -match “ReadOnly”}

    Description
    ———–
    This command retrieves all Aliases in which the value of the Options property is ReadOnly. This command provides a quick way to find the Aliases that are built into Windows PowerShell, because they have the ReadOnly option.

    Options is just one property of the AliasInfo objects that Get-Alias gets. To find all properties and methods of AliasInfo objects, type “Get-Alias | Get-Member“.

    ————————– EXAMPLE 5 ————————–

    C:\PS>Get-Alias -definition “*-pssession” -Exclude e* -Scope global

    Description
    ———–
    This example gets Aliases for commands that have names that end in “-pssession”, except for those that begin with “e”.

    The command uses the Scope parameter to apply the command in the global scope. This is useful in scripts when you want to get the Aliases in the session.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113306
    about_aliases
    Set-Alias
    New-Alias
    Export-Alias
    Import-Alias
    Alias Provider

Export-Alias

NAME
    Export-Alias

SYNOPSIS
    Exports information about currently defined Aliases to a file.

SYNTAX
    Export-Alias [-Path] <string> [[-Name] <string[]>] [-Append] [-As {Csv | Script}] [-Description <string>] [-Force] [-NoClobber] [-PassThru] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Export-Alias cmdlet exports the Aliases in the current session to a file. If the output file does not exist, the cmdlet will create it.

    Export-Alias can export the Aliases in a particular scope or all scopes, it can generate the data in CSV format or as a series of Set-Alias commands that you can add to a session or to a Windows PowerShell profile.

PARAMETERS
    -Append [<SwitchParameter>]
        Appends the output to the specified file, rather than overwriting the existing contents of that file.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -As <ExportAliasFormat>
        Determines the output format. CSV is the default.

        Valid values are:

        — CSV: Comma-separated value (CSV) format.
        — Script: Creates a Set-Alias command for each exported Alias. If you name the output file with a .ps1 file name extension, you can run it as a script to add the Aliases to any session.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Description <string>
        Adds a description to the exported file. The description appears as a comment at the top of the file, following the header information.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Force [<SwitchParameter>]
        Overwrites the output file, even if the read-only attribute is set on the file.

        By default, Export-Alias overwrites files without warning, unless the read-only or hidden attribute is set or the NoClobber parameter is used in the command. The NoClobber parameter takes precedence over the Force parameter when both are used in a command.

        The Force parameter cannot force Export-Alias to overwrite files with the hidden attribute.

        Required?                    false
        Position?                    named
        Default value                Does not overwrite read-only files.
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Name <string[]>
        Specifies the names of the Aliases to export. Wildcards are permitted.

        By default, Export-Alias exports all Aliases in the session or scope.

        Required?                    false
        Position?                    2
        Default value                Export all Aliases
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -NoClobber [<SwitchParameter>]
        Prevents Export-Alias from overwriting any files, even if the Force parameter is used in the command.

        If the NoClobber parameter is omitted, Export-Alias will overwrite an existing file without warning, unless the read-only attribute is set on the file. NoClobber takes precedence over the Force parameter, which permits Export-Alias to overwrite a file with the read-only attribute.

        NoClobber does not prevent the Append parameter from adding content to an existing file.

        Required?                    false
        Position?                    named
        Default value                Overwrites read-write files.
        Accept pipeline input?     false
        Accept wildcard characters? false

    -PassThru [<SwitchParameter>]
        Returns objects that represent the Aliases that were exported. By default, this cmdlet does not generate any output.

        Required?                    false
        Position?                    named
        Default value                No output
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Path <string>
        Specifies the path to the output file. Wildcards are permitted, but the resulting path value must resolve to a single file name. This parameter is required.

        Required?                    true
        Position?                    1
        Default value                None
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Scope <string>
        Specifies the scope from which the Aliases should be exported.

        Valid values are “Global”, “Local”, or “Script”, or a number relative to the current scope (0 through the number of scopes where 0 is the current scope and 1 is its parent). “Local” is the default. For more information, see about_scopes.

        Required?                    false
        Position?                    named
        Default value                Local
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None.
        You cannot pipe objects to this cmdlet.

OUTPUTS
    None or System.Management.Automation.AliasInfo
        When you use the Passthru parameter, Export-Alias returns a System.Management.Automation.AliasInfo object that represents the Alias. Otherwise, this cmdlet does not generate any output.

NOTES

        You can only Export-Aliases to a file.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Export-Alias -Path Alias.csv

    Description
    ———–
    This command exports current Alias information to a file named Alias.csv in the current directory.

    ————————– EXAMPLE 2 ————————–

    C:\PS>Export-Alias -Path Alias.csv -NoClobber

    Description
    ———–
    This command exports the Aliases in the current session to an Alias.csv file.

    Because the NoClobber parameter is specified, the command will fail if an Alias.csv file already exists in the current directory.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Export-Alias -Path Alias.csv -Append -Description “Appended Aliases” -Force

    Description
    ———–
    This command appends the Aliases in the current session to the Alias.csv file.

    The command uses the Description parameter to add a description to the comments at the top of the file.

    The command also uses the Force parameter to overwrite any existing Alias.csv files, even if they have the read-only attribute.

    ————————– EXAMPLE 4 ————————–

    C:\PS>Export-Alias -Path Alias.ps1 -As script

    C:\PS> Add-Content -Path $profile -value (Get-Content Alias.ps1)

    C:\PS> $s = New-PSSession -computername Server01
    C:\PS> Invoke-Command -session $s -filepath .\alias.ps1

    Description
    ———–
    This example shows how to use the script file format that Export-Alias generates.

    The first command exports the Aliases in the session to the Alias.ps1 file. It uses the As parameter with a value of Script to generate a file that contains a Set-Alias command for each Alias.

    The second command adds the Aliases in the Alias.ps1 file to the CurrentUser-CurrentHost profile. (The path to the profile is saved in the $profile Variable.) The command uses the Get-Content cmdlet to get the Aliases from the Alias.ps1 file and the Add-Content cmdlet to add them to the profile. For more information, see about_profiles.

    The third and fourth commands add the Aliases in the Alias.ps1 file to a remote session on the Server01 computer. The third command uses the New-PSSession cmdlet to create the session. The fourth command uses the FilePath parameter of the Invoke-Command cmdlet to run the Alias.ps1 file in the new session.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113296
    Import-Alias
    Get-Alias
    New-Alias
    Set-Alias

Clear-Variable

NAME
    Clear-Variable

SYNOPSIS
    Deletes the value of a Variable.

SYNTAX
    Clear-Variable [-Name] <string[]> [-Exclude <string[]>] [-Force] [-Include <string[]>] [-PassThru] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

DESCRIPTION
    The Clear-Variable cmdlet deletes the data stored in a Variable, but it does not delete the Variable. As a result, the value of the Variable is NULL (empty). If the Variable has a specified data or object type, Clear-Variable preserves the type of the object stored in the Variable.

PARAMETERS
    -Exclude <string[]>
        Omits the specified items. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Force [<SwitchParameter>]
        Allows the cmdlet to clear a Variable even if it is read-only. Even using the Force parameter, the cmdlet cannot clear constants.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Include <string[]>
        Clears only the specified items. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as “s*”. Wildcards are permitted.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Name <string[]>
        Specifies the name of the Variable to be cleared. Wildcards are permitted. This parameter is required, but the parameter name (“Name”) is optional.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?     true (ByPropertyName)
        Accept wildcard characters? false

    -PassThru [<SwitchParameter>]
        Returns an object representing the cleared Variable. By default, this cmdlet does not generate any output.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Scope <string>
        Specifies the scope in which this Alias is valid. Valid values are “Global”, “Local”, or “Script”, or a number relative to the current scope (0 through the number of scopes, where 0 is the current scope and 1 is its parent). “Local” is the default. For more information, see about_scopes.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -Confirm [<SwitchParameter>]
        Prompts you for confirmation before executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    -WhatIf [<SwitchParameter>]
        Describes what would happen if you executed the command without actually executing the command.

        Required?                    false
        Position?                    named
        Default value
        Accept pipeline input?     false
        Accept wildcard characters? false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer and OutVariable. For more information, type,
        “Get-Help about_CommonParameters“.

INPUTS
    None
        You cannot pipe objects to Clear-Variable.

OUTPUTS
    None or System.Management.Automation.PSVariable
        When you use the PassThru parameter, Clear-Variable generates a System.Management.Automation.PSVariable object representing the cleared Variable. Otherwise, this cmdlet does not generate any output.

NOTES

        To delete a Variable, along with its value, use Remove-Variable or Remove-Item.

        Clear-Variable will not delete the values of Variables that are set as constants or owned by the system, even if you use the -Force parameter.

        If the Variable that you are clearing does not exist, the cmdlet has no effect. It does not create a Variable with a null value.

        You can also refer to Clear-Variable by its built-in Alias, “clv”. For more information, see about_aliases.

    ————————– EXAMPLE 1 ————————–

    C:\PS>Clear-Variable my* -global

    Description
    ———–
    This command deletes the value of the global Variables that begin with “my”.

    ————————– EXAMPLE 2 ————————–

    C:\PS>$a=3

    C:\PS>&{ Clear-Variable a }

    C:\PS>$a
    3

    Description
    ———–
    These commands demonstrate that clearing a Variable in a child scope does not clear the value in the parent scope. The first command sets the value of the Variable $a to “3”. The second command uses the invoke operator (&) to run a Clear-Variable command in a new scope. The Variable is cleared in the child scope (although it did not exist), but it is not cleared in the local scope. The third command, which gets the value of $a, shows that the value “3” is unaffected.

    ————————– EXAMPLE 3 ————————–

    C:\PS>Clear-Variable -Name processes

    Description
    ———–
    This command deletes the value of the $processes Variable. The $processes Variable still exists, but the value is null.

RELATED LINKS
    Online version: http://go.microsoft.com/fwlink/?LinkID=113285
    Get-Variable
    Set-Variable
    New-Variable
    Remove-Variable