Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Last active June 10, 2018 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techthoughts2/2824d28c95633a6c095a7c6831ffd2f1 to your computer and use it in GitHub Desktop.
Save techthoughts2/2824d28c95633a6c095a7c6831ffd2f1 to your computer and use it in GitHub Desktop.
Example of pushing MOFs to different servers using a CIMSession to apply DSC.
#-------------------------------------------------------
#specify test device details and load up credentials
$s1 = "SERVER1"
$creds = Get-Credential -Message "Enter Credentials"
#-------------------------------------------------------
#create remote CIM session with the appropriate options for your environment
$sop = New-CimSessionOption –UseSSL -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$cim = New-CimSession -ComputerName $s1 -Credential $creds -SessionOption $sop
#-------------------------------------------------------
#push the configuration
Start-DSCConfiguration -CimSession $cim -Path C:\DSC\Test -Wait -Verbose -Force
#*******************************************************
#-------------------------------------------------------
#establish new session to second server and repeat process
$s2 = "SERVER2"
#-------------------------------------------------------
#create remote CIM session with the appropriate options for your environment
$cim = New-CimSession -ComputerName $s2 -Credential $creds -SessionOption $sop
#-------------------------------------------------------
#push the configuration
Start-DSCConfiguration -CimSession $cim -Path C:\DSC\Test -Wait -Verbose -Force
#-------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment