How to run a Powershell DSC script locally How to run a Powershell DSC script locally powershell powershell

How to run a Powershell DSC script locally


Try:

configuration SampleIISInstall    {        Node "localhost"        {          File FileDemo {            Type = 'Directory'            DestinationPath = 'C:\TestUser3'            Ensure = "Present"        }        }    }    # Compile the configuration file to a MOF format    SampleIISInstall    # Run the configuration on localhost    Start-DscConfiguration -Path .\SampleIISInstall -Wait -Force -Verbose


Since DSC Uses PowerShell remoting you can't use IP addresses for the nodename you have to specify a computer name. Using localhost or $env:computername should work you could also remove the node block completely and just write the DSC config without it.

 configuration SampleIISInstall    {          File FileDemo {            Type = 'Directory'            DestinationPath = 'C:\TestUser3'            Ensure = "Present"        }        }    # Compile the configuration file to a MOF format    SampleIISInstall    # Run the configuration on localhost    Start-DscConfiguration -Path .\SampleIISInstall -Wait -Force -Verbose