Public/Remove-PsModule.ps1
function Remove-PsModule { <# .Synopsis Removes a powershell module from the user's module folder .DESCRIPTION Using plaster and pester for proper scaffolding this function creates a couple of files and folders: Data/ Internal/ Public/ Tests/ Module.psd1 Module.psm1 readme.md .EXAMPLE Remove-PsModule AwesomePowershellModule Remove-PsModule AwesomePowershellModule "C:\modules\path" Remove-PsModule AwesomePowershellModule "C:\modules\path" "Module description..." Remove-PsModule AwesomePowershellModule "C:\modules\path" "Module description..." "0.0.1" Remove-PsModule AwesomePowershellModule "C:\modules\path" "Module description..." "0.0.1" "Author Name" #> [CmdletBinding(SupportsShouldProcess=$true)] param ( [Parameter(Mandatory=$true, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [string]$ModuleName, [string]$ModulePath="" ) BEGIN{ $here = $PSscriptRoot . "$here\Get-PsModuleBuilderPath.ps1" if((!$ModulePath) -or !(Test-Path $ModulePath -PathType Container)) { $ModulePath = Get-PsModuleBuilderPath } $whatifMessage = @" Removing the following: - $ModulePath\$ModuleName\ - $ModulePath\$ModuleName\Internal\ - $ModulePath\$ModuleName\Public\ - $ModulePath\$ModuleName\Test\ - $ModulePath\$ModuleName\Data\ - $ModulePath\$ModuleName\Data\plasterManifest.xml - $ModulePath\$ModuleName\$ModuleName.psd1 - $ModulePath\$ModuleName\$ModuleName.psm1 - $ModulePath\$ModuleName\readme.md "@ }#begin PROCESS{ if ($psCmdlet.ShouldProcess("$ModulePath\$ModuleName", $whatifMessage)) { Write-Debug $whatifMessage Remove-Item "$ModulePath\$ModuleName" -Recurse -Force } }#process END{}#end } |