DCS connection error


I’m trying to create a VHD with xvhd on my local computer. I’ve written the configuration and created the mof.

Configuration CreateVHD { Import-DscResource -module xHyper-V
    xvhd NewVHD
        Name = "TestVHD1"
        Path = "C:\Lab\VHD"
        Ensure = "Present"
        Generation = "vhdx"
        MaximumSizeBytes = 40GB


However, when I push it with Start-DscConfiguration, I always get this error:

The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". + CategoryInfo : ConnectionError: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : HRESULT 0x80338012 + PSComputerName : localhost

I don’t get how the heck is my computer unable to connect to itself. I’ve even run Enable-PSRemoting and as far as I know, LCM should run automatically. All the modules are copied to ‘C:\Program Files\WindowsPowerShell\Modules’ and Hyper-V is running too.

Your configuration does not contain a NODE section?

DSC doesn’t use Remoting per se; it uses WS-MAN and WinRM, which are distinct technologies. If Enter-PSSession works, then DSC should be able to connect. However, what was the name of the MOF file that you produced? What was the exact Start-DscConfiguration command you ran? Normally, a configuration includes a NODE section, which identifies the machines being targeted.

I tried with the Node section now:

Configuration CreateVHD { Import-DscResource -module xHyper-V Node localhost { xvhd NewVHD { Name = "TestVM1" Path = "C:\lab\VHD" Ensure = "Present" Generation = "vhdx" MaximumSizeBytes = 40GB } } } CreateVHD

I run Start-DscConfiguration .\CreateVHD -wait, but I still get the same error.

Can you run

Enter-PSSession localhost


No, I get almost the same error.

Then you need to troubleshoot that, apart from DSC.

When you run Enable-PSRemoting, you get no errors? Are you an Administrator on the computer? Is PowerShell being run as Administrator?

I see. I’ll keep tracking it down. I’m an admin and I run PS as admin. When I run Enable-PSRemoting I get this:

WinRM is already set up to receive requests on this computer. Set-WSManQuickConfig : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859113" Machine="localhost"><f:Message><f:ProviderFault provider="Config provider" path="%systemroot%\system32\WsmSvc.dll"><f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2150859113" Machine="igep"><f:Message>WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Change the network connection type to either Domain or Private and try again. </f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault> At line:69 char:17 + Set-WSManQuickConfig -force + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Set-WSManQuickConfig], InvalidOperationException + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand

Thank you so far, I’ll keep on trying!

Add -SkipNetworkProfileCheck. That error’s common, and well-documented. It means you have a network adapter set to “Public,” usually a VM adapter.

Although be aware that, if you have a Public adapter, Windows Firewall will still block traffic on that adapter - so make sure it isn’t the one you’re actually trying to connect to.

I am pretty certain I had this same problem when I was trying to run a Configuration from ISE (which wasn’t running as Administrator, it was running as a privileged account). Running the console or ISE as Administrator fixed the issue.

If that’s not it, what version is the desktop OS you are trying to run this on? I took this section from the DSC e-Book:
On Windows 8.1 and Windows Server 2012 R2, make certain that KB2883200 is installed or DSC will not work. On Windows Server 2008 R2, Windows 7, and Windows Server 2008, be sure to install the full Microsoft .NET Framework 4.5 package prior to installing WMF 4.0 or DSC may not work correctly.

Thank you, it solved the problem!
I also added localhost to the wsman trusted host list, but that didn’t help.
Also, after Start-DscConfiguration I had to supply an absolute path, the relative path didn’t work.
Thank you lot again!

Relative paths will work if they’re correct; you may have been in a different folder without realizing it. And TrustedHosts has nothing to do with it; you were being blocked by Windows Firewall. Glad it’s working now.

Don where do we “Add -SkipNetworkProfileCheck”? I tried adding it to the “Start-DscConfiguration” cmdlet but it wasn’t recognized.


Ah you meant to add it to “Enable-PSRemoting”. Thank you.

You can set your network adapters to private scriptomagically:

$networkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}")) 
$connections = $networkListManager.GetNetworkConnections() 

# Set network location to Private for all networks 
$connections | %{$_.GetNetwork().SetCategory(1)}