pluralsight / PS-AutoLab-Env

A PowerShell module for creating lab configurations using Lability and Desired State Configuration. Look at README.md for more information.
MIT License
269 stars 74 forks source link

Get-NetNat is not working #260

Closed edbg closed 2 years ago

edbg commented 2 years ago

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

jdhitsolutions commented 2 years ago

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 2 years ago

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.

jdhitsolutions commented 2 years ago

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

jdhitsolutions commented 2 years ago

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

jdhitsolutions commented 2 years ago

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 2 years ago

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

jdhitsolutions commented 2 years ago

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.

jdhitsolutions commented 2 years ago

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 2 years ago

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

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

jdhitsolutions commented 2 years ago

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

edbg commented 2 years ago

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.