{"id":347,"date":"2017-07-24T10:11:45","date_gmt":"2017-07-24T08:11:45","guid":{"rendered":"https:\/\/msb365.abstergo.ch\/?p=347"},"modified":"2017-10-27T10:14:08","modified_gmt":"2017-10-27T08:14:08","slug":"web-application-proxy-powershell-cheat-sheet","status":"publish","type":"post","link":"https:\/\/www.msb365.blog\/?p=347","title":{"rendered":"Web Application Proxy PowerShell Cheat Sheet"},"content":{"rendered":"<div id=\"page\" class=\"site container-fluid\">\n<div id=\"site-content\" class=\"site-content row\">\n<div id=\"primary\" class=\"content-area col-sm-9\">\n<div id=\"single-content\" class=\"div-content\">\n<article id=\"post-24\" class=\"post-24 post type-post status-publish format-standard hentry category-uncategorized tag-management tag-powershell tag-web-application-proxy\">\n<div class=\"entry-content single\">\n<p>As Web Application Proxy is a standard Windows Server role service, you can use many Windows Server PowerShell tools to control Web Application Proxy:<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td valign=\"top\">Shows Web Application Proxy Windows services status<\/td>\n<td valign=\"top\">Get-Service&#8217;appproxysvc&#8217;,&#8217;appproxyctrl&#8217;,&#8217;adfssrv&#8217;|fl-property*<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Shows the configuration of Web Application Proxy Windows service<\/td>\n<td valign=\"top\">Get-WmiObject-ClassWin32_Service-PropertyStartMode-Filter&#8221;Name=&#8217;appproxysvc'&#8221;<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Get Best Practices Analyzer (BPA) results for the Remote Access role<\/td>\n<td valign=\"top\">Invoke-BpaModel Microsoft\/Windows\/RemoteAccessServer ;<br \/>\nGet-BpaResultMicrosoft\/Windows\/RemoteAccessServer<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">List\u00a0all the events that Web Application Proxy had in the last 24 hours with their ID, Level and Message.<\/td>\n<td valign=\"top\">$yesterday = (Get-Date) &#8211; (New-TimeSpan -Day 1) ;<br \/>\nGet-WinEvent-FilterHashTable @{LogName=&#8217;Microsoft-Windows-WebApplicationProxy\/Admin&#8217;; StartTime=$yesterday} |group-PropertyID,LevelDisplayName,Message-NoElement|sortCount,Name-Descending|ft-AutoSize<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Read\u00a0Web Application Proxy\u00a0registry keys<\/td>\n<td valign=\"top\">Get-ItemPropertyhklm:\\software\\microsoft\\appproxy<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Read\u00a0Web Application Proxy performance counters at current point<\/td>\n<td valign=\"top\">Get-Counter&#8217;\\Web Application Proxy\\*&#8217;<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Return the number of currently active requests<\/td>\n<td valign=\"top\">(Get-Counter &#8216;\\Web Application Proxy\\active requests&#8217;).CounterSamples.CookedValue<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<\/div>\n<\/article>\n<div id=\"page\" class=\"site container-fluid\">\n<div id=\"site-content\" class=\"site-content row\">\n<div id=\"primary\" class=\"content-area col-sm-9\">\n<div id=\"single-content\" class=\"div-content\">\n<article id=\"post-24\" class=\"post-24 post type-post status-publish format-standard hentry category-uncategorized tag-management tag-powershell tag-web-application-proxy\">\n<div class=\"entry-content single\">\n<table cellspacing=\"0\" cellpadding=\"4\">\n<tbody>\n<tr>\n<td valign=\"top\"><b>cmdlet<\/b><\/td>\n<td valign=\"top\"><b>alias<\/b><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Add-WebApplicationProxyApplication<\/td>\n<td valign=\"top\">awpa<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Get-WebApplicationProxyApplication<\/td>\n<td valign=\"top\">gwpa<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Set-WebApplicationProxyApplication<\/td>\n<td valign=\"top\">swpa<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Remove-WebApplicationProxyApplication<\/td>\n<td valign=\"top\">rwpa<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Get-WebApplicationProxyConfiguration<\/td>\n<td valign=\"top\">gwpc<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Set-WebApplicationProxyConfiguration<\/td>\n<td valign=\"top\">swpc<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Get-WebApplicationProxyAvailableADFSRelyingParty<\/td>\n<td valign=\"top\">gwpr<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Get-WebApplicationProxyHealth<\/td>\n<td valign=\"top\">gwph<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<\/div>\n<div id=\"page\" class=\"site container-fluid\">\n<div id=\"site-content\" class=\"site-content row\">\n<div id=\"primary\" class=\"content-area col-sm-9\">\n<div id=\"single-content\" class=\"div-content\">\n<article id=\"post-24\" class=\"post-24 post type-post status-publish format-standard hentry category-uncategorized tag-management tag-powershell tag-web-application-proxy\">\n<div class=\"entry-content single\">\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td valign=\"top\">Show\u00a0published applications\u00a0that have ADFS as their preauthentication method<\/td>\n<td valign=\"top\">Get-WebApplicationProxyApplication | ? {$_.ExternalPreauthentication -eq &#8216;ADFS&#8217;}<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Export all published applications to a file<\/td>\n<td valign=\"top\">Get-WebApplicationProxyApplication | Export-Clixml &#8220;ExportedApps&#8221;<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Import published applications\u00a0from a file<\/td>\n<td valign=\"top\">Import-Clixml &#8220;ExportedApps&#8221; | Add-WebApplicationProxyApplication<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Getting full help on the set command<\/td>\n<td valign=\"top\">Get-Help -Full Set-WebApplicationProxyApplication<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">List all the details on all the certificates that are used by published apps.<br \/>\nNote: the cert: provider does not support filter<\/td>\n<td valign=\"top\">$WAP_Certs = (gwpa).ExternalCertificateThumbprint | sort \u2013Unique\u00a0;<br \/>\ndir Cert:\\LocalMachine\\my |? {$WAP_Certs -contains $_.Thumbprint} | fl -Property *<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Add a machine to the Web Application Proxy connected servers list<\/td>\n<td valign=\"top\">swpc -ConnectedServersName ((gwpc).ConnectedServersName + \u2018ServerToAdd\u2019)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Remove a machine from the\u00a0Web Application Proxy connected servers list<\/td>\n<td valign=\"top\">swpc \u2013ConnectedServersName ((gwpc).ConnectedServersName -ne \u2018ServerToRemove\u2019)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<div id=\"page\" class=\"site container-fluid\">\n<div id=\"site-content\" class=\"site-content row\">\n<div id=\"primary\" class=\"content-area col-sm-9\">\n<div id=\"single-content\" class=\"div-content\">\n<article id=\"post-24\" class=\"post-24 post type-post status-publish format-standard hentry category-uncategorized tag-management tag-powershell tag-web-application-proxy\">\n<div class=\"entry-content single\">\n<p>And finally, here are some tricks for managing Web Application Proxy multi-machine deployments:<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td valign=\"top\">Show the status of Web Application Proxy related services on all the connected servers grouped by their status.<br \/>\nNote: Same syntax would work with any command that supports the ComputerName parameter. E.g. set-service, get-process<\/td>\n<td valign=\"top\">Get-Service&#8217;appproxysvc&#8217;,&#8217;appproxyctrl&#8217;,&#8217;adfssrv&#8217;-ComputerName ((gwpc).ConnectedServersName) |sortStatus,MachineName,Name|ftMachineName,Name-AutoSize-GroupByStatus<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Restart the Web Application Proxy service on all the connected servers and print the name of the machines<\/td>\n<td valign=\"top\">Invoke-Command -ScriptBlock {Restart-Service &#8216;appproxysvc&#8217;; (Get-WmiObject -Class Win32_ComputerSystem).Name} -ComputerName ((gwpc).ConnectedServersName)<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Show the names of all the\u00a0connected servers that had event 12000 in the last 10 hours<\/td>\n<td valign=\"top\">Foreach ($Server in (gwpc).ConnectedServersName){Get-WinEvent -FilterHashTable @{LogName=&#8217;Microsoft-Windows-WebApplicationProxy\/Admin&#8217;; ID=12000; StartTime=(Get-Date) &#8211; (New-TimeSpan -hour 10)} -ComputerName $Server -ErrorAction SilentlyContinue | group MachineName -NoElement | ft Name -HideTableHeaders }<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\">Show all IP addresses of all servers in the cluster.<br \/>\nNote:<br \/>\n1. This will work only if remote management is enabled on all servers using Kerberos<br \/>\n2. Same syntax would work with any command that supports the CimSession parameter<br \/>\n3. New-CimSession can accept admin credentials.<\/td>\n<td valign=\"top\">Get-NetIPAddress-CimSession (New-CimSession-ComputerName ((gwpc).ConnectedServersName)) |ftIPAddress<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<\/div>\n<\/article>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/article>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>As Web Application Proxy is a standard Windows Server role service, you can use many Windows Server PowerShell tools to control Web Application Proxy: Shows Web Application Proxy Windows services status Get-Service&#8217;appproxysvc&#8217;,&#8217;appproxyctrl&#8217;,&#8217;adfssrv&#8217;|fl-property* Shows the configuration of Web Application Proxy Windows service Get-WmiObject-ClassWin32_Service-PropertyStartMode-Filter&#8221;Name=&#8217;appproxysvc&#8217;&#8221; Get Best Practices Analyzer (BPA) results for the Remote Access role Invoke-BpaModel Microsoft\/Windows\/RemoteAccessServer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[4,3],"tags":[],"class_list":["post-347","post","type-post","status-publish","format-standard","hentry","category-adfs","category-powershell"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts\/347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347"}],"version-history":[{"count":4,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts\/347\/revisions"}],"predecessor-version":[{"id":351,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=\/wp\/v2\/posts\/347\/revisions\/351"}],"wp:attachment":[{"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.msb365.blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}