PowerShell Function: Reset-Module

    ##--------------------------------------------------------------------------
    ##  FUNCTION.......:  Reset-Module
    ##  PURPOSE........:  Removes and then imports the specified PowerShell 
    ##                    Module.
    ##  REQUIREMENTS...:  The Module must be registered with the shell.
    ##  NOTES..........:  
    ##--------------------------------------------------------------------------
    Function Reset-Module {
        <#
        .SYNOPSIS
         Removes and then re-imports the specified PowerShell Module.
         For examples type:
         Help Reset-Module -examples
        .DESCRIPTION
         Removes and then re-imports the specified PowerShell Module.
        .PARAMETER ModuleName
         The Name of the Module to reload.
        .EXAMPLE
         C:\PS>Reload-Module TroubleshootingPack

         This example will reload the TroubleshootingPack module. This example
         will produce no visible output.

        .EXAMPLE
         C:\PS>Reload-Module TroubleshootingPack -verbose

         This example does the same thing as Example 1, but will also write 
         verbose output to the console.

        .NOTES
         NAME......:  Reset-Module
         AUTHOR....:  Joe Glessner
         LAST EDIT.:  19MAY11
         CREATED...:  19MAY11
        .LINK
         about_Modules
         https://joeit.wordpress.com/
        #>
        [CmdletBinding()]             
            Param (                        
                [Parameter(Mandatory=$True, 
                    #ValueFromPipeline=$True,
                    #ValueFromPipelineByPropertyName=$True,
                    Position=0)]  
                [String]$ModuleName
                )#End Param
        Write-Verbose "Removing Module $ModuleName"
        Remove-Module $ModuleName
        Start-Sleep -s 1
        Write-Verbose "Importing Module $ModuleName"
        Import-Module $ModuleName
    }#END: Module Reset-Module

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: