Get-SecureMFA_WEPAPI_Portal.ps1
#Requires -RunAsAdministrator #Requires -Version 5.0 <# .SYNOPSIS Shows SecureMFA WEB API Portal configuration. .DESCRIPTION Shows SecureMFA WEB API Portal configuration in web.config file. Dependencies: * Only licensed Providers API request will use custom application settings; unlicensed providers will be subject to default application settings even those will be updated in web.config file * Default values are: api_auth_endpoint_enabled = $false, api_headers_value = "P4WK6mUMgL6ztXtiJUurA3Fhn5Xjbejy1ZAhwokT", data_encryption = $false, data_encryption_passphrase = "d9GhT=7=Ox8-+LaZ", ui_customization = $false, ui_login_failures = 0, ui_lockout_minutes = 5, totp_customization = $false, totp_validity_seconds = 30, verboselog = $false .NOTES Version: 2.0.0.1 Author: SecureMfa.com Creation Date: 08/09/2020 Purpose/Change: Release .EXAMPLE C:\PS> Get-SecureMFA_WEPAPI_Portal -siteName = "SecureMFAWebAPI" This command shows <appSettings> configuration values from parameters in web.config for SecureMFA WEB API Portal on a server. #> #Check if windows events source for application log exist, if not create one. if ([System.Diagnostics.EventLog]::SourceExists("Secure MFA WEBAPI") -eq $False) {New-EventLog -LogName "Application" -Source "Secure MFA WEBAPI" ; Write-Host "Secure MFA WEBAPI Log Source Created."} Function Get-SecureMFA_WEPAPI_Portal { Param ( [Parameter(Mandatory=$false)][string]$siteName = "SecureMFAWebAPI", [Parameter(Mandatory=$false)][Switch]$ListDefaultValues ) try { $Error.Clear() Import-Module WebAdministration if($ListDefaultValues) { # Default values list write-host "Unlicensed providers use default application settings values even those are updated in web.config file." -ForegroundColor Cyan $DefaultValues = @{api_auth_endpoint_enabled='false';api_headers_value='P4WK6mUMgL6ztXtiJUurA3Fhn5Xjbejy1ZAhwokT';data_encryption='false';data_encryption_passphrase='d9GhT=7=Ox8-+LaZ';ui_customization='false';ui_login_failures='0';ui_lockout_minutes='5';totp_customization='false';totp_validity_seconds='30';verboselog='false'} $DefaultValues.GetEnumerator() | sort -Property Name } else { if (!(Test-Path "iis:\Sites\$siteName" -Type Container) ) { throw "$siteName IIS website does not exist" ; break} #Get <appSettings> values Get-WebConfigurationProperty -pspath "iis:\Sites\$siteName" -filter "/appSettings/add" -name * | select key,value # Complete write-host "List of IIS WebSite $siteName application settings." -ForegroundColor Cyan } } catch { Write-Host "$($MyInvocation.InvocationName): $_" -ForegroundColor red } } |