SkillPilotAI

PowerShell RemoteAccess module (3/5)

Part 3 of the RemoteAccess module: health and status Get- cmdlets (server health, RADIUS, IP filters, load balancer, user activity, VPN server, S2S interfaces), Install-RemoteAccess, the New- traffic selector and SSTP proxy rule, and the Remove- cmdlets for RADIUS, DirectAccess, VPN and BGP. The lab removes BGP pieces step by step in FRRouting.

257.1 Why is it used?

  • Get-RemoteAccessHealth is the first command when users say "VPN is down".
  • User activity and connection data answer who accessed what over VPN/DirectAccess.
  • Traffic selectors decide exactly which traffic enters an S2S tunnel.
  • Remove- cmdlets cleanly retire peers, sites, RADIUS servers and pools.
  • Office PC: Count 0; office VPN/RADIUS never touched; syntax/output from Microsoft Learn.

257.2 How it works

RRAS server: VPN user, RADIUS and branch S2S
  1. 1.Remote user connects with IKEv2 / SSTP 443

  2. 2.RRAS forwards Access-Request to RADIUS (NPS) 10.1.2.1

  3. 3.RADIUS answers Access-Accept on port 1812

  4. 4.Branch router edge1 is connected through an S2S tunnel

  5. 5.Get-RemoteAccessHealth shows all these components in one table

257.3 Health, RADIUS, IP filter, load balancer

  • Get-RemoteAccessHealth: one server (-ComputerName), the NLB cluster (-Cluster) or one site (-EntrypointName); -Refresh recomputes.
  • Rule: one feature red = server red; one yellow = server yellow.
  • Get-RemoteAccessLoadBalancer shows servers, status, VPN range, VIPs; -Brief skips node status.
  • Get-/Remove-RemoteAccessRadius work per -Purpose Authentication|Accounting|Otp; run once per purpose.
  • The last VPN auth RADIUS cannot be deleted; removing the last accounting server falls back to Windows accounting.
  • Get-/Remove-RemoteAccessIpFilter use -InterfaceAlias, -Direction and -List "src:dst:protocol:port1:port2".
  • Remove-RemoteAccessLoadBalancerNode takes a server out of the cluster and clears its DA + VPN settings; the role is NOT uninstalled.
