Skip to content

Instantly share code, notes, and snippets.

@mgreenegit
Last active August 29, 2015 14:18
Show Gist options
  • Save mgreenegit/ff64f4b470e30dad3271 to your computer and use it in GitHub Desktop.
Save mgreenegit/ff64f4b470e30dad3271 to your computer and use it in GitHub Desktop.
Script to stub-in a new DSC module
$modules = 'C:\Program Files\WindowsPowerShell\Modules\'
$modulename = 'xName'
$Description = 'Some Text'
if (!(test-path (join-path $modules $modulename))) {
$modulefolder = mkdir (join-path $modules $modulename)
New-ModuleManifest -Path (join-path $modulefolder "$modulename.psd1") -Guid $([system.guid]::newguid().guid) -Author 'Author' -CompanyName 'Company Name' -Copyright '2015' -ModuleVersion '0.1.0.0' -Description $Description -PowerShellVersion '4.0'
$standard = @{ModuleName = $modulename
ClassVersion = '0.1.0.0'
Path = $modules
}
$P = @()
$P += New-xDscResourceProperty -Name NAME -Type String -Attribute Key -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type Boolean -Attribute Required -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type Hashtable -Attribute Write -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type PSCredential -Attribute Write -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type DateTime -Attribute Write -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type Uint32 -Attribute Read -Description 'Some Text'
New-xDscResource -Name MSFT_xResourceName -Property $P -FriendlyName xResourceName @standard
$P = @()
$P += New-xDscResourceProperty -Name NAME -Type String -Attribute Key -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type Boolean -Attribute Required -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type Hashtable -Attribute Write -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type PSCredential -Attribute Write -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type DateTime -Attribute Write -Description 'Some Text'
$P += New-xDscResourceProperty -Name OTHER -Type Uint32 -Attribute Read -Description 'Some Text'
New-xDscResource -Name MSFT_xResourceName2 -Property $P -FriendlyName xResourceName2 @standard
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment