131 commands · 8 cheat sheets · Windows

Networking and Remote Access master quick reference

Browse 131 commands from 8 focused cheat sheets on page 1 of 1. Each example opens its matching detailed section.

Networking and Remote Access · 19 commands

PowerShell Network Diagnostics Cheat Sheet

Open full cheat sheet
UseSyntaxExamples
Show active configurationGet-NetIPConfigurationView examples
Include disconnected interfacesGet-NetIPConfiguration -AllView examples
List IPv4 addressesGet-NetIPAddress -AddressFamily IPv4View examples
Inspect interface stateGet-NetIPInterface | Sort-Object InterfaceMetricView examples
Show IPv4 routesGet-NetRoute -AddressFamily IPv4 | Sort-Object RouteMetricView examples
Find the selected routeFind-NetRoute -RemoteIPAddress 1.1.1.1View examples
Inspect neighbor stateGet-NetNeighbor -AddressFamily IPv4View examples
Resolve IPv4 recordsResolve-DnsName -Name example.com -Type AView examples
Query a specific DNS serverResolve-DnsName -Name example.com -Type A -Server ` 192.0.2.53View examples
Clear the client DNS cacheClear-DnsClientCache -WhatIfView examples
Test ICMP reachabilityTest-Connection -TargetName example.com -Count 4View examples
Test a hostTest-NetConnection -ComputerName example.comView examples
Test a TCP portTest-NetConnection -ComputerName example.com -Port 443 ` -InformationLevel DetailedView examples
Trace the routeTest-NetConnection -ComputerName example.com -TraceRouteView examples
Show TCP listenersGet-NetTCPConnection -State Listen | Sort-Object LocalPortView examples
Show established TCP sessionsGet-NetTCPConnection -State EstablishedView examples
Show UDP endpointsGet-NetUDPEndpoint | Sort-Object LocalPortView examples
Map a socket to its processGet-Process -Id (Get-NetTCPConnection -LocalPort ` 443).OwningProcessView examples
Capture a port-test object$test = Test-NetConnection example.com -Port 443 ` -InformationLevel DetailedView examples

Networking and Remote Access · 12 commands

PowerShell Remoting Cheat Sheet

Open full cheat sheet
UseSyntaxExamples
Test WSManTest-WSMan -ComputerName 'server01'View examples
Run one commandInvoke-Command -ComputerName 'server01' -ScriptBlock { ` Get-Date }View examples
Pass argumentsInvoke-Command -ComputerName 'server01' -ScriptBlock { ` param($name) Get-Service -Name $name } -ArgumentList ` 'Spooler'View examples
Fan out to hostsInvoke-Command -ComputerName 'server01','server02' ` -ScriptBlock { hostname }View examples
Create a persistent session$session = New-PSSession -ComputerName 'server01'View examples
Enter interactivelyEnter-PSSession -Session $sessionView examples
Close a sessionRemove-PSSession -Session $sessionView examples
Prompt for credentials$credential = Get-CredentialView examples
Connect over SSHNew-PSSession -HostName 'server01' -UserName 'deploy' ` -SSHTransportView examples
Copy into a sessionCopy-Item -LiteralPath '.\config.json' -Destination ` 'C:\Temp\config.json' -ToSession $sessionView examples
Stop on remote non-terminating errorsInvoke-Command -Session $session -ScriptBlock { Get-Item ` C:\missing -ErrorAction Stop }View examples
List endpointsGet-PSSessionConfigurationView examples

Networking and Remote Access · 13 commands

Windows Defender Firewall PowerShell Cheat Sheet

Open full cheat sheet
UseSyntaxExamples
Inspect profilesGet-NetFirewallProfile | Select-Object Name, Enabled, DefaultInboundAction, DefaultOutboundActionView examples
List active enabled rulesGet-NetFirewallRule -PolicyStore ActiveStore -Enabled ` TrueView examples
Get one ruleGet-NetFirewallRule -Name 'CmdMemo-HTTPS-In'View examples
Inspect portsGet-NetFirewallRule -Name 'CmdMemo-HTTPS-In' | Get-NetFirewallPortFilterView examples
Inspect addressesGet-NetFirewallRule -Name 'CmdMemo-HTTPS-In' | Get-NetFirewallAddressFilterView examples
Inspect program scopeGet-NetFirewallRule -Name 'CmdMemo-HTTPS-In' | Get-NetFirewallApplicationFilterView examples
Preview an inbound ruleNew-NetFirewallRule -Name 'CmdMemo-HTTPS-In' ` -DisplayName 'CmdMemo HTTPS' -Direction Inbound ` -Action Allow -Protocol TCP -LocalPort 443 -Profile ` Domain -WhatIfView examples
Preview disablingDisable-NetFirewallRule -Name 'CmdMemo-HTTPS-In' -WhatIfView examples
Preview enablingEnable-NetFirewallRule -Name 'CmdMemo-HTTPS-In' -WhatIfView examples
Preview removalRemove-NetFirewallRule -Name 'CmdMemo-HTTPS-In' -WhatIfView examples
Export firewall policynetsh advfirewall export 'C:\Backup\firewall.wfw'View examples
Test a TCP endpointTest-NetConnection -ComputerName 'server01' -Port 443 ` -InformationLevel DetailedView examples
Inspect profile loggingGet-NetFirewallProfile | Select-Object Name, LogAllowed, LogBlocked, LogFileNameView examples

Networking and Remote Access · 18 commands

Windows DHCP Server PowerShell Administration Cheat Sheet

Open full cheat sheet
UseSyntaxExamples
Inspect DHCP role stateGet-WindowsFeature -Name DHCP,RSAT-DHCP | Select-Object Name, InstallStateView examples
Inspect DhcpServer moduleGet-Module -ListAvailable -Name DhcpServer | Select-Object Name, Version, PathView examples
List authorized serversGet-DhcpServerInDCView examples
Preview authorizationAdd-DhcpServerInDC -DnsName 'dhcp01.corp.example' ` -IPAddress '192.0.2.10' -WhatIfView examples
List IPv4 scopesGet-DhcpServerv4Scope -ComputerName ` 'dhcp01.corp.example'View examples
Inspect active leasesGet-DhcpServerv4Lease -ComputerName ` 'dhcp01.corp.example' -ScopeId '192.0.2.0' -AllLeasesView examples
Read scope statisticsGet-DhcpServerv4ScopeStatistics -ComputerName ` 'dhcp01.corp.example' -ScopeId '192.0.2.0'View examples
Preview an inactive scopeAdd-DhcpServerv4Scope -ComputerName 'dhcp01' -Name ` 'VLAN-120' -StartRange 192.0.2.50 -EndRange ` 192.0.2.199 -SubnetMask 255.255.255.0 -State InActive ` -WhatIfView examples
Preview an exclusionAdd-DhcpServerv4ExclusionRange -ComputerName 'dhcp01' ` -ScopeId '192.0.2.0' -StartRange '192.0.2.1' -EndRange ` '192.0.2.49' -WhatIfView examples
Inspect effective optionsGet-DhcpServerv4OptionValue -ComputerName ` 'dhcp01.corp.example' -ScopeId '192.0.2.0' -AllView examples
Preview common optionsSet-DhcpServerv4OptionValue -ComputerName 'dhcp01' ` -ScopeId '192.0.2.0' -Router '192.0.2.1' -DnsServer ` '192.0.2.20','192.0.2.21' -WhatIfView examples
Preview a reservationAdd-DhcpServerv4Reservation -ComputerName 'dhcp01' ` -ScopeId '192.0.2.0' -IPAddress '192.0.2.80' -ClientId ` '00-11-22-33-44-55' -WhatIfView examples
Inspect DNS update policyGet-DhcpServerv4DnsSetting -ComputerName ` 'dhcp01.corp.example' -ScopeId '192.0.2.0'View examples
Inspect failoverGet-DhcpServerv4Failover -ComputerName ` 'dhcp01.corp.example' -ScopeId '192.0.2.0'View examples
Preview load-balance failoverAdd-DhcpServerv4Failover -ComputerName 'dhcp01' -Name ` 'SITE-A' -PartnerServer 'dhcp02' -ScopeId 192.0.2.0 ` -SharedSecret '<approved-secret>' -WhatIfView examples
Preview failover replicationInvoke-DhcpServerv4FailoverReplication -ComputerName ` 'dhcp01.corp.example' -Name 'SITE-A' -WhatIfView examples
Preview DHCP exportExport-DhcpServer -ComputerName 'dhcp01.corp.example' ` -File 'C:\DHCP-Backup\dhcp01.xml' -Leases -WhatIfView examples
Read DHCP admin eventsGet-WinEvent -LogName ` 'Microsoft-Windows-DHCP Server Events/Admin' ` -MaxEvents 100View examples

Networking and Remote Access · 18 commands

Windows DNS Server PowerShell Administration Cheat Sheet

Open full cheat sheet
UseSyntaxExamples
Inspect DNS role stateGet-WindowsFeature -Name DNS,RSAT-DNS-Server | Select-Object Name, InstallStateView examples
Inspect DnsServer moduleGet-Module -ListAvailable -Name DnsServer | Select-Object Name, Version, PathView examples
List hosted zonesGet-DnsServerZone -ComputerName 'dns01.corp.example'View examples
Inspect one zoneGet-DnsServerZone -ComputerName 'dns01.corp.example' -Name 'corp.example' | Format-List *View examples
Read an A recordGet-DnsServerResourceRecord -ComputerName ` 'dns01.corp.example' -ZoneName 'corp.example' -Name ` 'app01' -RRType AView examples
Query a chosen serverResolve-DnsName -Name 'app01.corp.example' -Type A ` -Server 'dns01.corp.example' -DnsOnlyView examples
Preview an AD zoneAdd-DnsServerPrimaryZone -ComputerName 'dns01' -Name ` 'apps.corp.example' -ReplicationScope Domain ` -DynamicUpdate Secure -WhatIfView examples
Preview a reverse zoneAdd-DnsServerPrimaryZone -ComputerName 'dns01' ` -NetworkId '192.0.2.0/24' -ReplicationScope Domain ` -DynamicUpdate Secure -WhatIfView examples
Preview A and PTR recordsAdd-DnsServerResourceRecordA -ComputerName 'dns01' ` -ZoneName 'corp.example' -Name 'app01' -IPv4Address ` '192.0.2.40' -CreatePtr -WhatIfView examples
Preview a CNAMEAdd-DnsServerResourceRecordCName -ComputerName 'dns01' ` -ZoneName 'corp.example' -Name 'portal' -HostNameAlias ` 'app01.corp.example' -WhatIfView examples
Preview exact record removalRemove-DnsServerResourceRecord -ComputerName 'dns01' ` -ZoneName 'corp.example' -RRType A -Name 'app01' ` -RecordData '192.0.2.40' -WhatIfView examples
Inspect zone agingGet-DnsServerZoneAging -ComputerName ` 'dns01.corp.example' -Name 'corp.example'View examples
Preview aging settingsSet-DnsServerZoneAging -ComputerName 'dns01' -Name ` 'corp.example' -Aging $true -NoRefreshInterval ` 7.00:00:00 -RefreshInterval 7.00:00:00 -WhatIfView examples
Inspect forwardersGet-DnsServerForwarder -ComputerName ` 'dns01.corp.example'View examples
Inspect recursion policyGet-DnsServerRecursion -ComputerName ` 'dns01.corp.example'View examples
Preview zone exportExport-DnsServerZone -ComputerName 'dns01.corp.example' ` -Name 'corp.example' -FileName ` 'corp-example-audit.txt' -WhatIfView examples
Inspect DNSSEC settingsGet-DnsServerDnsSecZoneSetting -ComputerName ` 'dns01.corp.example' -ZoneName 'corp.example'View examples
Read recent DNS eventsGet-WinEvent -FilterHashtable @{LogName='DNS Server'; ` StartTime=(Get-Date).AddHours(-2)} -MaxEvents 100View examples

Networking and Remote Access · 16 commands

Windows Network Load Balancing Cheat Sheet

Open full cheat sheet
UseSyntaxExamples
Inspect NLB featureGet-WindowsFeature NLB,RSAT-NLBView examples
Inspect network adaptersGet-NetAdapter | Select-Object Name,InterfaceDescription,Status,MacAddress,LinkSpeedView examples
List NLB clustersGet-NlbClusterView examples
List cluster nodesGet-NlbClusterNode -HostName NLB01View examples
List port rulesGet-NlbClusterPortRule -HostName NLB01View examples
Create clusterNew-NlbCluster -InterfaceName 'Ethernet' ` -ClusterPrimaryIP 192.0.2.20 -ClusterName ` web.contoso.example -OperationMode MulticastView examples
Add nodeAdd-NlbClusterNode -NewNodeName NLB02 -NewNodeInterface ` 'Ethernet' -InterfaceName 'Ethernet' -HostName NLB01View examples
Add balanced HTTPS ruleAdd-NlbClusterPortRule -InterfaceName 'Ethernet' ` -StartPort 443 -EndPort 443 -Protocol TCP -Affinity ` SingleView examples
Set node load weightGet-NlbClusterPortRule -HostName NLB01 -StartPort 443 | Set-NlbClusterPortRuleNodeWeight -LoadWeight 50View examples
Drain node trafficStop-NlbClusterNode -HostName NLB01 -DrainView examples
Resume node trafficStart-NlbClusterNode -HostName NLB01View examples
Suspend NLB controlSuspend-NlbClusterNode -HostName NLB01View examples
Read node operational stateGet-NlbClusterNode -HostName NLB01 | Select-Object HostName,State,Status,PriorityView examples
Test application endpointTest-NetConnection web.contoso.example -Port 443View examples
Read NLB eventsGet-WinEvent -ProviderName Microsoft-Windows-NLB ` -MaxEvents 100View examples
Remove a drained nodeRemove-NlbClusterNode -HostName NLB02View examples

Networking and Remote Access · 18 commands

Windows Remote Desktop Services and Sessions PowerShell Cheat Sheet

Open full cheat sheet
UseSyntaxExamples
Check RDS cmdletsGet-Module -ListAvailable 'RemoteDesktop' | Select-Object Name, Version, PathView examples
List deployment serversGet-RDServer -ConnectionBroker 'rdcb01.contoso.com' | Sort-Object ServerView examples
List session hostsGet-RDServer -ConnectionBroker 'rdcb01.contoso.com' ` -Role 'RDS-RD-SERVER'View examples
List session collectionsGet-RDSessionCollection -ConnectionBroker 'rdcb01.contoso.com' | Sort-Object CollectionNameView examples
List collection hostsGet-RDSessionHost -CollectionName 'Finance Apps' ` -ConnectionBroker 'rdcb01.contoso.com'View examples
Inspect connection policyGet-RDSessionCollectionConfiguration -CollectionName ` 'Finance Apps' -Connection -ConnectionBroker ` 'rdcb01.contoso.com'View examples
Inspect security policyGet-RDSessionCollectionConfiguration -CollectionName ` 'Finance Apps' -Security -ConnectionBroker ` 'rdcb01.contoso.com'View examples
Inspect authorized groupsGet-RDSessionCollectionConfiguration -CollectionName ` 'Finance Apps' -UserGroup -ConnectionBroker ` 'rdcb01.contoso.com'View examples
List published RemoteAppsGet-RDRemoteApp -CollectionName 'Finance Apps' ` -ConnectionBroker 'rdcb01.contoso.com'View examples
Inspect RDS licensingGet-RDLicenseConfiguration -ConnectionBroker ` 'rdcb01.contoso.com'View examples
List deployment sessionsGet-RDUserSession -ConnectionBroker 'rdcb01.contoso.com' | Sort-Object HostServer, UnifiedSessionIdView examples
List collection sessionsGet-RDUserSession -CollectionName 'Finance Apps' ` -ConnectionBroker 'rdcb01.contoso.com'View examples
Resolve one user's sessionsGet-RDUserSession -ConnectionBroker 'rdcb01.contoso.com' | Where-Object { $_.DomainName -eq 'CONTOSO' -and $_.UserName -eq 'alice' }View examples
Query host-local sessionsquser.exe /server:rdsh01.contoso.comView examples
Notify one sessionSend-RDUserMessage -HostServer 'rdsh01.contoso.com' ` -UnifiedSessionID 12 -MessageTitle 'Maintenance' ` -MessageBody 'Save work by 22:00 UTC.'View examples
Disconnect one sessionDisconnect-RDUser -HostServer 'rdsh01.contoso.com' ` -UnifiedSessionID 12View examples
Log off one sessionInvoke-RDUserLogoff -HostServer 'rdsh01.contoso.com' ` -UnifiedSessionID 12View examples
Read Session Host eventsGet-WinEvent -LogName ` 'Microsoft-Windows-TerminalServices-LocalSessionManager/Operational' ` -MaxEvents 100View examples

Networking and Remote Access · 17 commands

Windows SMB Shares and Sessions PowerShell Cheat Sheet

Open full cheat sheet
UseSyntaxExamples
List ordinary sharesGet-SmbShare -Special $false | Select-Object Name, Path, ShareState, EncryptDataView examples
Inspect one shareGet-SmbShare -Name 'TeamData' | Format-List *View examples
Inspect a remote serverGet-SmbShare -CimSession 'files01' -Special $falseView examples
Inspect share permissionsGet-SmbShareAccess -Name 'TeamData'View examples
Inspect the folder ACLGet-Acl -LiteralPath 'D:\Shares\TeamData' | Format-List Owner, AccessToStringView examples
Create a scoped shareNew-SmbShare -Name 'TeamData' -Path 'D:\Shares\TeamData' ` -ChangeAccess 'CONTOSO\File-Team' -FullAccess ` 'CONTOSO\File-Admins'View examples
Preview share hardeningSet-SmbShare -Name 'TeamData' -EncryptData $true ` -FolderEnumerationMode AccessBased -CachingMode None ` -WhatIfView examples
Preview an access grantGrant-SmbShareAccess -Name 'TeamData' -AccountName ` 'CONTOSO\Auditors' -AccessRight Read -WhatIfView examples
Preview revoking accessRevoke-SmbShareAccess -Name 'TeamData' -AccountName ` 'CONTOSO\Auditors' -WhatIfView examples
List server sessionsGet-SmbSession | Select-Object SessionId, ClientComputerName, ClientUserName, NumOpensView examples
List a user's open filesGet-SmbOpenFile -ClientUserName 'CONTOSO\ada' | Select-Object FileId, SessionId, PathView examples
Preview closing a fileClose-SmbOpenFile -FileId 4415226383589 -Force -WhatIfView examples
Preview closing a sessionClose-SmbSession -SessionId 88143542 -Force -WhatIfView examples
Test SMB reachabilityTest-NetConnection -ComputerName 'files01' -Port 445 ` -InformationLevel DetailedView examples
Inspect client connectionsGet-SmbConnection -ServerName 'files01' | Select-Object ShareName, Dialect, Encrypted, NumOpensView examples
Read SMB server eventsGet-WinEvent -LogName ` 'Microsoft-Windows-SMBServer/Operational' -MaxEvents ` 30View examples
Preview share removalRemove-SmbShare -Name 'TeamData' -WhatIfView examples
CMDMEMO TERMINALREAD ONLY