PowerShell
Get-RemoteAccessHealthGet-RemoteAccessLoadBalancer -EntrypointName Edge1_Site -BriefRemove-RemoteAccessRadius -ServerName 10.1.1.1 -Purpose Authentication -PassThruGet-RemoteAccessRadiusGet-RemoteAccessIpFilter -InterfaceAlias Interface1 -Direction OutboundRemove-RemoteAccessLoadBalancerNode -RemoteAccessServer edge3.corp.contoso.com `  -ComputerName edge2.corp.contoso.com
Output
PS C:\>Get-RemoteAccessHealthComponent            RemoteAccessServer   HealthState     TimeStamp            Id              OperationStatus---------            ------------------   -----------     ---------            --              ---------------Server               localhost            Error           2/1/2012 1:59:32 AMVpn Addressing       localhost            OK              2/1/2012 1:59:20 AMIPsec                localhost            OK              2/1/2012 1:59:16 AMKerberos             localhost            Disabled        2/1/2012 1:59:16 AMHigh Availability    localhost            Error           2/1/2012 1:59:32 AM  {2148401155,... {NLB state, NLB drive...Vpn Connectivity     localhost            OK              2/1/2012 1:59:13 AM
Output
PS C:\>Remove-RemoteAccessRadius -ServerName 10.1.1.1 -Purpose Authentication -PassThruServerName : 10.1.1.1Purpose    : AuthenticationPS C:\>Get-RemoteAccessRadiusServerName      Purpose         Score   Timeout(s)  Port    AccountingOnOffMsg MsgAuthenticator----------      -------         -----   ----------  ----    ------------------ ----------------10.1.1.1        Accounting       30       5         1813    Disabled10.1.3.1        Accounting       30       5         1813    Disabled10.1.2.1        Authentication   30       5         1812                       DisabledPS C:\> Get-RemoteAccessIpFilter -InterfaceAlias Interface1 -Direction OutboundInterfaceAlias   : Interface1Direction        : outboundIpv4FilterAction : allowIpv4Filters      : {10.0.0.0/16:10.2.0.0/16:tcp:1234:4321}Ipv6FilterAction :Ipv6Filters      :

257.4 User activity, routing preference, VPN server settings

  • Get-RemoteAccessRoutingDomain: routing config of one tenant (no -Name = all).
  • Get-RemoteAccessUserActivity: servers and ports a user accessed; no dates = only active connections, with dates = history from the inbox accounting store.
  • Get-RoutingProtocolPreference: lower value = higher priority when the same route comes from two protocols.
  • Get-VpnAuthProtocol: incoming VPN auth, e.g. {EAP, MsChapv2}; Get-VpnServerConfiguration -TunnelType IKEV2|L2TP.
PowerShell
Get-RemoteAccessUserActivity -StartDateTime $startdate -EndDateTime $enddate `  -UserName "corp.contoso.com\User1"Get-RoutingProtocolPreferenceGet-VpnAuthProtocolGet-VpnServerConfiguration -TunnelType IKEV2
Output
ServerIpAddress                          ProtocolID                     ServerPort---------------                          ----------                     ----------2001:4898:0:fff:0:5efe:10.57.36.131      6                              4432001:4898:0:fff:0:5efe:10.57.36.131      50                             0 Protocol                                          Priority (Lower value = higher priority)-----------------------------                     -----------------------------------------------local                                             1static                                            3nondod                                            5autostatic                                        7netmgmt                                           10ebgp                                              15rip                                               120ibgp                                              200

257.5 S2S interface, traffic selector, SSTP proxy, VPN pool

New-VpnTrafficSelector: which traffic enters the S2S tunnel
  1. 1.HQ PC 10.10.1.5 sends TCP 443 to branch server 20.20.1.10

  2. 2.RRAS EDGE1 checks: source in local TS 10.10.0.0-10.10.255.255 and protocol 6?

  3. 3.Match: packet enters the tunnel to the branch gateway (remote TS 20.20.0.0/16)

  4. 4.Packet reaches the branch server

  5. 5.A UDP 53 packet (protocol 17) does not match, so it does not use this tunnel

