Monday, December 19, 2016

Windows PowerShell Equivalents: Networking Commands (PING)

Looking for PowerShell equivalents for older console network commands such as PING. The PING command is used for checking connectivity and to measure network latency between two devices.

PowerShell: Test-NetConnection

Examples:
Test-NetConnection www.example.com
Test-NetConnection -ComputerName www.example.com -InformationLevel Detailed
Test-NetConnection -ComputerName www.example.com | Select-Object -ExpandProperty PingReplyDetails | Format-Table Address, Status, RoundTripTime

Monday, December 12, 2016

Advanced Tip: Finding and Uninstalling a HotFix From PowerShell

Warning: Use this trick at your own risk, uninstalling the wrong hot fixes on your system can cause problems.

There are several ways to find the hotfixes from the GUI tools on your system, such as the Windows Update GUI.  I generally like to use PowerShell only tricks, but this one is a hybrid. It uses a utility called WUSA to uninstall the hotfix.

To uninstall a hotfix on your system, you need to know its KB number.  You can use this technique to test if it exists and then uninstall it. All you have to do is change the KB number in the $A variable.

$a="11111111";$b="KB"+$a;$c=Get-HotFix|Where-Object HotFixID -eq $b;if(![string]::IsNullOrEmpty($c)){wusa /uninstall /kb:$a}

Tuesday, December 06, 2016

Windows PowerShell Equivalents: Networking Commands (IPCONFIG)

Looking for PowerShell equivalents for older console network commands such as IPCONFIG. The IPCONFIG command is used for displaying IP address information (including the subnet mask, and gateway) for the local NIC adapter attached to the computer.

PowerShell: Get-NetIPConfiguration or Get-NetIPAddress

Examples:

  • Get-NetIPConfiguration
  • Get-NetIPAddress | Sort-Object InterfaceIndex | Format-Table InterfaceIndex,InterfaceAlias,AddressFamily,IPAddress,PrefixLength -Autosize
  • Get-NetIPAddress | Where-Object AddressFamily -eq IPv6 | Format-Table –AutoSize