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 requests will allow to use customised data_encryption and ui_customization settings; unlicensed providers API requests will be subject to default application values when encrypting response data even passphrase value will be updated in web.config file. Any other application settings can be changed as required. * Default values are: 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, 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("SecureMFA WEBAPI") -eq $False) {New-EventLog -LogName "Application" -Source "SecureMFA WEBAPI" ; Write-Host "SecureMFA 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 "Only licensed Providers API requests will allow to use customised data_encryption and ui_customization settings; unlicensed providers API requests will be subject to default application values when encrypting response data even passphrase value will be updated in web.config file. Any other application settings can be changed as required." -ForegroundColor Cyan $DefaultValues = @{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';smtp_server='smtp.adatum.labnet';smtp_mailfrom='noreply@adatum.labnet';smtp_port='25';smtp_enablessl='false';smtp_username='';smtp_password='';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 } } |