i wanna change mtu with powershell script and the value in this txt file
- what’s wrong in this code ?
$GMTU = Get-Content C:\MTU2.txt
$AdapterName = $(Get-NetAdapter | Where { $_.Name -Match 'Ethernet'}).Name
netsh interface ipv4 set subinterface "$AdapterName" mtu=$GMTU store=persistent
>Solution :
It looks like there’s a trailing space after the last digit. You can use string.Trim() to remove leading or trailing whitespace:
$GMTU = (Get-Content C:\MTU2.txt -TotalCount 1).Trim()
