Author Posts

May 28, 2014 at 9:34 am

Hello,

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
}
}
CreateVHD

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.

May 28, 2014 at 9:39 am

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.

May 28, 2014 at 9:53 am

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.

May 28, 2014 at 10:06 am

Can you run

Enter-PSSession localhost

Successfully?

May 28, 2014 at 10:11 am

No, I get almost the same error.

May 28, 2014 at 10:25 am

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?

May 28, 2014 at 10:36 am

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 : 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.

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!

May 28, 2014 at 10:41 am

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

May 28, 2014 at 10:41 am

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.

May 28, 2014 at 10:43 am

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.

May 28, 2014 at 10:47 am

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!

May 28, 2014 at 10:51 am

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.

December 15, 2016 at 9:43 pm

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

Thanks.

December 15, 2016 at 9:52 pm

Ah you meant to add it to "Enable-PSRemoting". Thank you.

March 9, 2018 at 3:47 am

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)}