Im trying to run:
netsh lan show interfaces | findstr /i "GUID" > test.txt
set /p ethguid=<test.txt
echo %ethguid:~23%> test2.txt
set /p ethguidclean=<test2.txt
echo %ethguidclean%
powershell.exe -Command " Rename-Item "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{%ethguidclean%}" -NewName "11111111-1111-1111-1111-111111111111" "
pause
but i fails with error:
Rename-Item : A positional parameter cannot be found that accepts argument '8b384d18-7877-44ea-9b48-5f634a0ff1f6'.
At line:1 char:2
+ Rename-Item HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Rename-Item], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RenameItemCommand
and if I run command directly in powershell it works! what am I doing wrong?
"s you're not passing a single command string, but a strange sequence of strings.Get-NetAdapter | Where-Object { ($_.AdminStatus -Eq 'Up' -And $_.MediaConnectState -Eq 1) -And $_.NdisPhysicalMedium -Eq 14 } | Select-Object -ExpandProperty InterfaceGuid. Now as you're already using PowerShell for the registry change, you already have the subkey string you need!$(Get-NetAdapter | ? { ($_.AdminStatus -Eq 'Up' -And $_.MediaConnectState -Eq 1) -And $_.NdisPhysicalMedium -Eq 14 }).InterfaceGuiddirectly...