CmdletWhat it does
New-VpnTrafficSelectorObject with -IPAddressRange, -PortRange, -Protocol, -Type IPv4|IPv6; apply via Set-VpnS2SInterface
Get-VpnS2SInterfaceDestination and ConnectionState of tunnels
Get-VpnS2SInterfaceStatisticsByte, frame and error counters (-Clear resets)
Remove-VpnS2SInterfaceDeletes the tunnel (-Force skips confirm)
New-/Get-/Remove-VpnSstpProxyRuleTenant ID -> gateway mappings
Remove-VpnIPAddressRangeRemoves a static VPN pool range by its start IP (-Force even the last range)
PowerShell
$LocalTS = New-VpnTrafficSelector -IPAddressRange 10.10.0.0, 10.10.255.255 `  -PortRange 100, 1000 -Protocol 6 -Type IPv4Set-VpnS2SInterface -Name EDGE1 -LocalVpnTrafficSelector $LocalTSGet-VpnS2SInterfaceGet-VpnS2SInterfaceStatistics -Name 2-edge1Remove-VpnS2SInterface -Name TestVpnS2SInterface $Rule = New-VpnSstpProxyRule -TenantID "Contoso" -Gateway "100.10.10.10"Remove-VpnSstpProxyRule -TenantID "Contoso", "Woodgrove" -ForceRemove-VpnIPAddressRange -IPAddress 30.1.1.10 -Passthru
Output
PS C:\> Get-VpnS2SInterfaceName                 Destination          AdminStatus  ConnectionState IPv4Subnet----                 -----------          -----------  --------------- ----------edge1                {131.107.0.2}        True         Disconnected    {10.0.0.0/24:100}PS C:\> Get-VpnS2SInterfaceStatistics -Name 2-edge1BytesTransmitted      : 2874BytesReceived         : 14701FramesTransmitted     : 39FramesReceived        : 193CrcErrors             : 0TimeoutErrors         : 0PS C:\>Remove-VpnIPAddressRange -IPAddress 30.1.1.10 -PassthruStartIPAddress                           EndIPAddress--------------                           ------------30.1.1.10                                30.1.1.30

257.6 Install-RemoteAccess

Parameter setKey options
VPN (-VpnType Vpn|VpnS2S|SstpProxy|RoutingOnly)-IPAddressRange, -IPv6Prefix, -RadiusServer, -RadiusPort, -SharedSecret, -RadiusScore (30), -MultiTenancy, -CapacityKbps
DirectAccess (-DAInstallType FullInstall ...)-ConnectToAddress (public name), -DeployNat, -InternalInterface, -InternetInterface, -NlsUrl / -NlsCertificate, -ClientGpoName, -ServerGpoName
Checks only-PreRequisite (a non-admin gets error 104)
PowerShell
Install-RemoteAccess -VpnType VpnInstall-RemoteAccess -DAInstallType FullInstall -ConnectToAddress edge1...Install-RemoteAccess -PreRequisite
Output
PS C:\>Install-RemoteAccess -PreRequisiteWarning: The current user does not have the required permissions to configure WMI filtering in the domain. Verify permissions.Install-RemoteAccess : DirectAccess can only be configured by a user with local administrator permissions on the server. Add the current user to local administrator group+ FullyQualifiedErrorId : REMOTEACCESSERROR 104, Install-RemoteAccess

257.7 Remove-DA* and Remove-Bgp*

  • Remove-DAAppServer / Remove-DAClient remove security groups and their GPOs; the last client GPO + security group cannot be deleted.
  • Remove-DAClientDnsConfiguration removes one DNS suffix from the NRPT; Remove-DAEntryPoint removes a whole site; Remove-DAMgmtServer removes management servers.
  • Remove-BgpCustomRoute: router sends a route withdrawal to its peers.
  • Remove-BgpRoutingPolicyForPeer detaches a policy; Remove-BgpRoutingPolicy deletes it from the store.
  • Remove-BgpPeer removes all routes learned from that peer (confirm per peer without -Force); Remove-BgpRouter removes the whole BGP router.
PowerShell
Remove-DAClientDnsConfiguration -DnsSuffix 'contoso.com' -PassThruRemove-DAEntryPoint -Name "Entry Point 2" -PassThru -Force Remove-BgpCustomRoute -Network "172.23.90.0/29"Remove-BgpRouteAggregate -Force -Prefix "172.168.0.0/16", "10.10.10.0/24"Remove-BgpRoutingPolicyForPeer -PolicyName "RTPolicy04" -Direction Egress `  -PeerName "TenantSite04"Remove-BgpRoutingPolicy -Name "RTPolicy01"Remove-BgpPeer -Name TenantSite22,TenantSite23Remove-BgpRouter -Force
Output
PS C:\>Remove-DAEntryPoint -Name "Entry Point 2" -PassThru -ForceEntryPointName                 GslbIp                         Servers--------------                 ------                         -------Entry Point 2                  0.0.0.0                        {da2.domain1.corp.contoso.com}PS C:\> Remove-BgpPeer -Name TenantSite22,TenantSite23ConfirmBGP peering session is active with peer TenantSite22. Do you want to stop peering and remove this peer?[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): yConfirmBGP peering session is active with peer TenantSite23. Do you want to stop peering and remove this peer?[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

257.8 Lab: Remove-Bgp* as FRR "no" commands

Lab: a removed network becomes a WITHDRAW
  1. 1.router1 (AS 65001, .11) and router2 (AS 65002, .12) Established on TCP 179 in 192.168.157.0/24

  2. 2.router1 sends UPDATE for 10.255.56.0/22, .57.0/24, .58.0/24

  3. 3.router1: no network 10.255.57.0/24

  4. 4.router1 sends WITHDRAW 10.255.57.0/24

  5. 5.router2 drops 10.255.57.0/24 from its table

FRR command on router1Windows cmdletEffect on router2
no network 10.255.57.0/24Remove-BgpCustomRoute10.255.57.0/24 disappears
no aggregate-address 10.255.56.0/22Remove-BgpRouteAggregateOnly 10.255.58.0/24 left
no neighbor ... route-map MED outRemove-BgpRoutingPolicyForPeerMetric 50 -> 0
no route-map MEDRemove-BgpRoutingPolicyNo change; route-map not found
no neighbor 192.168.157.12Remove-BgpPeerPeer Active, 0 prefixes
no router bgp 65001Remove-BgpRouterBGP instance not found (bgpd still running)
Terminal
# router1.conf (FRR 10.0)ip route 10.255.57.0/24 blackholeip route 10.255.58.0/24 blackholerouter bgp 65001 neighbor 192.168.157.12 remote-as 65002 address-family ipv4 unicast  network 10.255.57.0/24  network 10.255.58.0/24  aggregate-address 10.255.56.0/22  neighbor 192.168.157.12 route-map MED outroute-map MED permit 10 set metric 50
Output
[router1]$ vtysh -c "show daemons" mgmtd zebra bgpd watchfrr staticd[router2]$ vtysh -c "show ip bgp"    Network          Next Hop            Metric LocPrf Weight Path *> 10.255.56.0/22   192.168.157.11          50             0 65001 i *> 10.255.57.0/24   192.168.157.11          50             0 65001 i *> 10.255.58.0/24   192.168.157.11          50             0 65001 iDisplayed 3 routes and 3 total paths[router1]$ vtysh -c "conf t; router bgp 65001; address-family ipv4 unicast; no network 10.255.57.0/24"[router2]$ vtysh -c "show ip bgp" *> 10.255.56.0/22   192.168.157.11          50             0 65001 i *> 10.255.58.0/24   192.168.157.11          50             0 65001 iDisplayed 2 routes and 2 total paths[router1]$ vtysh -c "show route-map MED"ZEBRA: 'route-map MED' not foundBGP: 'route-map MED' not found[router1]$ vtysh -c "show bgp summary"% No BGP neighbors found in VRF default[router2]$ vtysh -c "show ip bgp"No BGP prefixes displayed, 0 exist[router1]$ vtysh -c "conf t; no router bgp 65001"[router1]$ vtysh -c "show bgp summary"% BGP instance not found

257.9 Common mistakes

  • Thinking Remove-RemoteAccessLoadBalancerNode uninstalls the role: it only clears DA + VPN settings on that node.
  • Expecting Remove-RemoteAccessRadius -Purpose Authentication to remove the server completely: its Accounting row stays.
  • Reading one OK line in Get-RemoteAccessHealth and ignoring the red one: one red feature makes the server red.
  • Running Install-RemoteAccess on a production server to "just test" (it changes the server; use -PreRequisite).

257.10 Interview tips

  • Safely remove a BGP peer: Get-BgpPeer -> Remove-BgpRoutingPolicyForPeer -> Remove-BgpPeer -> Get-BgpRouteInformation to confirm the alternate route.
  • Route preference: lower value wins (static 3, eBGP 15, iBGP 200).
  • Traffic selectors = which source/destination/protocol/ports go into an IPsec S2S tunnel.
  • Removing a BGP network causes a WITHDRAW to peers, not just a local change.