pluralsight/PS-AutoLab-Env

Get-NetNat is not working

Closed this issue · 11 comments

edbg commented

When running Get-NetNat
I get the following
Get-NetNat : Invalid class
At line:1 char:1

  • Get-NetNat
  •   + CategoryInfo          : MetadataError: (MSFT_NetNat:root/StandardCimv2/MSFT_NetNat) [Get-NetNat], CimException
      + FullyQualifiedErrorId : HRESULT 0x80041010,Get-NetNat
    

You are going to have to provide some context. Did you install the module successfully? If so, run Get-PSAutolabSetting and post the result.

edbg commented

Yes I was able to install the module and I get the following when I run Get-PSAutoLabSetting:
AutoLab : C:\Lability
PSVersion : 5.1.19041.1320
PSEdition : Desktop
OS : Microsoft Windows 10 Pro
FreeSpaceGB : 414.76
MemoryGB : 48
PctFreeMemory : 85.32
Processor : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
IsElevated : True
RemotingEnabled : False
NetConnectionProfile : unknown
HyperV :
PSAutolab : 4.21.0
Lability : 0.20.0
Pester : {5.3.1, 4.10.1}
PowerShellGet : 1.0.0.1
PSDesiredStateConfiguration : 1.1

WARNING: The network connection profile for LabNet is not set to Private or DomainAuthenticated. Commands that rely on
PowerShell remoting may fail.

It looks like this is networking-related. Can you run Get-NetConnectionProfile and post the result? Did you run Setup-Host ?

You also need to have PowerShell remoting enabled. Take a look at the detailed setup instructions at https://github.com/pluralsight/PS-AutoLab-Env/blob/master/Detailed-Setup-Instructions.md

I'm pretty sure Get-NetNat will fail until there is a NAT setting configured which you won't get until you run Setup-Host.

edbg commented

I did run Setup-Host and looked at the Details-Setup and get the following now:
Get-PSAutoLabSetting

AutoLab : C:\Autolab
PSVersion : 5.1.19041.1320
PSEdition : Desktop
OS : Microsoft Windows 10 Pro
FreeSpaceGB : 389.4
MemoryGB : 48
PctFreeMemory : 87.37
Processor : Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
IsElevated : True
RemotingEnabled : True
NetConnectionProfile : unknown
HyperV : 10.0.19041.1
PSAutolab : 4.21.0
Lability : 0.20.0
Pester : {5.3.1, 4.10.1}
PowerShellGet : 1.0.0.1
PSDesiredStateConfiguration : 1.1

WARNING: The network connection profile for LabNet is not set to Private or DomainAuthenticated. Commands that rely on
PowerShell remoting may fail.

and this:
Get-NetConnectionProfile

Name : FiOS_3_5
InterfaceAlias : Wi-Fi
InterfaceIndex : 8
NetworkCategory : Public
IPv4Connectivity : Internet
IPv6Connectivity : Internet

Get-NetNat LabNat
Get-NetNat : No MSFT_NetNat objects found with property 'Name' equal to 'LabNat'. Verify the value of the property
and retry.
At line:1 char:1

  • Get-NetNat LabNat
  •   + CategoryInfo          : ObjectNotFound: (LabNat:String) [Get-NetNat], CimJobException
      + FullyQualifiedErrorId : CmdletizationQuery_NotFound_Name,Get-NetNat
    
    
    

Remoting won't work over a public interface. There are ways around that. But since you've already run Setup-Host, I need to figure out how to work around where you are now.

I've been using this module for so long that I take things for granted. Setup-Host configures remoting to skip checking for public connections. You don't get a NAT until you set up a lab and run Enable-Internet manually or Unattend-lab. Running Get-NetNat is jumping the gun because you haven't set anything up yet. Build lab and then Get-NetNat will work.

edbg commented

ran Enable-Internet and got the following:
Enable-Internet

    This is the Enable-Internet script. This script will perform the following:

    * Enable Internet to the VM's using NAT

    * Note! - If this generates an error, you are already enabled, or one of the default settings below
    does not match your .PSD1 configuration

Get-NetAdapter : No MSFT_NetAdapter objects found with property 'Name' equal to 'vethernet ()'. Verify the value of
the property and retry.
At C:\Program Files\WindowsPowerShell\Modules\PSAutoLab\4.21.0\functions\public.ps1:712 char:14

  • ... $Index = Get-NetAdapter -Name "vethernet ($LabSwitchName)" | Selec ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (vethernet ():String) [Get-NetAdapter], CimJobException
    • FullyQualifiedErrorId : CmdletizationQuery_NotFound_Name,Get-NetAdapter

New-NetIPAddress : Cannot bind argument to parameter 'IPAddress' because it is an empty string.
At C:\Program Files\WindowsPowerShell\Modules\PSAutoLab\4.21.0\functions\public.ps1:715 char:60

  • ... New-NetIPAddress -InterfaceIndex $Index -IPAddress $GatewayIP -Prefix ...
  •                                                    ~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [New-NetIPAddress], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,New-NetIPAddress

New-NetNat : Cannot bind argument to parameter 'Name' because it is an empty string.
At C:\Program Files\WindowsPowerShell\Modules\PSAutoLab\4.21.0\functions\public.ps1:720 char:26

  •     New-NetNat -Name $NatName -InternalIPInterfaceAddressPrefix $ ...
    
  •                      ~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [New-NetNat], ParameterBindingValidationException

    • FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,New-NetNat

      Next Steps:

      When complete, run:
      Run-Lab

      And run:
      Validate-Lab

You have to run a lab setup to create the Hyper-V network. You can't run Enable-Internet by itself.

edbg commented

I think I am all good now. I appreciate your help. I spun up a test windows 10 Lab, the machine was built, and I was also able to Enable-Ethernet. I could not RDP into the device, but I think that is because of the setting on the Windows 10 device.