transcript at /tmp/2021-01-08-12-28-21-powershell.log PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -6. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $a Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -18. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $ad Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -18. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $ada Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -18. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $adap Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -18. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $adapt Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -18. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $adapte Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -18. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $adapter Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -18. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.AcceptLineImpl(Boolean validate) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $adapter >> Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -19. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c) at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> # Wi-Fi, Ethernet 2, Ethernet 3, VirtualBox Host-Only Network >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv6') >> } >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $adapter >> } Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: Space Space Space Space Space Space Space Space $ a d a p t e r _ w i t h _ i p Space = Space $ i p _ a d a p t e r _ m a p [ $ I p V 6 A d d r e s s ] Enter Space Space Space Space } Enter Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r _ w i t h _ i p Enter Enter Space Space Space Space $ a d a p t e r Space = Space R e s t a r t - N e t A d a p t e r Space - N a m e Space $ a d a p t e r _ w i t h _ i p . N a m e Space - P a s s T h r u Enter Space Space Space Space W r i t e - O u t p u t Space $ a d a p t e r Enter } Enter Enter Exception: System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension. Parameter name: top Actual value was -19. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor) at Microsoft.PowerShell.PSConsoleReadLine.ForceRender() at Microsoft.PowerShell.PSConsoleReadLine.AcceptLineImpl(Boolean validate) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- PS C:\home\ccarl\src\snippets> function Restart-NetworkAdapterByIpAddress { >> <# >> >> #> >> [CmdletBinding()] >> param ( >> [Parameter()][string]$IpV4Address=$null, >> [Parameter()][string]$IpV6Address=$null >> ) >> if (($IpV4Address -eq $null) -and ($IpV6Address -eq $null)) { >> throw "Please provide either an ip address v4 or v6!" >> } >> >> $adapters = Get-NetAdapter | Where-Object {$_.Status -ne 'Disconnected'} >> $adapter_map = @{} >> foreach($adapter in $adapters) { >> $adapter_map[$adapter.Name] = $adapter >> } >> >> >> $ip_adapter_map = @{} >> $ips = Get-NetIPAddress | Where-Object {$adapter_map.ContainsKey($_.InterfaceAlias) -eq $true} >> if (($IpV4Address -ne $null) -and ($IpV6Address -ne $null)) { >> $ips = $ips | Where-Object {($_.AddressFamily -eq 'IPv4') -and ($_.AddressFamily -eq 'IPv6')} >> } elseif ($IpV4Address -ne $null) { >> $ips = $ips | Where-Object ($_.AddressFamily -eq 'IPv4') >> } else { >> foreach($ip in $ips) { >> $ip_adapter_map[$ip.IpAddress] = $adapter_map[$ip.InterfaceAlias] >> } >> >> if ($IpV4Address -ne $null) { >> $adapter_with_ip = $ip_adapter_map[$IpV4Address] >> } else { >> $adapter_with_ip = $ip_adapter_map[$IpV6Address] >> } >> >> Write-Output $adapter_with_ip >> >> $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassThru >> Write-Output $adapter >> } PS C:\home\ccarl\src\snippets> ^C PS C:\home\ccarl\src\snippets> Import-Module -Name powershell\network-adapters.ps1 Import-Module : The specified module 'powershell\network-adapters.ps1' was not loaded because no valid module file was found in any module directory. At line:1 char:1 + Import-Module -Name powershell\network-adapters.ps1 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (powershell\network-adapters.ps1:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand PS C:\home\ccarl\src\snippets> Import-Module -Name .\powershell\network-adapters.psm1 PS C:\home\ccarl\src\snippets> Restart-NetworkAdapterByIpAddress -IpV4Address 10.251.156.38 Restart-NetAdapter : Cannot validate argument on parameter 'Name'. The argument is null. Provide a valid value for the argument, and then try running the command again. At C:\home\ccarl\src\snippets\powershell\network-adapters.psm1:44 char:41 + $adapter = Restart-NetAdapter -Name $adapter_with_ip.Name -PassTh ... + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Restart-NetAdapter], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Restart-NetAdapter Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- VirtualBox Host-Only N... VirtualBox Host-Only Ethernet Adapter 14 Up 0A-00-27-00-00-0E 1 Gbps PS C:\home\ccarl\src\snippets>