A simple script to create Windows PowerShell Module structure

As part of creating Windows PowerShell modules, I have recently created a script to create the structure required, as follows:


[CmdletBinding()]
Param (
[String]
$ModuleName = "TestModule",
[String]
$Author = "",
[String]
[ValidateScript({Get-Item $_ })]
$Path = "C:\Sandbox\PowerShell\Modules"
)
New-Item ($Path + "\" + $ModuleName + "\" + $ModuleName) -Type Directory | Out-Null
New-Item ($Path + "\" + $ModuleName + "\" + $ModuleName + "\Private") -Type Directory | Out-Null
New-Item ($Path + "\" + $ModuleName + "\" + $ModuleName + "\Public") -Type Directory | Out-Null
New-Item ($Path + "\" + $ModuleName + "\" + $ModuleName + "\en-US") -Type Directory | Out-Null
New-Item ($Path + "\" + $ModuleName + "\" + $ModuleName + "\lib") -Type Directory | Out-Null
New-Item ($Path + "\" + $ModuleName + "\" + $ModuleName + "\bin") -Type Directory | Out-Null
New-Item ($Path + "\" + $ModuleName + "\Tests") -Type Directory | Out-Null
New-Item ($Path + "\" + $ModuleName + "\" + $ModuleName + "\" + $ModuleName + ".psm1") -Type File | Out-Null
New-Item ($Path + "\" + $ModuleName + "\" + $ModuleName + "\" + $ModuleName + ".Format.ps1.xml") -Type File | Out-Null
New-Item ($Path + "\" + $ModuleName + "\" + $ModuleName + "\en-US\about_$ModuleName.help.txt") -Type File | Out-Null
New-Item ($Path + "\" + $ModuleName + "\Tests\" + $ModuleName + ".Tests.ps1") -Type File | Out-Null

This will create the following items in the specified path:

CreateModuleStructure


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 )

Facebook photo

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

Connecting to %s