NetAdapter command gives 'The data is invalid' message - powershell

I am trying to rename the Ethernet adapter after creating a VLAN in my script. It currently just creates a new Ethernet x as an adapter.
From what I can find online Get-NetAdapter should display all network adapters and Rename-NetAdapter should work, however I keep getting the following error:
Kind regards,
Tom

Related

I'm trying to connect two computers with unity NetCode but don't successes

I'm trying to create a multiplayer game with Unity NetCode and I'm doing well but, when I'm connecting from anther computer I'm aren't successes.
the computers are connect to the same network but one with Wi-Fi and anther with Ethernet cable, from the same computer it does working
I think the U Net Transport have something to do with it
does any body have any idea why I'm failing?
first you need to check if the computers answer to ping, by default windows doesn't allow answer to ping.
Tutorial - https://youtu.be/1BGdvSyAADw
In the network u net transform there is a connection ip, make sure that connectio ip is right. by default the connection ip is pointing to your own computer.

Enable VLAN and set VLAN ID with powershell script if VLAN is not yet enabled

I'm right now trying to write a powershell script in Windows 11, that should automatically configure an usb to ethernet adapter. For this I need to automatically configure the VLAN of the adapter.
Everything works fine in case the VLAN was already activated in the network dialog using
Set-NetAdapter -Name Adapter -VlanID 999
In case the network adapter is not yet configured the script fails with:
Set-NetAdapter : Requested operation not supported on adapter
The screenshot shows on how to disable VLAN on the adapter.
Does anyone knows how to enable VLAN with powershell in the first place prior to setting the VLAN ID?
Try running the following command:
Get-NetAdapterAdvancedProperty
If you test with this you should be able to tell what property needs to be set e.g.
Set-NetAdapterAdvancedProperty -DisplayName "Jumbo*" -DisplayValue "4088 Bytes"

Getting error while executing DHCP power shell command

I need to read vendor specification data from DHCP server options.
I have connected an android mobile to my PC, enabled the tethering and exposed the DHCP server IP: 192.168.42.129 as shown in the image.
As per MSDN site this is the syntax:
(Get-DhcpServerv4OptionValue -ComputerName "dhcpserver.contoso.com")
for getting DHCP options through power shell. I tried the same but get the error.
Did I miss anything?

Powershell - Strange issue with script when searching for Ethernet Adapter

I'm not even sure if this is a programming issue or something strange in Windows
I am creating a script in PowerShell 4.0 to automate the setting up of a Windows 6in4 tunnel.
The script is working successfully on my machine however when someone else using the same version tries it, the script fails for them.
The sticking point appears to be here
# First Locate Which device is the Ethernet Adapter
$wiredAdapter = Get-NetAdapter | Where-Object {$_.PhysicalMediaType -eq '802.3'}
This line is supposed to get the adapter properties of the Ethernet adapter (On both mine and the other individuals system there is only one)
On my system if I run the line and then output the results I get the following
PS C:\Users\Timothy> $wiredAdapter
Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
---- -------------------- ------- ------ ---------- ---------
Ethernet Qualcomm Atheros AR8131 PCI-E Gigabi... 3 Up xx-xx-xx-3B-22-78 100 Mbps
However when he tries copying the line directly he gets no output.
Can anyone suggest what's going wrong here?
Thanks in advance.
On my system Get-NetAdapter returns as I'd expect
The same as $ Wired above
PS C:\Users\Timothy> Get-NetAdapter
Name InterfaceDescription ifIndex Status MacAddress LinkSpeed
---- -------------------- ------- ------ ---------- ---------
WiFi 3 Atheros AR5007UG Wireless Network Ad... 13 Disconnected 00-1D-0F-B1-82-B9 0 bps
Ethernet Qualcomm Atheros AR8131 PCI-E Gigabi... 3 Up F4-6D-04-3B-22-78 100 Mbps
If I then do (Get-NetAdapter).PhysicalMediaType I get the following
PS C:\Users\Timothy> (Get-NetAdapter).PhysicalMediaType
Native 802.11
802.3
I chose PhysicalMediaType as I was getting strange results off the media type for the Wireless Adapters.
PS C:\Users\Timothy> (Get-NetAdapter).MediaType
802.3
802.3
Still can't figure out why I get this result.
Thanks guys - the problem is that the other system returns different values for the Ethernet card. What's annoying is that the card is the same model as mine
Native 802.11
Unspecified
Unspecified
Unspecified
Unspecified
Unspecified
Unspecified
I did come across the following page using the Get-WMIObject.
http://gallery.technet.microsoft.com/scriptcenter/PowerShell-Script-to-889c9505
However using that my wireless adapters were enumerated as wired adapters :(

How to find which IP address is active for communication?

I am using Windows XP Sp3. We are having both wired network and wireless network.
Both will have different IP address range .
Is there any way to find which IP address/Gateway is used to communicate?
i.e. We are having permission to wired network IP range to rdp to our lab machines. But with wireless connection we can't.
Often people forget that and asking me.
If the wireless network is active channel , then it should either try to connect through wired network or it should intimate them. How to achieve this using powershell?
You can get the same information route print shows like this:
Get-WmiObject -Class Win32_IP4RouteTable | select Destination, Mask, NextHop, Metric1
If your network address is 10.0.0.0 you can get the NextHop IP like this:
Get-WmiObject -Class Win32_IP4RouteTable | ? {$_.Destination -eq "10.0.0.0"} | select NextHop
As I understand you should manually add routes to lab machines for wired interface. And you could detemine current route settings with command:
route print
running from windows console (cmd )
Guess this links could be also helpfull to you:
Configure default gateway
Usage route command
Adding static IP route