Skip to content

Instantly share code, notes, and snippets.

@jamesallen-cm
Last active August 29, 2015 14:23
Show Gist options
  • Save jamesallen-cm/49f016aeebee41c71846 to your computer and use it in GitHub Desktop.
Save jamesallen-cm/49f016aeebee41c71846 to your computer and use it in GitHub Desktop.
Applies the LCMNode Configuration and walks through mof creation using guid identifiers
# Computer list - Be sure to change the computer name to your server
$ComputerName='WIN-UO9GH1EJ9J7'
$cred = Get-Credential "$ComputerName\administrator"
$cimsession = New-CimSession -Credential $cred -ComputerName $ComputerName
# Send to computers LCM
Set-DSCLocalConfigurationManager -ComputerName $ComputerName -Credential $cred -Path c:\DSC\HTTP –Verbose
Get-DSCLocalConfigurationManager -CimSession $cimsession
# Create configureation for clients
ise "C:\DSCDemo\Config_SMTP.ps1"
# Rename config with GUID and Checksum
# Get the guid, is already assigned
$guid=Get-DscLocalConfigurationManager -CimSession $cimsession | Select-Object -ExpandProperty ConfigurationID
# Specify source folder of configuration
$source = "C:\DSC\HTTP\HTTPSComputers.mof"
# Destination should be the pull location on the web server
# for the demonstration just copy the files manually to the C:\Program Files\WindowsPowerShell\DscService\Configuration
$dest = "C:\DSC\HTTP\$guid.mof"
Copy-Item -Path $source -Destination $dest
Explorer "C:\DSC\HTTP\"
#Then on Pull server make checksum
New-DSCChecksum $dest
# Test - ONLY IF TIME
Get-WindowsFeature -ComputerName $ComputerName -name *SMTP* #Shouldn't be installed yet.
Update-DscConfiguration -ComputerName $ComputerName -Wait -Verbose #Check to see if it installs
Get-WindowsFeature -ComputerName $ComputerName -name *SMTP* #Should be installed
Test-DscConfiguration -CimSession $ComputerName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment