software:microsoft:windows:powershell
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| software:microsoft:windows:powershell [2020/07/28 16:53] – superwizard | software:microsoft:windows:powershell [2023/09/30 16:32] (current) – [Change Network Location to Public or Private with PowerShell] superwizard | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== PowerShell Commands ====== | ====== PowerShell Commands ====== | ||
| + | |||
| + | ====== Change Network Location to Public or Private with PowerShell ====== | ||
| + | |||
| + | |||
| + | <WRAP center round box > | ||
| + | |||
| + | 2023-09-30 | ||
| + | |||
| + | |||
| + | On Windows 10/11 and Windows Server 2022/ | ||
| + | |||
| + | |||
| + | |||
| + | To change the network for the network adapter with index 8 to Private, run the command: | ||
| + | | ||
| + | Check that the network profile has changed: | ||
| + | | ||
| + | |||
| + | From < | ||
| + | |||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | ====== Backup SQL ====== | ||
| + | |||
| <WRAP center round box > | <WRAP center round box > | ||
| Line 9: | Line 36: | ||
| Get-NetworkStatistics | Format-Table > c: | Get-NetworkStatistics | Format-Table > c: | ||
| + | | ||
| + | Get-NetworkStatistics - netstat -bano with filtering | ||
| + | This code borrows from Shay Levy's Get-NetworkStatistics function | ||
| + | |||
| + | From < | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | ====== 10 PowerShell cmdlets to speed network troubleshooting ====== | ||
| + | |||
| + | <WRAP center round box > | ||
| + | |||
| + | |||
| + | From < | ||
| + | |||
| + | 1. Ping devices locally or remotely | ||
| + | Test-NetConnection -ComputerName " | ||
| + | |||
| + | the command as typed above and the computer will essentially perform a ping to determine if network | ||
| + | |||
| + | 2. Check connectivity based on port or service | ||
| + | Test-NetConnection " | ||
| + | |||
| + | Another feature of the Test-NetConnection cmdlet is the ability to test the connectivity | ||
| + | between the local | ||
| + | |||
| + | 3. Trace route communications | ||
| + | Test-NetConnection " | ||
| + | |||
| + | 4. Obtain IP configuration details | ||
| + | Get-NetIPConfiguration | ||
| + | |||
| + | Similar to the ipconfig command, the Get-NetIPConfiguration cmdlet provides a holistic | ||
| + | |||
| + | 5. Perform DNS lookups | ||
| + | Resolve-DnsName -Name " | ||
| + | |||
| + | By appending the " | ||
| + | | ||
| + | |||
| + | 6. View current TCP connections | ||
| + | Get-NetTCPConnection | ||
| + | |||
| + | Just like netstat before it, | ||
| + | |||
| + | 7. View & Set DNS information | ||
| + | Get-DnsClient | ||
| + | Set-DnsClientServer Address | ||
| + | |||
| + | This cmdlet lets you check the DNS client information for a device. | ||
| + | It will indicate what DNS server(s) are being used by the device to perform address resolutions as | ||
| + | The Set-DnsClientServerAddress cmdlet allows for specified DNS servers to be added to the network | ||
| + | |||
| + | 8. Flush DNS cache | ||
| + | Clear-DnsClientCache | ||
| + | |||
| + | The DNS cache helps keep often used DNS resolution records stored locally on a device, | ||
| + | |||
| + | 9. Release and renew DHCP leases | ||
| + | Invoke-Command -ComputerName -ScriptBlock {ipconfig /release} | ||
| + | Invoke-Command -ComputerName -ScriptBlock {ipconfig /renew} | ||
| + | |||
| + | there is no direct way to release/ | ||
| + | | ||
| + | 10. Disable and enable network adapters | ||
| + | Disable-NetAdapter -Name " | ||
| + | Enable-NetAdapter -Name " | ||
| + | |||
| + | From < | ||
| </ | </ | ||
software/microsoft/windows/powershell.1595955232.txt.gz · Last modified: by superwizard
