I have been using GitHub - PowerShellOrg/DSC: DSC Tools and Documentation on the current Development Branch (due to the cool features)
I currently have 3 configs. Test, Server, Workstation.
To the most part they are the same as far as the config file goes but use diferent DSC_Configuration folders
Here is an example of the configuration file.
Configuration ServerConfig
{
$script:DependsOn = $null
Import-DscResource -ModuleName StackExchangeResources,
xComputerManagement,
xHyper-V,
cSMBShare,
PowerShellAccessControl,
PDSResorces
node $AllNodes.NodeName
{
Write-Warning "Current Node: $($node.name) GUID: $($node.NodeName)"
#region ### User Conifguration ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName LocalUserSettings)
{
$Users = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName LocalUserSettings\User -MultipleResultBehavior AllValues
)
foreach ($User in $Users)
{
User $User['UserName']
{
UserName = $User['UserName']
FullName = $User['FullName']
Description = $User['Description']
Disabled = $User['Disabled']
Password = if ($User['CredName']) {$ConfigurationData.Credentials.($User['CredName'])} else {$null}
PasswordChangeNotAllowed = $User['PasswordChangeNotAllowed']
PasswordChangeRequired = $User['PasswordChangeRequired']
PasswordNeverExpires = $User['PasswordNeverExpires']
DependsOn = $User['DependsOn']
Ensure = $User['Ensure']
}
}
}#endregion
#region ### Group Conifguration ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName LocalGroupSettings)
{
$Groups = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName LocalGroupSettings\Group -MultipleResultBehavior AllValues
)
foreach ($Group in $Groups)
{
group $Group['GroupName']
{
GroupName = $Group['GroupName']
Description = $Group['Description']
Members = $Group['Members']
MembersToInclude = $Group['MembersToInclude']
MembersToExclude = $Group['MembersToExclude']
DependsOn = $Group['DependsOn']
Credential = if ($Group['CredName']) {$ConfigurationData.Credentials.($Group['CredName'])} else {$null}
Ensure = $Group['Ensure']
}
}
} #endregion
#region ### Windows Features ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName WindowsFeatureSettings)
{
$Features = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName WindowsFeatureSettings\WindowsFeature -MultipleResultBehavior AllValues
)
foreach ($Feature in $Features)
{
WindowsFeature $Feature['Name']
{
Name = $Feature['Name']
Credential = if ($Feature['CredName']) {$ConfigurationData.Credentials.($Feature['CredName'])} else {$null}
DependsOn = $Feature['DependsOn']
Ensure = $Feature['Ensure']
IncludeAllSubFeature = $Feature['IncludeAllSubFeature']
LogPath = $Feature['LogPath']
Source = if($Feature['SourceRef']){
(Resolve-DscConfigurationProperty -Node $node -PropertyName $Feature['SourceRef'])
}
elseif ($Feature['Source']){
($Feature['Source'])}
else{$null}
}
}
} #endregion
#region ### File ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName FileSettings)
{
$Files = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName FileSettings\File -MultipleResultBehavior AllValues
)
foreach ($File in $Files)
{
if ($File['Attributes'] -and $File['Checksum']) {
File $File['Name']
{
DestinationPath = $File['DestinationPath']
Attributes = $File['Attributes']
Checksum = $File['Checksum']
Contents = if($File['Contents']){(Resolve-DscConfigurationProperty -Node $node -PropertyName $File['Contents'] )} else {$null }
Credential = if ($File['CredName']) {$ConfigurationData.Credentials.($File['CredName'])} else {$null}
DependsOn = $File['DependsOn']
Ensure = $File['Ensure']
Force = $File['Force']
MatchSource = $File['MatchSource']
Recurse = $File['Recurse']
SourcePath = $File['SourcePath']
Type = if ($File['Type']) {$File['Type'] } else {'file' }
}
}
elseif ($File['Checksum']) {
File $File['Name']
{
DestinationPath = $File['DestinationPath']
#Attributes = $File['Attributes']
Checksum = $File['Checksum']
Contents = if($File['Contents']){(Resolve-DscConfigurationProperty -Node $node -PropertyName $File['Contents'] )} else {$null }
Credential = if ($File['CredName']) {$ConfigurationData.Credentials.($File['CredName'])} else {$null}
DependsOn = $File['DependsOn']
Ensure = $File['Ensure']
Force = $File['Force']
MatchSource = $File['MatchSource']
Recurse = $File['Recurse']
SourcePath = $File['SourcePath']
Type = if ($File['Type']) {$File['Type'] } else {'file' }
}
}
elseif ($File['Attributes']) {
File $File['Name']
{
DestinationPath = $File['DestinationPath']
Attributes = $File['Attributes']
#Checksum = $File['Checksum']
Contents = if($File['Contents']){(Resolve-DscConfigurationProperty -Node $node -PropertyName $File['Contents'] )} else {$null }
Credential = if ($File['CredName']) {$ConfigurationData.Credentials.($File['CredName'])} else {$null}
DependsOn = $File['DependsOn']
Ensure = $File['Ensure']
Force = $File['Force']
MatchSource = $File['MatchSource']
Recurse = $File['Recurse']
SourcePath = $File['SourcePath']
Type = if ($File['Type']) {$File['Type'] } else {'file' }
}
}
else {
File $File['Name']
{
DestinationPath = $File['DestinationPath']
#Attributes = $File['Attributes']
#Checksum = $File['Checksum']
Contents = if($File['Contents']){(Resolve-DscConfigurationProperty -Node $node -PropertyName $File['Contents'] )} else {$null }
Credential = if ($File['CredName']) {$ConfigurationData.Credentials.($File['CredName'])} else {$null}
DependsOn = $File['DependsOn']
Ensure = $File['Ensure']
Force = $File['Force']
MatchSource = $File['MatchSource']
Recurse = $File['Recurse']
SourcePath = $File['SourcePath']
Type = if ($File['Type']) {$File['Type'] } else {'file' }
}
}
}
} #endregion
#region ### Hyper-V Settings ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName HypervSettings\vmSwitch)
{
#region ### Hyper-v Virtual Switch ###
$Switchs = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName HypervSettings\vmSwitch -MultipleResultBehavior AllValues
)
foreach ($Switch in $Switchs)
{
xVMSwitch $Switch['Name']
{
Name = $Switch['Name']
Type = $Switch['Type']
AllowManagementOS = $Switch['AllowManagementOS']
DependsOn = $Switch['DependsOn']
Ensure = $Switch['Ensure']
NetAdapterName = $Switch['NetAdapterName']
}
} #endregion
}
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName HypervSettings\VHDX)
{
#region ### VHDX Creation ###
$VHDs = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName HypervSettings\VHDX -MultipleResultBehavior AllValues
)
foreach ($VHD in $VHDs)
{
xVHD $VHD['Name']
{
Name = $VHD['Name']
Path = $VHD['Path']
DependsOn = $VHD['DependsOn']
Ensure = $VHD['Ensure']
Generation = $VHD['Generation']
MaximumSizeBytes = $VHD['MaximumSizeBytes']
ParentPath = $VHD['ParentPath']
}
} #endregion
}
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName HypervSettings\VirtualMachine)
{
#region ### VM Creation ###
$VirtualMachine = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName HypervSettings\VirtualMachine -MultipleResultBehavior AllValues
)
foreach ($VM in $VirtualMachine)
{
xVMHyperV $VM['Name']
{
Name = $VM['Name']
VhdPath = $VM['VhdPath']
DependsOn = $VM['DependsOn']
Ensure = $VM['Ensure']
Generation = $VM['Generation']
MACAddress = $VM['MACAddress']
MaximumMemory = $VM['MaximumMemory']
MinimumMemory = $VM['MinimumMemory']
Path = $VM['Path']
ProcessorCount = $VM['ProcessorCount']
RestartIfNeeded = $VM['RestartIfNeeded']
StartupMemory = $VM['StartupMemory']
State = $VM['State']
SwitchName = $VM['SwitchName']
WaitForIP = $VM['WaitForIP']
}
} #endregion
}
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName HypervSettings\VMDvdDrive)
{
#region ### Attach ISO ###
$VMDvdDrive = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName HypervSettings\VMDvdDrive -MultipleResultBehavior AllValues
)
foreach ($DVD in $VMDvdDrive)
{
cVMDvdDrive $DVD['Name']
{
ISOPath = $DVD['ISOPath']
VMName = $DVD['VMName']
DependsOn = $DVD['DependsOn']
Ensure = $DVD['Ensure']
}
} #endregion
}
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName HypervSettings\VMHardDiskDrive)
{
#region ### Attach VHD ###
$VMHardDiskDrive = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName HypervSettings\VMHardDiskDrive -MultipleResultBehavior AllValues
)
foreach ($VHD in $VMHardDiskDrive)
{
cVMHardDiskDrive $VHD['Name']
{
VHDPath = $VHD['VHDPath']
VMName = $VHD['VMName']
DependsOn = $VHD['DependsOn']
Ensure = $VHD['Ensure']
}
} #endregion
} #endregion
#region ### Install Packages ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName InstallPackages)
{
$Packages = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName InstallPackages\Package -MultipleResultBehavior AllValues
)
foreach ($Package in $Packages)
{
Package $Package['Name']
{
Name = $Package['Name']
Path = $Package['Path']
ProductId = $Package['ProductId']
Arguments = $Package['Arguments']
Credential = if ($Package['CredName']) {$ConfigurationData.Credentials.($Package['CredName'])} else {$null}
DependsOn = $Package['DependsOn']
Ensure = $Package['Ensure']
LogPath = $Package['LogPath']
ReturnCode = $Package['ReturnCode']
}
}
} #endregion
#region ### Access Control Entry (Permission) ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName AccessControlEntry)
{
$Aces = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName AccessControlEntry\Ace -MultipleResultBehavior AllValues
)
foreach ($Ace in $Aces)
{
if ($Ace['AceType'] -eq 'SystemAudit') {
cAccessControlEntry $ACE['Name']
{
AceType = $Ace['AceType']
ObjectType = $Ace['ObjectType']
Path = $Ace['Path']
Principal = $Ace['Principal']
AccessMask = $Ace['AccessMask']
AppliesTo = $Ace['AppliesTo']
AuditFailure = $Ace['AuditFailure']
AuditSuccess = $Ace['AuditSuccess']
DependsOn = $Ace['DependsOn']
Ensure = $Ace['Ensure']
OnlyApplyToThisContainer = $Ace['OnlyApplyToThisContainer']
}
}
elseif ($Ace['Specific'])
{
cAccessControlEntry $ACE['Name']
{
AceType = $Ace['AceType']
ObjectType = $Ace['ObjectType']
Path = $Ace['Path']
Principal = $Ace['Principal']
AccessMask = $Ace['AccessMask']
AppliesTo = $Ace['AppliesTo']
DependsOn = $Ace['DependsOn']
Ensure = $Ace['Ensure']
OnlyApplyToThisContainer = $Ace['OnlyApplyToThisContainer']
Specific = $Ace['Specific']
}
}
else
{
cAccessControlEntry $ACE['Name']
{
AceType = $Ace['AceType']
ObjectType = $Ace['ObjectType']
Path = $Ace['Path']
Principal = $Ace['Principal']
AccessMask = $Ace['AccessMask']
AppliesTo = $Ace['AppliesTo']
DependsOn = $Ace['DependsOn']
Ensure = $Ace['Ensure']
OnlyApplyToThisContainer = $Ace['OnlyApplyToThisContainer']
}
}
}
} #endregion
#region ### SMB Share ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName SmbShareSettings)
{
$SmbShares = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName SmbShareSettings\SmbShare -MultipleResultBehavior AllValues
)
foreach ($SmbShare in $SmbShares)
{
if ($SmbShare['FolderEnumerationMode'])
{
cSmbShare $SmbShare['Name']
{
Name = $SmbShare['Name']
Path = $SmbShare['Path']
ChangeAccess = $SmbShare['ChangeAccess']
ConcurrentUserLimit = $SmbShare['ConcurrentUserLimit']
DependsOn = $SmbShare['DependsOn']
Description = $SmbShare['Description']
EncryptData = $SmbShare['EncryptData']
Ensure = $SmbShare['Ensure']
FolderEnumerationMode = $SmbShare['FolderEnumerationMode']
FullAccess = $SmbShare['FullAccess']
NoAccess = $SmbShare['NoAccess']
ReadAccess = $SmbShare['ReadAccess']
}
}
else
{
cSmbShare $SmbShare['Name']
{
Name = $SmbShare['Name']
Path = $SmbShare['Path']
ChangeAccess = $SmbShare['ChangeAccess']
ConcurrentUserLimit = $SmbShare['ConcurrentUserLimit']
DependsOn = $SmbShare['DependsOn']
Description = $SmbShare['Description']
EncryptData = $SmbShare['EncryptData']
Ensure = $SmbShare['Ensure']
FullAccess = $SmbShare['FullAccess']
NoAccess = $SmbShare['NoAccess']
ReadAccess = $SmbShare['ReadAccess']
}
}
}
} #endregion
#region ### Service Settings ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName ServiceSettings)
{
$Services = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName ServiceSettings\Service -MultipleResultBehavior AllValues
)
foreach ($Service in $Services)
{
if ($Service['BuiltInAccount']) {
Service $Service['Name']
{
Name = $Service['Name']
BuiltInAccount = $Service['BuiltInAccount']
DependsOn = $Service['DependsOn']
StartupType = $Service['StartupType']
State = $Service['State']
}
}
else {
Service $Service['Name']
{
Name = $Service['Name']
Credential = if ($Service['CredName']) {$ConfigurationData.Credentials.($Service['CredName'])} else {$null}
DependsOn = $Service['DependsOn']
StartupType = $Service['StartupType']
State = $Service['State']
}
}
}
} #endregion
#region ### Registry Settings ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName RegistrySettings)
{
$RegistrySettings = @(
Resolve-DscConfigurationProperty -Node $Node -PropertyName RegistrySettings\Registry -MultipleResultBehavior AllValues
)
foreach ($Registry in $RegistrySettings)
{
if ($Registry.ValueType)
{
Registry $Registry['Name']
{
Key = $Registry['Key']
ValueName = $Registry['ValueName']
DependsOn = $Registry['DependsOn']
Ensure = $Registry['Ensure']
Force = $Registry['Force']
Hex = $Registry['Hex']
ValueData = $Registry['ValueData']
ValueType = $Registry['ValueType']
}
}
else
{
Registry $Registry['Name']
{
Key = $Registry['Key']
ValueName = $Registry['ValueName']
DependsOn = $Registry['DependsOn']
Ensure = $Registry['Ensure']
Force = $Registry['Force']
Hex = $Registry['Hex']
ValueData = $Registry['ValueData']
}
}
}
} #endregion
#region ### Time Zone ###
if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName TimeZone)
{
Timezone TZone
{
Name = (Resolve-DscConfigurationProperty -Node $Node -PropertyName TimeZone)
}
}#endregion
#region ### Phisical Servers ###
if ($node.ServerType -eq 'Phsycal')
{
Package 'OMSA'
{
Name = 'OMSA'
Path = '\\itfiles\DSC$\MSI\OMSA_74x64\SysMgmtx64.msi'
ProductId = 'D21351E1-B98E-4F49-94C1-9E0BE31BA4A4'
DependsOn = '[xComputer]NewName'
Ensure = 'Present'
LogPath = 'C:\Programdata\Logs\OMSA.log'
}
}#endregion
#region ### All OnDomain Servers ###
if (-not ($node.OffDomain))
{
xComputer NewName
{
Name = $Node.Name
DomainName = 'domain.com'
Credential = (New-Object System.Management.Automation.PSCredential -ArgumentList 'domain\DomainJoiner',$ConfigurationData.Credentials.DomainJoiner.Password)
}
} #endregion
#region BranchHost File Copy Script
If (Test-DscConfigurationPropertyExists -Node $Node -PropertyName BranchHostFileCopyScript)
{
script BranchServerBootDrive
{
SetScript = {
if (-not (Test-Path -Path 'E:\Hyper-V\Virtual Hard Disks\BranchServer_Boot.vhdx' -ErrorAction SilentlyContinue))
{
copy-item -Path 'E:\Hyper-V\Virtual Hard Disks\2012R2u1_Std.vhdx' -Destination 'E:\Hyper-V\Virtual Hard Disks\BranchServer_Boot.vhdx'
}
}
TestScript = {
Test-Path -Path 'E:\Hyper-V\Virtual Hard Disks\BranchServer_Boot.vhdx' -ErrorAction SilentlyContinue
}
GetScript = {
$Ensure = (Test-Path -Path 'E:\Hyper-V\Virtual Hard Disks\BranchServer_Boot.vhdx' -ErrorAction SilentlyContinue)
$output = @{Ensure = $Ensure
Path = 'E:\Hyper-V\Virtual Hard Disks\BranchServer_Boot.vhdx'}
$output
}
DependsOn = '[file]VMImage'
}
cVhdFileInjection CopyBranchServerGUID
{
VhdPath = 'E:\Hyper-V\Virtual Hard Disks\BranchServer_Boot.vhdx'
FileDirectory = PDS_cFileDirectory {
SourcePath = 'E:\Hyper-V\BranchServerGUID'
DestinationPath = 'DSCtemp\GUID'
}
DependsOn = '[File]BranchServerGUIDFile','[script]BranchServerBootDrive'
# VolumeNumber = 1
}
} #endregion
LocalConfigurationManager
{
CertificateId = (Resolve-DscConfigurationProperty -Node $node -PropertyName 'CertificateID')
AllowModuleOverwrite = (Resolve-DscConfigurationProperty -Node $node -PropertyName 'AllowModuleOverwrite')
ConfigurationID = $Node.NodeName
ConfigurationModeFrequencyMins = (Resolve-DscConfigurationProperty -Node $node -PropertyName 'ConfigurationModeFrequencyMins')
ConfigurationMode = (Resolve-DscConfigurationProperty -Node $node -PropertyName 'ConfigurationMode')
RebootNodeIfNeeded = (Resolve-DscConfigurationProperty -Node $node -PropertyName 'RebootNodeIfNeeded')
RefreshMode = (Resolve-DscConfigurationProperty -Node $node -PropertyName 'RefreshMode')
DownloadManagerName = (Resolve-DscConfigurationProperty -Node $node -PropertyName 'DownloadManagerName')
DownloadManagerCustomData = (Resolve-DscConfigurationProperty -Node $node -PropertyName 'DownloadManagerCustomData')
}
}
}
In the AllNodes under DSC_Configuration
AllNodes.psd1
@{
NodeName = '*'
PSDscAllowPlainTextPssword=$false
CertificateID = '0F7E02A2AD4D7D6808F70F33FC09EF6D52F1BA55'
AllowModuleOverwrite = 'True'
ConfigurationModeFrequencyMins = 30
ConfigurationMode = 'ApplyAndAutoCorrect'
RebootNodeIfNeeded = 'True'
RefreshMode = 'PULL'
DownloadManagerName = 'WebDownloadManager'
DownloadManagerCustomData = (@{ServerUrl = 'https://DSC-Pull.domain.com:8443/psdscpullserver.svc'})
WIMSource = 'wim:\\itfiles\DSC$\WIM\install.wim:4'
}
Hyper-vServerBranch1.psd1
@{
Name = 'BranchServer1-HV'
Location = 'Branch1'
MachineType = 'Phisical'
NodeName = 'a5583c86-bddf-4c22-82a6-e1a50b2c519c'
BranchServerGUID = 'e754ea9d-b01d-4489-a612-6265c6b466dc'
}
BranchServer1.psd1
@{
Name = 'BranchServer1'
Location = 'Branch1
MachineType = 'VM'
NodeName = 'e754ea9d-b01d-4489-a612-6265c6b466dc'
AccessControlEntry = @{
Ace = @(
@{
Name = 'AllBranchUsersModifyShares'
AceType = 'AccessAllowed'
ObjectType = 'Directory'
Path = 'E:\Shares'
Principal = 'Domain\All-Branch1Users'
AccessMask = [System.Security.AccessControl.FileSystemRights] 'Modify'
DependsOn = '[File]AppFolder', '[xComputer]NewName'
Ensure = 'Present'
}
)
}
}
in the DSC_Configuration\Services folder
BranchHypserVHost.psd1
@{
#region Node List
Nodes = 'Branch1-HV'
#endregion
BranchHostFileCopyScript = $true
InstallPackages = @{
Package = @(
@{
Name = 'OMSA'
Path = "\\itfiles\DSC$\MSI\OMSA_74x64\SysMgmtx64.msi"
ProductId = 'D21351E1-B98E-4F49-94C1-9E0BE31BA4A4'
DependsOn = '[xComputer]NewName'
Ensure = 'Present'
}
)
}
WindowsFeatureSettings = @{
WindowsFeature = @(
@{
Ensure = 'Present'
Name = 'Hyper-V'
}
)
}
FileSettings = @{
File = @(
@{
Name = 'winISO'
Ensure = 'Present'
SourcePath = '\\itfiles\DSC$\ISO\Win_Svr_2012_R2_64Bit_English.ISO'
DestinationPath = 'E:\ISO\Win_Svr_2012_R2_64Bit_English.ISO'
Checksum = 'SHA-256'
Force = $true
DependsOn = '[xComputer]NewName'
Type = 'file'
}
@{
Name = 'VMImage'
Ensure = 'Present'
SourcePath = '\\itfiles\DSC$\VHD\2012R2u1_Std.vhdx'
DestinationPath = 'E:\Hyper-V\Virtual Hard Disks\2012R2u1_Std.vhdx'
Checksum = 'SHA-256'
Force = $true
DependsOn = '[xComputer]NewName'
Type = 'file'
}
@{
Name = 'BranchServerGUIDFile'
Ensure = 'Present'
DestinationPath = 'E:\Hyper-V\BranchServerGUID'
Contents = 'BranchServerGUID'
DependsOn = '[xComputer]NewName'
Type = 'file'
}
)
}
HypervSettings = @{
vmSwitch = @(
@{
Ensure = 'present'
Name = 'VM'
Type = 'External'
NetAdapterName = 'Ethernet 2'
AllowManagementOS = $true
DependsOn = '[WindowsFeature]Hyper-V'
}
)
VirtualMachine = @(
@{
Ensure = 'Present'
Name = 'BranchServer'
SwitchName = 'VM'
vhdPath = 'E:\Hyper-V\Virtual Hard Disks\BranchServer_Boot.vhdx'
State = 'Running'
Path = 'E:\Hyper-V'
Generation = 'VHDX'
StartupMemory = 1GB
MaximumMemory = 1GB
MinimumMemory = 1GB
ProcessorCount = 2
RestartIfNeeded = $true
DependsOn = '[script]BranchServerBootDrive', '[xVMSwitch]VM', '[WindowsFeature]Hyper-V', '[cVhdFileInjection]CopyBranchServerGUID'
}
)
VHDX = @(
@{
Ensure = 'Present'
Name = 'BranchServer_Data.vhdx'
Path = 'E:\Hyper-V\Virtual Hard Disks'
MaximumSizeBytes = 127GB
Generation = 'VHDX'
}
)
VMHardDiskDrive = @(
@{
Name = 'BranchServerDataDrive'
Ensure = 'Present'
VMName = 'BranchServer'
VHDPath = 'E:\Hyper-V\Virtual Hard Disks\BranchServer_Data.vhdx'
DependsOn = '[xVMHyperV]BranchServer'
}
)
VMDvdDrive = @(
@{
Name = 'BranchServerWinDVD'
Ensure = 'Present'
VMName = 'BranchServer'
ISOPath = 'E:\ISO\Win_Svr_2012_R2_64Bit_English.ISO'
DependsOn = '[xVMHyperV]BranchServer'
}
)
}
}
BranchServerVM.psd1
@{
#region Node List
Nodes = 'BranchServer1'
#endregion
WindowsFeatureSettings = @{
WindowsFeature = @(
@{
Ensure = 'Present'
Name = 'Server-Gui-Shell'
DependsOn = '[xComputer]NewName'
SourceRef = 'WIMSource'
}
@{
Ensure = 'Present'
Name = 'Server-Gui-Mgmt-Infra'
DependsOn = '[xComputer]NewName'
SourceRef = 'WIMSource'
}
@{
Ensure = 'Present'
Name = 'File-Services'
}
@{
Ensure = 'Present'
Name = 'FS-Data-Deduplication'
}
@{
Ensure = 'Present'
Name = 'FS-DFS-Namespace'
}
@{
Ensure = 'Present'
Name = 'FS-DFS-Replication'
}
@{
Ensure = 'Present'
Name = 'FS-Resource-Manager'
}
@{
Ensure = 'Present'
Name = 'Print-Server'
}
)
}
SmbShareSettings = @{
SmbShare = @(
@{
Name = 'Apps'
Path = 'E:\Shares\Apps'
Description = 'Branch Application Share'
Ensure = 'Present'
DependsOn = '[File]AppFolder'
FullAccess = 'Everyone'
}
@{
Name = 'User$'
Path = 'E:\Shares\User'
Description = 'Branch User Share'
Ensure = 'Present'
DependsOn = '[File]UserFolder'
FullAccess = 'Everyone'
}
@{
Name = 'Share'
Path = 'E:\Shares\Share'
Description = 'Branch Group Share'
Ensure = 'Present'
DependsOn = '[File]ShareFolder'
FullAccess = 'Everyone'
}
)
}
FileSettings = @{
File = @(
@{
Name = 'AppFolder'
Ensure = 'Present'
DestinationPath = 'E:\Shares\Apps'
Type = 'Directory'
}
@{
Name = 'UserFolder'
Ensure = 'Present'
DestinationPath = 'E:\Shares\User'
Type = 'Directory'
}
@{
Name = 'ShareFolder'
Ensure = 'Present'
DestinationPath = 'E:\Shares\Share'
Type = 'Directory'
}
)
}
}
The VM image is a Core2012R1 install that has been sysprep with some files in the C:\DSCTemp that are run automatically to install the password decryption certificate key (sysprep removes all cert keys) look for the GUID file and start DSC for the VM.
I have something similar in an ESXi template for the VMWare hosts so we add the GUID when deploying the template and it builds the system from scratch.
Using "if (Test-DscConfigurationPropertyExists -Node $Node -PropertyName … " has some advantages but when it does limit more advanced logic. I have to work around the special cases as is obvious with the OMSA install I’m doing on only Physical hosts.
We are still in our infancy and don’t deploy the data into the file shares for replacement servers yet. but this is an example of what can be done.