public/Get-VPASSQLPlatforms.ps1

<#
.Synopsis
   GET SQL PLATFORMS
   CREATED BY: Vadim Melamed, EMAIL: vmelamed5@gmail.com
.DESCRIPTION
   USE THIS FUNCTION TO OUTPUT ALL PLATFORM DETAILS INTO AN SQL TABLE
.PARAMETER token
   HashTable of data containing various pieces of login information (PVWA, LoginToken, HeaderType, etc).
   If -token is not passed, function will use last known hashtable generated by New-VPASToken
.EXAMPLE
   $SQLPlatforms = Get-VPASSQLPlatforms
.OUTPUTS
   $true if successful
   ---
   $false if failed
#>

function Get-VPASSQLPlatforms{
    [OutputType([bool])]
    [CmdletBinding()]
    Param(

        [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true,Position=0)]
        [hashtable]$token
    )

    Begin{
        $tokenval,$sessionval,$PVWA,$Header,$ISPSS,$IdentityURL,$EnableTextRecorder,$AuditTimeStamp,$NoSSL,$VaultVersion,$HideWarnings,$AuthenticatedAs,$SubDomain = Get-VPASSession -token $token
        $CommandName = $MyInvocation.MyCommand.Name
        $log = Write-VPASTextRecorder -inputval $CommandName -token $token -LogType COMMAND
    }
    Process{
        $curUser = $env:UserName
        $ConfigFile = "C:\Users\$curUser\AppData\Local\VPASModuleOutputs\SQL\SQLConfigFile.txt"

        try{
            if(Test-Path -Path $ConfigFile){
                Write-Verbose "FOUND SQL CONFIG FILE...PARSING DATA"
            }
            else{
                Write-Verbose "FAILED TO FIND SQL CONFIG FILE...RERUN VSetSQLConnectionDetails"
                Write-VPASOutput -str "FAILED TO FIND SQL CONFIG FILE...RERUN VSetSQLConnectionDetails" -type E
                return $false
            }
        }catch{
            Write-Verbose "FAILED TO FIND SQL CONFIG FILE...RERUN VSetSQLConnectionDetails"
            Write-VPASOutput -str "FAILED TO FIND SQL CONFIG FILE...RERUN VSetSQLConnectionDetails" -type E
            return $false
        }

        Write-Verbose "PARSING FILE CONTENTS"
        $SQLServerTemp = ""
        $SQLDatabaseTemp = ""
        $SQLUsernameTemp = ""
        $AAMTemp = ""
        $AppIDTemp = ""
        $FolderTemp = ""
        $SafeIDTemp = ""
        $ObjectNameTemp = ""
        $AIMServerTemp = ""
        $PasswordSDKTemp = ""
        $SQLPasswordTemp = ""
        $CertificateTPTemp = ""
        $AllLines = Get-Content -Path $ConfigFile
        foreach($line in $AllLines){
            if($line -match "SQLServer="){ $SQLServerTemp = $line }
            if($line -match "SQLDatabase="){ $SQLDatabaseTemp = $line }
            if($line -match "SQLUsername="){ $SQLUsernameTemp = $line }
            if($line -match "AAM="){ $AAMTemp = $line }
            if($line -match "AppID="){ $AppIDTemp = $line }
            if($line -match "Folder="){ $FolderTemp = $line }
            if($line -match "SafeID="){ $SafeIDTemp = $line }
            if($line -match "ObjectName="){ $ObjectNameTemp = $line }
            if($line -match "AIMServer="){ $AIMServerTemp = $line }
            if($line -match "PasswordSDK="){ $PasswordSDKTemp = $line }
            if($line -match "SQLPassword="){ $SQLPasswordTemp = $line }
            if($line -match "CERTIFICATETP="){ $CertificateTPTemp = $line }
        }

        $AAMSplit = $AAMTemp -split "="
        $AAM = $AAMSplit[1]
        Write-Verbose "AAM = $AAM"

        $SQLServerSplit = $SQLServerTemp -split "="
        $SQLServer = $SQLServerSplit[1]
        Write-Verbose "SQLServer = $SQLServer"

        $SQLDatabaseSplit = $SQLDatabaseTemp -split "="
        $SQLDatabase = $SQLDatabaseSplit[1]
        Write-Verbose "SQLDatabase = $SQLDatabase"

        $SQLUsernameSplit = $SQLUsernameTemp -split "="
        $SQLUsername = $SQLUsernameSplit[1]
        Write-Verbose "SQLUsername = $SQLUsername"

        if($AAM -eq "CCP"){
            #CCP
            $AppIDSplit = $AppIDTemp -split "="
            $AppID = $AppIDSplit[1]
            Write-Verbose "AppID = $AppID"

            $FolderSplit = $FolderTemp -split "="
            $Folder = $FolderSplit[1]
            Write-Verbose "Folder = $Folder"

            $SafeIDSplit = $SafeIDTemp -split "="
            $SafeID = $SafeIDSplit[1]
            Write-Verbose "SafeID = $SafeID"

            $ObjectNameSplit = $ObjectNameTemp -split "="
            $ObjectName = $ObjectNameSplit[1]
            Write-Verbose "ObjectName = $ObjectName"

            $AIMServerSplit = $AIMServerTemp -split "="
            $AIMServer = $AIMServerSplit[1]
            Write-Verbose "AIMServer = $AIMServer"

            if([String]::IsNullOrEmpty($CertificateTPTemp)){
                #DO NOTHING
            }
            else{
                $CertificateTPSplit = $CertificateTPTemp -split "="
                $CertificateTP = $CertificateTPSplit[1]
                Write-Verbose "CertificateTP = $CertificateTP"
            }

            try{
                if($NoSSL){
                    $uri = "http://$AIMServer/AIMWebService/api/accounts?AppID=$AppID&Safe=$SafeID&Folder=$Folder&Object=$ObjectName"
                    Write-Verbose "NO SSL ENABLED, USING HTTP INSTEAD OF HTTPS"
                }
                else{
                    $uri = "https://$AIMServer/AIMWebService/api/accounts?AppID=$AppID&Safe=$SafeID&Folder=$Folder&Object=$ObjectName"
                    Write-Verbose "SSL ENABLED BY DEFAULT, USING HTTPS"
                }
                if([String]::IsNullOrEmpty($CertificateTP)){
                    $CCPResult = Invoke-RestMethod -Uri $uri
                }
                else{
                    $CCPResult = Invoke-RestMethod -Uri $uri -CertificateThumbprint $CertificateTP
                }

                $Secret = $CCPResult.Content
                if($Secret){
                    write-verbose "SECRET RETRIEVED SUCCESSFULLY"
                }
                else{
                    Write-VPASOutput -str "FAILED TO RETRIEVE SQL SECRET...PLEASE CONFIRM SQLConfigFile ($ConfigFile) CONTENT AND CCP FUNCTIONALITY" -type E
                    return $false
                }
            }catch{
                Write-VPASOutput -str "FAILED TO RETRIEVE SQL SECRET...PLEASE CONFIRM SQLConfigFile ($ConfigFile) CONTENT AND CCP FUNCTIONALITY" -type E
                Write-VPASOutput -str $_ -type E
                return $false
            }

        }
        elseif($AAM -eq "CP"){
            #CP
            $AppIDSplit = $AppIDTemp -split "="
            $AppID = $AppIDSplit[1]
            Write-Verbose "AppID = $AppID"

            $FolderSplit = $FolderTemp -split "="
            $Folder = $FolderSplit[1]
            Write-Verbose "Folder = $Folder"

            $SafeIDSplit = $SafeIDTemp -split "="
            $SafeID = $SafeIDSplit[1]
            Write-Verbose "SafeID = $SafeID"

            $ObjectNameSplit = $ObjectNameTemp -split "="
            $ObjectName = $ObjectNameSplit[1]
            Write-Verbose "ObjectName = $ObjectName"

            $PasswordSDKSplit = $PasswordSDKTemp -split "="
            $PasswordSDK = $PasswordSDKSplit[1]
            Write-Verbose "PasswordSDK = $PasswordSDK"

            try{
                $Secret = & "$PasswordSDK" GetPassword /p AppDescs.AppID=$AppID /p Query="Safe=$SafeID;Folder=$Folder;Object=$ObjectName" /o Password
                if($Secret){
                    write-verbose "RETRIEVED SECRET SUCCESSFULLY"
                }
                else{
                    Write-VPASOutput -str "FAILED TO RETRIEVE SQL SECRET...PLEASE CONFIRM SQLConfigFile ($ConfigFile) CONTENT AND CP FUNCTIONALITY" -type E
                    return $false
                }
            }catch{
                Write-VPASOutput -str "FAILED TO RETRIEVE SQL SECRET...PLEASE CONFIRM SQLConfigFile ($ConfigFile) CONTENT AND CP FUNCTIONALITY" -type E
                Write-VPASOutput -str $_ -type E
                return $false
            }

        }
        else{
            #NONE
            $SQLPasswordSplit = $SQLPasswordTemp -split "="
            $SQLPassword = $SQLPasswordSplit[1]
            $SecureString = ConvertTo-SecureString -String $SQLPassword
            $Pointer = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)
            $Secret = [Runtime.InteropServices.Marshal]::PtrToStringAuto($Pointer)
        }

        try{
            import-module sqlserver -ErrorAction Stop
        }catch{
            Write-VPASOutput -str "FAILED TO LOAD SQLServer MODULE..." -type E
            Write-VPASOutput -str $_ -type E
            Write-VPASOutput -str "FAILED TO FIND SQLServer MODULE IN THE FOLLOWING DIRECTORIES:" -type E

            $str = $env:PSModulePath -split ";"
            foreach($strsplit in $str){
                Write-VPASOutput -str $strsplit -type E
            }

            Write-VPASOutput -str "DOWNLOAD THE MODULE BY TYPING IN 'Install-Module -Name SqlServer' THEN RERUN VSetSQLConnectionDetails" -type E
            Write-VPASOutput -str "YOU CAN ALSO VIEW THIS LINK FOR MORE INFORMATION: 'https://www.powershellgallery.com/packages/SqlServer/21.1.18256'" -type E
            Write-VPASOutput -str "PROCESS TERMINATED" -type E
            return $false
        }

        try{
            $output = @()
            $result = Invoke-Sqlcmd -ServerInstance $SQLServer -Database $SQLDatabase -Query "SELECT DB_NAME()" -Username $SQLUsername -Password $Secret

            if($result.Column1 -eq $SQLDatabase){
                write-verbose "SQL CONNECTIVITY SUCCESSFUL"
            }
            else{
                Write-VPASOutput -str "FAILED TO CONNECT TO SQL DATABASE...PLEASE CONFIRM SQLConfigFile ($ConfigFile) CONTENT" -type E
                return $false
            }
        }catch{
            Write-VPASOutput -str "FAILED TO CONNECT TO SQL DATABASE...PLEASE CONFIRM SQLConfigFile ($ConfigFile) CONTENT" -type E
            Write-VPASOutput -str $_ -type E
            return $false
        }


        #DROP
        $TableName = "Vpas_Platform_Inventory"
        try{
            $query = "DROP TABLE $TableName"
            $result = Invoke-Sqlcmd -ServerInstance $SQLServer -Database $SQLDatabase -Query $query -Username $SQLUsername -Password $Secret -ErrorAction Stop
            Write-Verbose "$TableName DELETED SUCCESSFULLY"
        }catch{
            Write-Verbose "$TableName DOES NOT EXIST"
        }

        #CREATE
        try{
            $query = "CREATE TABLE $TableName ( ID varchar(255), Name varchar(255), SystemType varchar(255), Active varchar(255), Description varchar(255), PlatformBaseID varchar(255), PlatformType varchar(255), PropertiesRequired varchar(255), PropertiesOptional varchar(255), LinkedAccounts varchar(255), AllowedSafes varchar(255), AllowManualChange varchar(255), PerformPeriodicChange varchar(255), RequirePasswordChangeEveryXDays varchar(255), AllowManualVerification varchar(255), PerformPeriodicVerification varchar(255), RequirePasswordVerificationEveryXDays varchar(255), AllowManualReconciliation varchar(255), AutomaticReconcileWhenUnsynched varchar(255), RequirePrivilegedSessionMonitoringAndIsolation varchar(255), RecordAndSaveSessionActivity varchar(255), PSMServerID varchar(255), RequireDualControlPasswordAccessApproval varchar(255), EnforceCheckinCheckoutExclusiveAccess varchar(255), EnforceOnetimePasswordAccess varchar(255), ConnectionComponents varchar(255), SearchForUsages varchar(255), PolicyType varchar(255), ImmediateInterval varchar(255), Interval varchar(255), MaxConcurrentConnections varchar(255), MinValidityPeriod varchar(255), ResetOveridesMinValidity varchar(255), ResetOveridesTimeFrame varchar(255), Timeout varchar(255), UnlockIfFail varchar(255), UnrecoverableErrors varchar(255), MaximumRetries varchar(255), MinDelayBetweenRetries varchar(255), DllName varchar(255), XMLFile varchar(255), HeadStartInterval varchar(255), FromHour varchar(255), ToHour varchar(255), ChangeNotificationPeriod varchar(255), DaysNotifyPriorExpiration varchar(255), VFFromHour varchar(255), VFToHour varchar(255), RCReconcileReasons varchar(255), RCFromHour varchar(255), RCToHour varchar(255), NFNotifyPriorExpiration varchar(255), NFPriorExpirationRecipients varchar(255), NFNotifyOnPasswordDisable varchar(255), NFOnPasswordDisableRecipients varchar(255), NFNotifyOnVerificationErrors varchar(255), NFOnVerificationErrorsRecipients varchar(255), NFNotifyOnPasswordUsed varchar(255), NFOnPasswordUsedRecipients varchar(255), PasswordLength varchar(255), MinUpperCase varchar(255), MinLowerCase varchar(255), MinDigit varchar(255), MinSpecial varchar(255), PasswordLevelRequestTimeframe varchar(255) ); "
            $result = Invoke-Sqlcmd -ServerInstance $SQLServer -Database $SQLDatabase -Query $query -Username $SQLUsername -Password $Secret
            Write-Verbose "$TableName CREATED SUCCESSFULLY"
        }catch{
            Write-Verbose "FAILED TO CREATE $TableName"
            Write-VPASOutput -str "FAILED TO CREATE $TableName" -type E
            Write-VPASOutput -str $_ -type E
        }

        #START QUERYING
        try{
            if($NoSSL){
                $uri = "http://$PVWA/PasswordVault/API/Platforms"

                if($sessionval){
                    $result = Invoke-RestMethod -Headers @{"Authorization"=$Header} -Uri $uri -Method GET -ContentType "application/json" -WebSession $sessionval
                }
                else{
                    $result = Invoke-RestMethod -Headers @{"Authorization"=$Header} -Uri $uri -Method GET -ContentType "application/json"
                }
                $AllPlatforms = $result.Platforms
            }
            else{
                $uri = "https://$PVWA/PasswordVault/API/Platforms"

                if($sessionval){
                    $result = Invoke-RestMethod -Headers @{"Authorization"=$Header} -Uri $uri -Method GET -ContentType "application/json" -WebSession $sessionval
                }
                else{
                    $result = Invoke-RestMethod -Headers @{"Authorization"=$Header} -Uri $uri -Method GET -ContentType "application/json"
                }
                $AllPlatforms = $result.Platforms
            }

            $Data = @{}
            $counter = 1
            foreach($platform in $AllPlatforms){
                $temparr = @{}
                $PFGeneralID = $platform.general.id
                $PFGeneralName = $platform.general.name
                $PFGeneralSystemType = $platform.general.systemType
                $PFGeneralActive = $platform.general.active
                $PFGeneralDescription = $platform.general.description
                $PFGeneralPlatformBaseID = $platform.general.platformBaseID
                $PFGeneralPlatformType = $platform.general.platformType

                $str = ""
                $PFPropertiesRequiredTemp = $platform.properties.required
                foreach($rec in $PFPropertiesRequiredTemp){
                    $testval = $rec.name
                    if([String]::IsNullOrEmpty($testval)){
                        $testval = $rec.displayName
                    }
                    $str += $testval + ";"
                }
                $PFPropertiesRequired = $str

                $str = ""
                $PFPropertiesOptionalTemp = $platform.properties.optional
                foreach($rec in $PFPropertiesOptionalTemp){
                    $testval = $rec.name
                    if([String]::IsNullOrEmpty($testval)){
                        $testval = $rec.displayName
                    }
                    $str += $testval + ";"
                }
                $PFPropertiesOptional = $str

                $str = ""
                $PFLinkedAccountsTemp = $platform.linkedAccounts
                foreach($rec in $PFLinkedAccountsTemp){
                    $testval = $rec.name
                    if([String]::IsNullOrEmpty($testval)){
                        $testval = $rec.displayName
                    }
                    $str += $testval + ";"
                }
                $PFLinkedAccounts = $str

                $PFCredentialsManagementAllowedSafes = $platform.credentialsManagement.allowedSafes
                $PFCredentialsManagementAllowManualChange = $platform.credentialsManagement.allowManualChange
                $PFCredentialsManagementPerformPeriodicChange = $platform.credentialsManagement.performPeriodicChange
                $PFCredentialsManagementRequirePasswordChangeEveryXDays = $platform.credentialsManagement.requirePasswordChangeEveryXDays
                $PFCredentialsManagementAllowManualVerification = $platform.credentialsManagement.allowManualVerification
                $PFCredentialsManagementPerformPeriodicVerification = $platform.credentialsManagement.performPeriodicVerification
                $PFCredentialsManagementRequirePasswordVerificationEveryXDays = $platform.credentialsManagement.requirePasswordVerificationEveryXDays
                $PFCredentialsManagementAllowManualReconciliation = $platform.credentialsManagement.allowManualReconciliation
                $PFCredentialsManagementAutomaticReconcileWhenUnsynched = $platform.credentialsManagement.automaticReconcileWhenUnsynched

                $PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation = $platform.sessionManagement.requirePrivilegedSessionMonitoringAndIsolation
                $PFSessionManagementRecordAndSaveSessionActivity = $platform.sessionManagement.recordAndSaveSessionActivity
                $PFSessionManagementPSMServerID = $platform.sessionManagement.PSMServerID

                $PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval = $platform.privilegedAccessWorkflows.requireDualControlPasswordAccessApproval
                $PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess = $platform.privilegedAccessWorkflows.enforceCheckinCheckoutExclusiveAccess
                $PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess = $platform.privilegedAccessWorkflows.enforceOnetimePasswordAccess
                $PFConnectionComponents = ""

                if($NoSSL){
                    $response2 = Get-VPASPSMSettingsByPlatformID -token $token -PlatformID $PFGeneralID
                }
                else{
                    $response2 = Get-VPASPSMSettingsByPlatformID -token $token -PlatformID $PFGeneralID
                }

                $AllConnectionComponents = $response2.PSMConnectors
                foreach($cc in $AllConnectionComponents){
                    $ccName = $cc.PSMConnectorID
                    $ccStatus = $cc.Enabled

                    if($ccStatus.ToString() -eq "True"){
                        $PFConnectionComponents += "$ccName(ACTIVE);"
                    }
                    else{
                        $PFConnectionComponents += "$ccName(DISABLED);"
                    }
                }

                #GET OTHER HALF OF PLATFORM PROPERTIES
                $PFSearchForUsages = ""
                $PFPolicyType = ""
                $PFImmediateInterval = ""
                $PFInterval = ""
                $PFMaxConcurrentConnections = ""
                $PFMinValidityPeriod = ""
                $PFResetOveridesMinValidity = ""
                $PFResetOveridesTimeFrame = ""
                $PFTimeout = ""
                $PFUnlockIfFail = ""
                $PFUnrecoverableErrors = ""
                $PFMaximumRetries = ""
                $PFMinDelayBetweenRetries = ""
                $PFDllName = ""
                $PFXMLFile = ""
                $PFHeadStartInterval = ""
                $PFFromHour = ""
                $PFToHour = ""
                $PFChangeNotificationPeriod = ""
                $PFDaysNotifyPriorExpiration = ""
                $PFVFFromHour = ""
                $PFVFToHour = ""
                $PFRCReconcileReasons = ""
                $PFRCFromHour = ""
                $PFRCToHour = ""
                $PFNFNotifyPriorExpiration = ""
                $PFNFPriorExpirationRecipients = ""
                $PFNFNotifyOnPasswordDisable = ""
                $PFNFOnPasswordDisableRecipients = ""
                $PFNFNotifyOnVerificationErrors = ""
                $PFNFOnVerificationErrorsRecipients = ""
                $PFNFNotifyOnPasswordUsed = ""
                $PFNFOnPasswordUsedRecipients = ""
                $PFPasswordLength = ""
                $PFMinUpperCase = ""
                $PFMinLowerCase = ""
                $PFMinDigit = ""
                $PFMinSpecial = ""
                $PFPasswordLevelRequestTimeframe = ""

                $MoreDetails = Get-VPASPlatformDetails -platformID $PFGeneralID -token $token
                if($MoreDetails){
                    $PFSearchForUsages = $MoreDetails.details.SearchForUsages
                    $PFPolicyType = $MoreDetails.details.PolicyType
                    $PFImmediateInterval = $MoreDetails.details.ImmediateInterval
                    $PFInterval = $MoreDetails.details.Interval
                    $PFMaxConcurrentConnections = $MoreDetails.details.MaxConcurrentConnections
                    $PFMinValidityPeriod = $MoreDetails.details.MinValidityPeriod
                    $PFResetOveridesMinValidity = $MoreDetails.details.ResetOveridesMinValidity
                    $PFResetOveridesTimeFrame = $MoreDetails.details.ResetOveridesTimeFrame
                    $PFTimeout = $MoreDetails.details.Timeout
                    $PFUnlockIfFail = $MoreDetails.details.UnlockIfFail
                    $PFUnrecoverableErrors = $MoreDetails.details.UnrecoverableErrors
                    $PFMaximumRetries = $MoreDetails.details.MaximumRetries
                    $PFMinDelayBetweenRetries = $MoreDetails.details.MinDelayBetweenRetries
                    $PFDllName = $MoreDetails.details.DllName
                    $PFXMLFile = $MoreDetails.details.XMLFile
                    $PFHeadStartInterval = $MoreDetails.details.HeadStartInterval
                    $PFFromHour = $MoreDetails.details.FromHour
                    $PFToHour = $MoreDetails.details.ToHour
                    $PFChangeNotificationPeriod = $MoreDetails.details.ChangeNotificationPeriod
                    $PFDaysNotifyPriorExpiration = $MoreDetails.details.DaysNotifyPriorExpiration
                    $PFVFFromHour = $MoreDetails.details.VFFromHour
                    $PFVFToHour = $MoreDetails.details.VFToHour
                    $PFRCReconcileReasons = $MoreDetails.details.RCReconcileReasons
                    $PFRCFromHour = $MoreDetails.details.RCFromHour
                    $PFRCToHour = $MoreDetails.details.RCToHour
                    $PFNFNotifyPriorExpiration = $MoreDetails.details.NFNotifyPriorExpiration
                    $PFNFPriorExpirationRecipients = $MoreDetails.details.NFPriorExpirationRecipients
                    $PFNFNotifyOnPasswordDisable = $MoreDetails.details.NFNotifyOnPasswordDisable
                    $PFNFOnPasswordDisableRecipients = $MoreDetails.details.NFOnPasswordDisableRecipients
                    $PFNFNotifyOnVerificationErrors = $MoreDetails.details.NFNotifyOnVerificationErrors
                    $PFNFOnVerificationErrorsRecipients = $MoreDetails.details.NFOnVerificationErrorsRecipients
                    $PFNFNotifyOnPasswordUsed = $MoreDetails.details.NFNotifyOnPasswordUsed
                    $PFNFOnPasswordUsedRecipients = $MoreDetails.details.NFOnPasswordUsedRecipients
                    $PFPasswordLength = $MoreDetails.details.PasswordLength
                    $PFMinUpperCase = $MoreDetails.details.MinUpperCase
                    $PFMinLowerCase = $MoreDetails.details.MinLowerCase
                    $PFMinDigit = $MoreDetails.details.MinDigit
                    $PFMinSpecial = $MoreDetails.details.MinSpecial
                    $PFPasswordLevelRequestTimeframe = $MoreDetails.details.PasswordLevelRequestTimeframe
                }

                if([String]::IsNullOrEmpty($PFGeneralID)){ $PFGeneralID = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralName)){ $PFGeneralName = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralSystemType)){ $PFGeneralSystemType = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralActive)){ $PFGeneralActive = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralDescription)){ $PFGeneralDescription = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralPlatformBaseID)){ $PFGeneralPlatformBaseID = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralPlatformType)){ $PFGeneralPlatformType = "NULL" }
                if([String]::IsNullOrEmpty($PFPropertiesRequired)){ $PFPropertiesRequired = "NULL" }
                if([String]::IsNullOrEmpty($PFPropertiesOptional)){ $PFPropertiesOptional = "NULL" }
                if([String]::IsNullOrEmpty($PFLinkedAccounts)){ $PFLinkedAccounts = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAllowedSafes)){ $PFCredentialsManagementAllowedSafes = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAllowManualChange)){ $PFCredentialsManagementAllowManualChange = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementPerformPeriodicChange)){ $PFCredentialsManagementPerformPeriodicChange = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementRequirePasswordChangeEveryXDays)){ $PFCredentialsManagementRequirePasswordChangeEveryXDays = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAllowManualVerification)){ $PFCredentialsManagementAllowManualVerification = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementPerformPeriodicVerification)){ $PFCredentialsManagementPerformPeriodicVerification = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementRequirePasswordVerificationEveryXDays)){ $PFCredentialsManagementRequirePasswordVerificationEveryXDays = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAllowManualReconciliation)){ $PFCredentialsManagementAllowManualReconciliation = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAutomaticReconcileWhenUnsynched)){ $PFCredentialsManagementAutomaticReconcileWhenUnsynched = "NULL" }
                if([String]::IsNullOrEmpty($PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation)){ $PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation = "NULL" }
                if([String]::IsNullOrEmpty($PFSessionManagementRecordAndSaveSessionActivity)){ $PFSessionManagementRecordAndSaveSessionActivity = "NULL" }
                if([String]::IsNullOrEmpty($PFSessionManagementPSMServerID)){ $PFSessionManagementPSMServerID = "NULL" }
                if([String]::IsNullOrEmpty($PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval)){ $PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval = "NULL" }
                if([String]::IsNullOrEmpty($PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess)){ $PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess = "NULL" }
                if([String]::IsNullOrEmpty($PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess)){ $PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess = "NULL" }
                if([String]::IsNullOrEmpty($PFConnectionComponents)){ $PFConnectionComponents = "NULL" }
                if([String]::IsNullOrEmpty($PFSearchForUsages)){ $PFSearchForUsages = "NULL" }
                if([String]::IsNullOrEmpty($PFPolicyType)){ $PFPolicyType = "NULL" }
                if([String]::IsNullOrEmpty($PFImmediateInterval)){ $PFImmediateInterval = "NULL" }
                if([String]::IsNullOrEmpty($PFInterval)){ $PFInterval = "NULL" }
                if([String]::IsNullOrEmpty($PFMaxConcurrentConnections)){ $PFMaxConcurrentConnections = "NULL" }
                if([String]::IsNullOrEmpty($PFMinValidityPeriod)){ $PFMinValidityPeriod = "NULL" }
                if([String]::IsNullOrEmpty($PFResetOveridesMinValidity)){ $PFResetOveridesMinValidity = "NULL" }
                if([String]::IsNullOrEmpty($PFResetOveridesTimeFrame)){ $PFResetOveridesTimeFrame = "NULL" }
                if([String]::IsNullOrEmpty($PFTimeout)){ $PFTimeout = "NULL" }
                if([String]::IsNullOrEmpty($PFUnlockIfFail)){ $PFUnlockIfFail = "NULL" }
                if([String]::IsNullOrEmpty($PFUnrecoverableErrors)){ $PFUnrecoverableErrors = "NULL" }
                if([String]::IsNullOrEmpty($PFMaximumRetries)){ $PFMaximumRetries = "NULL" }
                if([String]::IsNullOrEmpty($PFMinDelayBetweenRetries)){ $PFMinDelayBetweenRetries = "NULL" }
                if([String]::IsNullOrEmpty($PFDllName)){ $PFDllName = "NULL" }
                if([String]::IsNullOrEmpty($PFXMLFile)){ $PFXMLFile = "NULL" }
                if([String]::IsNullOrEmpty($PFHeadStartInterval)){ $PFHeadStartInterval = "NULL" }
                if([String]::IsNullOrEmpty($PFFromHour)){ $PFFromHour = "NULL" }
                if([String]::IsNullOrEmpty($PFToHour)){ $PFToHour = "NULL" }
                if([String]::IsNullOrEmpty($PFChangeNotificationPeriod)){ $PFChangeNotificationPeriod = "NULL" }
                if([String]::IsNullOrEmpty($PFDaysNotifyPriorExpiration)){ $PFDaysNotifyPriorExpiration = "NULL" }
                if([String]::IsNullOrEmpty($PFVFFromHour)){ $PFVFFromHour = "NULL" }
                if([String]::IsNullOrEmpty($PFVFToHour)){ $PFVFToHour = "NULL" }
                if([String]::IsNullOrEmpty($PFRCReconcileReasons)){ $PFRCReconcileReasons = "NULL" }
                if([String]::IsNullOrEmpty($PFRCFromHour)){ $PFRCFromHour = "NULL" }
                if([String]::IsNullOrEmpty($PFRCToHour)){ $PFRCToHour = "NULL" }
                if([String]::IsNullOrEmpty($PFNFNotifyPriorExpiration)){ $PFNFNotifyPriorExpiration = "NULL" }
                if([String]::IsNullOrEmpty($PFNFPriorExpirationRecipients)){ $PFNFPriorExpirationRecipients = "NULL" }
                if([String]::IsNullOrEmpty($PFNFNotifyOnPasswordDisable)){ $PFNFNotifyOnPasswordDisable = "NULL" }
                if([String]::IsNullOrEmpty($PFNFOnPasswordDisableRecipients)){ $PFNFOnPasswordDisableRecipients = "NULL" }
                if([String]::IsNullOrEmpty($PFNFNotifyOnVerificationErrors)){ $PFNFNotifyOnVerificationErrors = "NULL" }
                if([String]::IsNullOrEmpty($PFNFOnVerificationErrorsRecipients)){ $PFNFOnVerificationErrorsRecipients = "NULL" }
                if([String]::IsNullOrEmpty($PFNFNotifyOnPasswordUsed)){ $PFNFNotifyOnPasswordUsed = "NULL" }
                if([String]::IsNullOrEmpty($PFNFOnPasswordUsedRecipients)){ $PFNFOnPasswordUsedRecipients = "NULL" }
                if([String]::IsNullOrEmpty($PFPasswordLength)){ $PFPasswordLength = "NULL" }
                if([String]::IsNullOrEmpty($PFMinUpperCase)){ $PFMinUpperCase = "NULL" }
                if([String]::IsNullOrEmpty($PFMinLowerCase)){ $PFMinLowerCase = "NULL" }
                if([String]::IsNullOrEmpty($PFMinDigit)){ $PFMinDigit = "NULL" }
                if([String]::IsNullOrEmpty($PFMinSpecial)){ $PFMinSpecial = "NULL" }
                if([String]::IsNullOrEmpty($PFPasswordLevelRequestTimeframe)){ $PFPasswordLevelRequestTimeframe = "NULL" }

                $PFGeneralID = $PFGeneralID -replace "'","''"
                $PFGeneralName = $PFGeneralName -replace "'","''"
                $PFGeneralSystemType = $PFGeneralSystemType -replace "'","''"
                $PFGeneralActive = $PFGeneralActive -replace "'","''"
                $PFGeneralDescription = $PFGeneralDescription -replace "'","''"
                $PFGeneralPlatformBaseID = $PFGeneralPlatformBaseID -replace "'","''"
                $PFGeneralPlatformType = $PFGeneralPlatformType -replace "'","''"
                $PFPropertiesRequired = $PFPropertiesRequired -replace "'","''"
                $PFPropertiesOptional = $PFPropertiesOptional -replace "'","''"
                $PFLinkedAccounts = $PFLinkedAccounts -replace "'","''"
                $PFCredentialsManagementAllowedSafes = $PFCredentialsManagementAllowedSafes -replace "'","''"
                $PFCredentialsManagementAllowManualChange = $PFCredentialsManagementAllowManualChange -replace "'","''"
                $PFCredentialsManagementPerformPeriodicChange = $PFCredentialsManagementPerformPeriodicChange -replace "'","''"
                $PFCredentialsManagementRequirePasswordChangeEveryXDays = $PFCredentialsManagementRequirePasswordChangeEveryXDays -replace "'","''"
                $PFCredentialsManagementAllowManualVerification = $PFCredentialsManagementAllowManualVerification -replace "'","''"
                $PFCredentialsManagementPerformPeriodicVerification = $PFCredentialsManagementPerformPeriodicVerification -replace "'","''"
                $PFCredentialsManagementRequirePasswordVerificationEveryXDays = $PFCredentialsManagementRequirePasswordVerificationEveryXDays -replace "'","''"
                $PFCredentialsManagementAllowManualReconciliation = $PFCredentialsManagementAllowManualReconciliation -replace "'","''"
                $PFCredentialsManagementAutomaticReconcileWhenUnsynched = $PFCredentialsManagementAutomaticReconcileWhenUnsynched -replace "'","''"
                $PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation = $PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation -replace "'","''"
                $PFSessionManagementRecordAndSaveSessionActivity = $PFSessionManagementRecordAndSaveSessionActivity -replace "'","''"
                $PFSessionManagementPSMServerID = $PFSessionManagementPSMServerID -replace "'","''"
                $PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval = $PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval -replace "'","''"
                $PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess = $PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess -replace "'","''"
                $PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess = $PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess -replace "'","''"
                $PFConnectionComponents = $PFConnectionComponents -replace "'","''"
                $PFSearchForUsages = $PFSearchForUsages -replace "'","''"
                $PFPolicyType = $PFPolicyType -replace "'","''"
                $PFImmediateInterval = $PFImmediateInterval -replace "'","''"
                $PFInterval = $PFInterval -replace "'","''"
                $PFMaxConcurrentConnections = $PFMaxConcurrentConnections -replace "'","''"
                $PFMinValidityPeriod = $PFMinValidityPeriod -replace "'","''"
                $PFResetOveridesMinValidity = $PFResetOveridesMinValidity -replace "'","''"
                $PFResetOveridesTimeFrame = $PFResetOveridesTimeFrame -replace "'","''"
                $PFTimeout = $PFTimeout -replace "'","''"
                $PFUnlockIfFail = $PFUnlockIfFail -replace "'","''"
                $PFUnrecoverableErrors = $PFUnrecoverableErrors -replace "'","''"
                $PFMaximumRetries = $PFMaximumRetries -replace "'","''"
                $PFMinDelayBetweenRetries = $PFMinDelayBetweenRetries -replace "'","''"
                $PFDllName = $PFDllName -replace "'","''"
                $PFXMLFile = $PFXMLFile -replace "'","''"
                $PFHeadStartInterval = $PFHeadStartInterval -replace "'","''"
                $PFFromHour = $PFFromHour -replace "'","''"
                $PFToHour = $PFToHour -replace "'","''"
                $PFChangeNotificationPeriod = $PFChangeNotificationPeriod -replace "'","''"
                $PFDaysNotifyPriorExpiration = $PFDaysNotifyPriorExpiration -replace "'","''"
                $PFVFFromHour = $PFVFFromHour -replace "'","''"
                $PFVFToHour = $PFVFToHour -replace "'","''"
                $PFRCReconcileReasons = $PFRCReconcileReasons -replace "'","''"
                $PFRCFromHour = $PFRCFromHour -replace "'","''"
                $PFRCToHour = $PFRCToHour -replace "'","''"
                $PFNFNotifyPriorExpiration = $PFNFNotifyPriorExpiration -replace "'","''"
                $PFNFPriorExpirationRecipients = $PFNFPriorExpirationRecipients -replace "'","''"
                $PFNFNotifyOnPasswordDisable = $PFNFNotifyOnPasswordDisable -replace "'","''"
                $PFNFOnPasswordDisableRecipients = $PFNFOnPasswordDisableRecipients -replace "'","''"
                $PFNFNotifyOnVerificationErrors = $PFNFNotifyOnVerificationErrors -replace "'","''"
                $PFNFOnVerificationErrorsRecipients = $PFNFOnVerificationErrorsRecipients -replace "'","''"
                $PFNFNotifyOnPasswordUsed = $PFNFNotifyOnPasswordUsed -replace "'","''"
                $PFNFOnPasswordUsedRecipients = $PFNFOnPasswordUsedRecipients -replace "'","''"
                $PFPasswordLength = $PFPasswordLength -replace "'","''"
                $PFMinUpperCase = $PFMinUpperCase -replace "'","''"
                $PFMinLowerCase = $PFMinLowerCase -replace "'","''"
                $PFMinDigit = $PFMinDigit -replace "'","''"
                $PFMinSpecial = $PFMinSpecial -replace "'","''"
                $PFPasswordLevelRequestTimeframe = $PFPasswordLevelRequestTimeframe -replace "'","''"

                try{
                    $query = "INSERT INTO $TableName ( ID, Name, SystemType, Active, Description, PlatformBaseID, PlatformType, PropertiesRequired, PropertiesOptional, LinkedAccounts, AllowedSafes, AllowManualChange, PerformPeriodicChange, RequirePasswordChangeEveryXDays, AllowManualVerification, PerformPeriodicVerification, RequirePasswordVerificationEveryXDays, AllowManualReconciliation, AutomaticReconcileWhenUnsynched, RequirePrivilegedSessionMonitoringAndIsolation, RecordAndSaveSessionActivity, PSMServerID, RequireDualControlPasswordAccessApproval, EnforceCheckinCheckoutExclusiveAccess, EnforceOnetimePasswordAccess, ConnectionComponents, SearchForUsages, PolicyType, ImmediateInterval, Interval, MaxConcurrentConnections, MinValidityPeriod, ResetOveridesMinValidity, ResetOveridesTimeFrame, Timeout, UnlockIfFail, UnrecoverableErrors, MaximumRetries, MinDelayBetweenRetries, DllName, XMLFile, HeadStartInterval, FromHour, ToHour, ChangeNotificationPeriod, DaysNotifyPriorExpiration, VFFromHour, VFToHour, RCReconcileReasons, RCFromHour, RCToHour, NFNotifyPriorExpiration, NFPriorExpirationRecipients, NFNotifyOnPasswordDisable, NFOnPasswordDisableRecipients, NFNotifyOnVerificationErrors, NFOnVerificationErrorsRecipients, NFNotifyOnPasswordUsed, NFOnPasswordUsedRecipients, PasswordLength, MinUpperCase, MinLowerCase, MinDigit, MinSpecial, PasswordLevelRequestTimeframe ) VALUES ( '$PFGeneralID', '$PFGeneralName', '$PFGeneralSystemType', '$PFGeneralActive', '$PFGeneralDescription', '$PFGeneralPlatformBaseID', '$PFGeneralPlatformType', '$PFPropertiesRequired', '$PFPropertiesOptional', '$PFLinkedAccounts', '$PFCredentialsManagementAllowedSafes', '$PFCredentialsManagementAllowManualChange', '$PFCredentialsManagementPerformPeriodicChange', '$PFCredentialsManagementRequirePasswordChangeEveryXDays', '$PFCredentialsManagementAllowManualVerification', '$PFCredentialsManagementPerformPeriodicVerification', '$PFCredentialsManagementRequirePasswordVerificationEveryXDays', '$PFCredentialsManagementAllowManualReconciliation', '$PFCredentialsManagementAutomaticReconcileWhenUnsynched', '$PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation', '$PFSessionManagementRecordAndSaveSessionActivity', '$PFSessionManagementPSMServerID', '$PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval', '$PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess', '$PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess', '$PFConnectionComponents', '$PFSearchForUsages', '$PFPolicyType', '$PFImmediateInterval', '$PFInterval', '$PFMaxConcurrentConnections', '$PFMinValidityPeriod', '$PFResetOveridesMinValidity', '$PFResetOveridesTimeFrame', '$PFTimeout', '$PFUnlockIfFail', '$PFUnrecoverableErrors', '$PFMaximumRetries', '$PFMinDelayBetweenRetries', '$PFDllName', '$PFXMLFile', '$PFHeadStartInterval', '$PFFromHour', '$PFToHour', '$PFChangeNotificationPeriod', '$PFDaysNotifyPriorExpiration', '$PFVFFromHour', '$PFVFToHour', '$PFRCReconcileReasons', '$PFRCFromHour', '$PFRCToHour', '$PFNFNotifyPriorExpiration', '$PFNFPriorExpirationRecipients', '$PFNFNotifyOnPasswordDisable', '$PFNFOnPasswordDisableRecipients', '$PFNFNotifyOnVerificationErrors', '$PFNFOnVerificationErrorsRecipients', '$PFNFNotifyOnPasswordUsed', '$PFNFOnPasswordUsedRecipients', '$PFPasswordLength', '$PFMinUpperCase', '$PFMinLowerCase', '$PFMinDigit', '$PFMinSpecial', '$PFPasswordLevelRequestTimeframe' );"
                    $UpdateRec = Invoke-Sqlcmd -ServerInstance $SQLServer -Database $SQLDatabase -Query $query -Username $SQLUsername -Password $Secret
                    Write-Verbose "ADDED RECORD INTO $TableName FOR PLATFORMID: $PFPlatformID"
                }catch{
                    Write-Verbose "FAILED TO ADD RECORD INTO $TableName FOR PLATFORMID: $PFPlatformID"
                    Write-VPASOutput -str "FAILED TO ADD RECORD INTO $TableName FOR PLATFORMID: $PFPlatformID" -type E
                    Write-VPASOutput -str $_ -type E
                }
            }
        }catch{
            Write-Verbose "GET ALL PLATFORMS API FAILED: $_"
            Write-Verbose "RUNNING Get-VPASAllTargetPlatforms INSTEAD"
            Write-VPASOutput -str "FAILED TO GET ALL PLATFORMS, RUNNING Get-VPASAllTargetPlatforms INSTEAD" -type M
            Write-VPASOutput -str "KEEP IN MIND THE RETURN JSON SYNTAX DIFFERS FOR Get-VPASAllTargetPlatforms" -type M

            if($NoSSL){
                $uri = "http://$PVWA/PasswordVault/API/Platforms/targets"

                if($sessionval){
                    $result = Invoke-RestMethod -Headers @{"Authorization"=$Header} -Uri $uri -Method GET -ContentType "application/json" -WebSession $sessionval
                }
                else{
                    $result = Invoke-RestMethod -Headers @{"Authorization"=$Header} -Uri $uri -Method GET -ContentType "application/json"
                }
                $AllPlatforms = $result.Platforms
            }
            else{
                $uri = "https://$PVWA/PasswordVault/API/Platforms/targets"

                if($sessionval){
                    $result = Invoke-RestMethod -Headers @{"Authorization"=$Header} -Uri $uri -Method GET -ContentType "application/json" -WebSession $sessionval
                }
                else{
                    $result = Invoke-RestMethod -Headers @{"Authorization"=$Header} -Uri $uri -Method GET -ContentType "application/json"
                }
                $AllPlatforms = $result.Platforms
            }

            $Data = @{}
            $counter = 1
            foreach($platform in $AllPlatforms){
                $temparr = @{}
                $PFGeneralID = $platform.PlatformID
                $PFGeneralName = $platform.Name
                $PFGeneralSystemType = $platform.SystemType
                $PFGeneralActive = $platform.Active
                $PFGeneralDescription = ""
                $PFGeneralPlatformBaseID = $platform.PlatformBaseID
                $PFGeneralPlatformType = $platform.PlatformBaseType

                $str = ""
                $PFPropertiesRequiredTemp = $platform.properties.required
                foreach($rec in $PFPropertiesRequiredTemp){
                    $testval = $rec.name
                    if([String]::IsNullOrEmpty($testval)){
                        $testval = $rec.displayName
                    }
                    $str += $testval + ";"
                }
                $PFPropertiesRequired = $str

                $str = ""
                $PFPropertiesOptionalTemp = $platform.properties.optional
                foreach($rec in $PFPropertiesOptionalTemp){
                    $testval = $rec.name
                    if([String]::IsNullOrEmpty($testval)){
                        $testval = $rec.displayName
                    }
                    $str += $testval + ";"
                }
                $PFPropertiesOptional = $str

                $str = ""
                $PFLinkedAccountsTemp = $platform.linkedAccounts
                foreach($rec in $PFLinkedAccountsTemp){
                    $testval = $rec.name
                    if([String]::IsNullOrEmpty($testval)){
                        $testval = $rec.displayName
                    }
                    $str += $testval + ";"
                }
                $PFLinkedAccounts = $str

                $PFCredentialsManagementAllowedSafes = $platform.AllowedSafes
                $PFCredentialsManagementAllowManualChange = $platform.CredentialsManagementPolicy.Change.AllowManual
                $PFCredentialsManagementPerformPeriodicChange = $platform.CredentialsManagementPolicy.Change.PerformAutomatic
                $PFCredentialsManagementRequirePasswordChangeEveryXDays = $platform.CredentialsManagementPolicy.Change.RequirePasswordEveryXDays
                $PFCredentialsManagementAllowManualVerification = $platform.CredentialsManagementPolicy.Verification.AllowManual
                $PFCredentialsManagementPerformPeriodicVerification = $platform.CredentialsManagementPolicy.Verification.PerformAutomatic
                $PFCredentialsManagementRequirePasswordVerificationEveryXDays = $platform.CredentialsManagementPolicy.Verification.RequirePasswordEveryXDays
                $PFCredentialsManagementAllowManualReconciliation = $platform.CredentialsManagementPolicy.Reconcile.AllowManual
                $PFCredentialsManagementAutomaticReconcileWhenUnsynched = $platform.CredentialsManagementPolicy.Reconcile.AutomaticReconcileWhenUnsynced
                $PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation = ""
                $PFSessionManagementRecordAndSaveSessionActivity = ""
                $PFSessionManagementPSMServerID = ""
                $PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval = $platform.privilegedAccessWorkflows.RequireDualControlPasswordAccessApproval.IsActive
                $PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess = $platform.privilegedAccessWorkflows.EnforceCheckinCheckoutExclusiveAccess.IsActive
                $PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess = $platform.privilegedAccessWorkflows.EnforceOnetimePasswordAccess.IsActive
                $PFConnectionComponents = ""

                if($NoSSL){
                    $response2 = Get-VPASPSMSettingsByPlatformID -token $token -PlatformID $PFGeneralID
                }
                else{
                    $response2 = Get-VPASPSMSettingsByPlatformID -token $token -PlatformID $PFGeneralID
                }

                $AllConnectionComponents = $response2.PSMConnectors
                foreach($cc in $AllConnectionComponents){
                    $ccName = $cc.PSMConnectorID
                    $ccStatus = $cc.Enabled

                    if($ccStatus.ToString() -eq "True"){
                        $PFConnectionComponents += "$ccName(ACTIVE);"
                    }
                    else{
                        $PFConnectionComponents += "$ccName(DISABLED);"
                    }
                }

                #GET OTHER HALF OF PLATFORM PROPERTIES
                $PFSearchForUsages = ""
                $PFPolicyType = ""
                $PFImmediateInterval = ""
                $PFInterval = ""
                $PFMaxConcurrentConnections = ""
                $PFMinValidityPeriod = ""
                $PFResetOveridesMinValidity = ""
                $PFResetOveridesTimeFrame = ""
                $PFTimeout = ""
                $PFUnlockIfFail = ""
                $PFUnrecoverableErrors = ""
                $PFMaximumRetries = ""
                $PFMinDelayBetweenRetries = ""
                $PFDllName = ""
                $PFXMLFile = ""
                $PFHeadStartInterval = ""
                $PFFromHour = ""
                $PFToHour = ""
                $PFChangeNotificationPeriod = ""
                $PFDaysNotifyPriorExpiration = ""
                $PFVFFromHour = ""
                $PFVFToHour = ""
                $PFRCReconcileReasons = ""
                $PFRCFromHour = ""
                $PFRCToHour = ""
                $PFNFNotifyPriorExpiration = ""
                $PFNFPriorExpirationRecipients = ""
                $PFNFNotifyOnPasswordDisable = ""
                $PFNFOnPasswordDisableRecipients = ""
                $PFNFNotifyOnVerificationErrors = ""
                $PFNFOnVerificationErrorsRecipients = ""
                $PFNFNotifyOnPasswordUsed = ""
                $PFNFOnPasswordUsedRecipients = ""
                $PFPasswordLength = ""
                $PFMinUpperCase = ""
                $PFMinLowerCase = ""
                $PFMinDigit = ""
                $PFMinSpecial = ""
                $PFPasswordLevelRequestTimeframe = ""

                $MoreDetails = Get-VPASPlatformDetails -platformID $PFGeneralID -token $token
                if($MoreDetails){
                    $PFSearchForUsages = $MoreDetails.details.SearchForUsages
                    $PFPolicyType = $MoreDetails.details.PolicyType
                    $PFImmediateInterval = $MoreDetails.details.ImmediateInterval
                    $PFInterval = $MoreDetails.details.Interval
                    $PFMaxConcurrentConnections = $MoreDetails.details.MaxConcurrentConnections
                    $PFMinValidityPeriod = $MoreDetails.details.MinValidityPeriod
                    $PFResetOveridesMinValidity = $MoreDetails.details.ResetOveridesMinValidity
                    $PFResetOveridesTimeFrame = $MoreDetails.details.ResetOveridesTimeFrame
                    $PFTimeout = $MoreDetails.details.Timeout
                    $PFUnlockIfFail = $MoreDetails.details.UnlockIfFail
                    $PFUnrecoverableErrors = $MoreDetails.details.UnrecoverableErrors
                    $PFMaximumRetries = $MoreDetails.details.MaximumRetries
                    $PFMinDelayBetweenRetries = $MoreDetails.details.MinDelayBetweenRetries
                    $PFDllName = $MoreDetails.details.DllName
                    $PFXMLFile = $MoreDetails.details.XMLFile
                    $PFHeadStartInterval = $MoreDetails.details.HeadStartInterval
                    $PFFromHour = $MoreDetails.details.FromHour
                    $PFToHour = $MoreDetails.details.ToHour
                    $PFChangeNotificationPeriod = $MoreDetails.details.ChangeNotificationPeriod
                    $PFDaysNotifyPriorExpiration = $MoreDetails.details.DaysNotifyPriorExpiration
                    $PFVFFromHour = $MoreDetails.details.VFFromHour
                    $PFVFToHour = $MoreDetails.details.VFToHour
                    $PFRCReconcileReasons = $MoreDetails.details.RCReconcileReasons
                    $PFRCFromHour = $MoreDetails.details.RCFromHour
                    $PFRCToHour = $MoreDetails.details.RCToHour
                    $PFNFNotifyPriorExpiration = $MoreDetails.details.NFNotifyPriorExpiration
                    $PFNFPriorExpirationRecipients = $MoreDetails.details.NFPriorExpirationRecipients
                    $PFNFNotifyOnPasswordDisable = $MoreDetails.details.NFNotifyOnPasswordDisable
                    $PFNFOnPasswordDisableRecipients = $MoreDetails.details.NFOnPasswordDisableRecipients
                    $PFNFNotifyOnVerificationErrors = $MoreDetails.details.NFNotifyOnVerificationErrors
                    $PFNFOnVerificationErrorsRecipients = $MoreDetails.details.NFOnVerificationErrorsRecipients
                    $PFNFNotifyOnPasswordUsed = $MoreDetails.details.NFNotifyOnPasswordUsed
                    $PFNFOnPasswordUsedRecipients = $MoreDetails.details.NFOnPasswordUsedRecipients
                    $PFPasswordLength = $MoreDetails.details.PasswordLength
                    $PFMinUpperCase = $MoreDetails.details.MinUpperCase
                    $PFMinLowerCase = $MoreDetails.details.MinLowerCase
                    $PFMinDigit = $MoreDetails.details.MinDigit
                    $PFMinSpecial = $MoreDetails.details.MinSpecial
                    $PFPasswordLevelRequestTimeframe = $MoreDetails.details.PasswordLevelRequestTimeframe
                }

                if([String]::IsNullOrEmpty($PFGeneralID)){ $PFGeneralID = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralName)){ $PFGeneralName = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralSystemType)){ $PFGeneralSystemType = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralActive)){ $PFGeneralActive = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralDescription)){ $PFGeneralDescription = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralPlatformBaseID)){ $PFGeneralPlatformBaseID = "NULL" }
                if([String]::IsNullOrEmpty($PFGeneralPlatformType)){ $PFGeneralPlatformType = "NULL" }
                if([String]::IsNullOrEmpty($PFPropertiesRequired)){ $PFPropertiesRequired = "NULL" }
                if([String]::IsNullOrEmpty($PFPropertiesOptional)){ $PFPropertiesOptional = "NULL" }
                if([String]::IsNullOrEmpty($PFLinkedAccounts)){ $PFLinkedAccounts = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAllowedSafes)){ $PFCredentialsManagementAllowedSafes = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAllowManualChange)){ $PFCredentialsManagementAllowManualChange = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementPerformPeriodicChange)){ $PFCredentialsManagementPerformPeriodicChange = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementRequirePasswordChangeEveryXDays)){ $PFCredentialsManagementRequirePasswordChangeEveryXDays = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAllowManualVerification)){ $PFCredentialsManagementAllowManualVerification = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementPerformPeriodicVerification)){ $PFCredentialsManagementPerformPeriodicVerification = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementRequirePasswordVerificationEveryXDays)){ $PFCredentialsManagementRequirePasswordVerificationEveryXDays = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAllowManualReconciliation)){ $PFCredentialsManagementAllowManualReconciliation = "NULL" }
                if([String]::IsNullOrEmpty($PFCredentialsManagementAutomaticReconcileWhenUnsynched)){ $PFCredentialsManagementAutomaticReconcileWhenUnsynched = "NULL" }
                if([String]::IsNullOrEmpty($PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation)){ $PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation = "NULL" }
                if([String]::IsNullOrEmpty($PFSessionManagementRecordAndSaveSessionActivity)){ $PFSessionManagementRecordAndSaveSessionActivity = "NULL" }
                if([String]::IsNullOrEmpty($PFSessionManagementPSMServerID)){ $PFSessionManagementPSMServerID = "NULL" }
                if([String]::IsNullOrEmpty($PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval)){ $PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval = "NULL" }
                if([String]::IsNullOrEmpty($PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess)){ $PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess = "NULL" }
                if([String]::IsNullOrEmpty($PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess)){ $PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess = "NULL" }
                if([String]::IsNullOrEmpty($PFConnectionComponents)){ $PFConnectionComponents = "NULL" }
                if([String]::IsNullOrEmpty($PFSearchForUsages)){ $PFSearchForUsages = "NULL" }
                if([String]::IsNullOrEmpty($PFPolicyType)){ $PFPolicyType = "NULL" }
                if([String]::IsNullOrEmpty($PFImmediateInterval)){ $PFImmediateInterval = "NULL" }
                if([String]::IsNullOrEmpty($PFInterval)){ $PFInterval = "NULL" }
                if([String]::IsNullOrEmpty($PFMaxConcurrentConnections)){ $PFMaxConcurrentConnections = "NULL" }
                if([String]::IsNullOrEmpty($PFMinValidityPeriod)){ $PFMinValidityPeriod = "NULL" }
                if([String]::IsNullOrEmpty($PFResetOveridesMinValidity)){ $PFResetOveridesMinValidity = "NULL" }
                if([String]::IsNullOrEmpty($PFResetOveridesTimeFrame)){ $PFResetOveridesTimeFrame = "NULL" }
                if([String]::IsNullOrEmpty($PFTimeout)){ $PFTimeout = "NULL" }
                if([String]::IsNullOrEmpty($PFUnlockIfFail)){ $PFUnlockIfFail = "NULL" }
                if([String]::IsNullOrEmpty($PFUnrecoverableErrors)){ $PFUnrecoverableErrors = "NULL" }
                if([String]::IsNullOrEmpty($PFMaximumRetries)){ $PFMaximumRetries = "NULL" }
                if([String]::IsNullOrEmpty($PFMinDelayBetweenRetries)){ $PFMinDelayBetweenRetries = "NULL" }
                if([String]::IsNullOrEmpty($PFDllName)){ $PFDllName = "NULL" }
                if([String]::IsNullOrEmpty($PFXMLFile)){ $PFXMLFile = "NULL" }
                if([String]::IsNullOrEmpty($PFHeadStartInterval)){ $PFHeadStartInterval = "NULL" }
                if([String]::IsNullOrEmpty($PFFromHour)){ $PFFromHour = "NULL" }
                if([String]::IsNullOrEmpty($PFToHour)){ $PFToHour = "NULL" }
                if([String]::IsNullOrEmpty($PFChangeNotificationPeriod)){ $PFChangeNotificationPeriod = "NULL" }
                if([String]::IsNullOrEmpty($PFDaysNotifyPriorExpiration)){ $PFDaysNotifyPriorExpiration = "NULL" }
                if([String]::IsNullOrEmpty($PFVFFromHour)){ $PFVFFromHour = "NULL" }
                if([String]::IsNullOrEmpty($PFVFToHour)){ $PFVFToHour = "NULL" }
                if([String]::IsNullOrEmpty($PFRCReconcileReasons)){ $PFRCReconcileReasons = "NULL" }
                if([String]::IsNullOrEmpty($PFRCFromHour)){ $PFRCFromHour = "NULL" }
                if([String]::IsNullOrEmpty($PFRCToHour)){ $PFRCToHour = "NULL" }
                if([String]::IsNullOrEmpty($PFNFNotifyPriorExpiration)){ $PFNFNotifyPriorExpiration = "NULL" }
                if([String]::IsNullOrEmpty($PFNFPriorExpirationRecipients)){ $PFNFPriorExpirationRecipients = "NULL" }
                if([String]::IsNullOrEmpty($PFNFNotifyOnPasswordDisable)){ $PFNFNotifyOnPasswordDisable = "NULL" }
                if([String]::IsNullOrEmpty($PFNFOnPasswordDisableRecipients)){ $PFNFOnPasswordDisableRecipients = "NULL" }
                if([String]::IsNullOrEmpty($PFNFNotifyOnVerificationErrors)){ $PFNFNotifyOnVerificationErrors = "NULL" }
                if([String]::IsNullOrEmpty($PFNFOnVerificationErrorsRecipients)){ $PFNFOnVerificationErrorsRecipients = "NULL" }
                if([String]::IsNullOrEmpty($PFNFNotifyOnPasswordUsed)){ $PFNFNotifyOnPasswordUsed = "NULL" }
                if([String]::IsNullOrEmpty($PFNFOnPasswordUsedRecipients)){ $PFNFOnPasswordUsedRecipients = "NULL" }
                if([String]::IsNullOrEmpty($PFPasswordLength)){ $PFPasswordLength = "NULL" }
                if([String]::IsNullOrEmpty($PFMinUpperCase)){ $PFMinUpperCase = "NULL" }
                if([String]::IsNullOrEmpty($PFMinLowerCase)){ $PFMinLowerCase = "NULL" }
                if([String]::IsNullOrEmpty($PFMinDigit)){ $PFMinDigit = "NULL" }
                if([String]::IsNullOrEmpty($PFMinSpecial)){ $PFMinSpecial = "NULL" }
                if([String]::IsNullOrEmpty($PFPasswordLevelRequestTimeframe)){ $PFPasswordLevelRequestTimeframe = "NULL" }

                $PFGeneralID = $PFGeneralID -replace "'","''"
                $PFGeneralName = $PFGeneralName -replace "'","''"
                $PFGeneralSystemType = $PFGeneralSystemType -replace "'","''"
                $PFGeneralActive = $PFGeneralActive -replace "'","''"
                $PFGeneralDescription = $PFGeneralDescription -replace "'","''"
                $PFGeneralPlatformBaseID = $PFGeneralPlatformBaseID -replace "'","''"
                $PFGeneralPlatformType = $PFGeneralPlatformType -replace "'","''"
                $PFPropertiesRequired = $PFPropertiesRequired -replace "'","''"
                $PFPropertiesOptional = $PFPropertiesOptional -replace "'","''"
                $PFLinkedAccounts = $PFLinkedAccounts -replace "'","''"
                $PFCredentialsManagementAllowedSafes = $PFCredentialsManagementAllowedSafes -replace "'","''"
                $PFCredentialsManagementAllowManualChange = $PFCredentialsManagementAllowManualChange -replace "'","''"
                $PFCredentialsManagementPerformPeriodicChange = $PFCredentialsManagementPerformPeriodicChange -replace "'","''"
                $PFCredentialsManagementRequirePasswordChangeEveryXDays = $PFCredentialsManagementRequirePasswordChangeEveryXDays -replace "'","''"
                $PFCredentialsManagementAllowManualVerification = $PFCredentialsManagementAllowManualVerification -replace "'","''"
                $PFCredentialsManagementPerformPeriodicVerification = $PFCredentialsManagementPerformPeriodicVerification -replace "'","''"
                $PFCredentialsManagementRequirePasswordVerificationEveryXDays = $PFCredentialsManagementRequirePasswordVerificationEveryXDays -replace "'","''"
                $PFCredentialsManagementAllowManualReconciliation = $PFCredentialsManagementAllowManualReconciliation -replace "'","''"
                $PFCredentialsManagementAutomaticReconcileWhenUnsynched = $PFCredentialsManagementAutomaticReconcileWhenUnsynched -replace "'","''"
                $PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation = $PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation -replace "'","''"
                $PFSessionManagementRecordAndSaveSessionActivity = $PFSessionManagementRecordAndSaveSessionActivity -replace "'","''"
                $PFSessionManagementPSMServerID = $PFSessionManagementPSMServerID -replace "'","''"
                $PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval = $PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval -replace "'","''"
                $PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess = $PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess -replace "'","''"
                $PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess = $PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess -replace "'","''"
                $PFConnectionComponents = $PFConnectionComponents -replace "'","''"
                $PFSearchForUsages = $PFSearchForUsages -replace "'","''"
                $PFPolicyType = $PFPolicyType -replace "'","''"
                $PFImmediateInterval = $PFImmediateInterval -replace "'","''"
                $PFInterval = $PFInterval -replace "'","''"
                $PFMaxConcurrentConnections = $PFMaxConcurrentConnections -replace "'","''"
                $PFMinValidityPeriod = $PFMinValidityPeriod -replace "'","''"
                $PFResetOveridesMinValidity = $PFResetOveridesMinValidity -replace "'","''"
                $PFResetOveridesTimeFrame = $PFResetOveridesTimeFrame -replace "'","''"
                $PFTimeout = $PFTimeout -replace "'","''"
                $PFUnlockIfFail = $PFUnlockIfFail -replace "'","''"
                $PFUnrecoverableErrors = $PFUnrecoverableErrors -replace "'","''"
                $PFMaximumRetries = $PFMaximumRetries -replace "'","''"
                $PFMinDelayBetweenRetries = $PFMinDelayBetweenRetries -replace "'","''"
                $PFDllName = $PFDllName -replace "'","''"
                $PFXMLFile = $PFXMLFile -replace "'","''"
                $PFHeadStartInterval = $PFHeadStartInterval -replace "'","''"
                $PFFromHour = $PFFromHour -replace "'","''"
                $PFToHour = $PFToHour -replace "'","''"
                $PFChangeNotificationPeriod = $PFChangeNotificationPeriod -replace "'","''"
                $PFDaysNotifyPriorExpiration = $PFDaysNotifyPriorExpiration -replace "'","''"
                $PFVFFromHour = $PFVFFromHour -replace "'","''"
                $PFVFToHour = $PFVFToHour -replace "'","''"
                $PFRCReconcileReasons = $PFRCReconcileReasons -replace "'","''"
                $PFRCFromHour = $PFRCFromHour -replace "'","''"
                $PFRCToHour = $PFRCToHour -replace "'","''"
                $PFNFNotifyPriorExpiration = $PFNFNotifyPriorExpiration -replace "'","''"
                $PFNFPriorExpirationRecipients = $PFNFPriorExpirationRecipients -replace "'","''"
                $PFNFNotifyOnPasswordDisable = $PFNFNotifyOnPasswordDisable -replace "'","''"
                $PFNFOnPasswordDisableRecipients = $PFNFOnPasswordDisableRecipients -replace "'","''"
                $PFNFNotifyOnVerificationErrors = $PFNFNotifyOnVerificationErrors -replace "'","''"
                $PFNFOnVerificationErrorsRecipients = $PFNFOnVerificationErrorsRecipients -replace "'","''"
                $PFNFNotifyOnPasswordUsed = $PFNFNotifyOnPasswordUsed -replace "'","''"
                $PFNFOnPasswordUsedRecipients = $PFNFOnPasswordUsedRecipients -replace "'","''"
                $PFPasswordLength = $PFPasswordLength -replace "'","''"
                $PFMinUpperCase = $PFMinUpperCase -replace "'","''"
                $PFMinLowerCase = $PFMinLowerCase -replace "'","''"
                $PFMinDigit = $PFMinDigit -replace "'","''"
                $PFMinSpecial = $PFMinSpecial -replace "'","''"
                $PFPasswordLevelRequestTimeframe = $PFPasswordLevelRequestTimeframe -replace "'","''"

                try{
                    $query = "INSERT INTO $TableName ( ID, Name, SystemType, Active, Description, PlatformBaseID, PlatformType, PropertiesRequired, PropertiesOptional, LinkedAccounts, AllowedSafes, AllowManualChange, PerformPeriodicChange, RequirePasswordChangeEveryXDays, AllowManualVerification, PerformPeriodicVerification, RequirePasswordVerificationEveryXDays, AllowManualReconciliation, AutomaticReconcileWhenUnsynched, RequirePrivilegedSessionMonitoringAndIsolation, RecordAndSaveSessionActivity, PSMServerID, RequireDualControlPasswordAccessApproval, EnforceCheckinCheckoutExclusiveAccess, EnforceOnetimePasswordAccess, ConnectionComponents, SearchForUsages, PolicyType, ImmediateInterval, Interval, MaxConcurrentConnections, MinValidityPeriod, ResetOveridesMinValidity, ResetOveridesTimeFrame, Timeout, UnlockIfFail, UnrecoverableErrors, MaximumRetries, MinDelayBetweenRetries, DllName, XMLFile, HeadStartInterval, FromHour, ToHour, ChangeNotificationPeriod, DaysNotifyPriorExpiration, VFFromHour, VFToHour, RCReconcileReasons, RCFromHour, RCToHour, NFNotifyPriorExpiration, NFPriorExpirationRecipients, NFNotifyOnPasswordDisable, NFOnPasswordDisableRecipients, NFNotifyOnVerificationErrors, NFOnVerificationErrorsRecipients, NFNotifyOnPasswordUsed, NFOnPasswordUsedRecipients, PasswordLength, MinUpperCase, MinLowerCase, MinDigit, MinSpecial, PasswordLevelRequestTimeframe ) VALUES ( '$PFGeneralID', '$PFGeneralName', '$PFGeneralSystemType', '$PFGeneralActive', '$PFGeneralDescription', '$PFGeneralPlatformBaseID', '$PFGeneralPlatformType', '$PFPropertiesRequired', '$PFPropertiesOptional', '$PFLinkedAccounts', '$PFCredentialsManagementAllowedSafes', '$PFCredentialsManagementAllowManualChange', '$PFCredentialsManagementPerformPeriodicChange', '$PFCredentialsManagementRequirePasswordChangeEveryXDays', '$PFCredentialsManagementAllowManualVerification', '$PFCredentialsManagementPerformPeriodicVerification', '$PFCredentialsManagementRequirePasswordVerificationEveryXDays', '$PFCredentialsManagementAllowManualReconciliation', '$PFCredentialsManagementAutomaticReconcileWhenUnsynched', '$PFSessionManagementRequirePrivilegedSessionMonitoringAndIsolation', '$PFSessionManagementRecordAndSaveSessionActivity', '$PFSessionManagementPSMServerID', '$PFPrivilegedAccessWorkflowsRequireDualControlPasswordAccessApproval', '$PFPrivilegedAccessWorkflowsEnforceCheckinCheckoutExclusiveAccess', '$PFPrivilegedAccessWorkflowsEnforceOnetimePasswordAccess', '$PFConnectionComponents', '$PFSearchForUsages', '$PFPolicyType', '$PFImmediateInterval', '$PFInterval', '$PFMaxConcurrentConnections', '$PFMinValidityPeriod', '$PFResetOveridesMinValidity', '$PFResetOveridesTimeFrame', '$PFTimeout', '$PFUnlockIfFail', '$PFUnrecoverableErrors', '$PFMaximumRetries', '$PFMinDelayBetweenRetries', '$PFDllName', '$PFXMLFile', '$PFHeadStartInterval', '$PFFromHour', '$PFToHour', '$PFChangeNotificationPeriod', '$PFDaysNotifyPriorExpiration', '$PFVFFromHour', '$PFVFToHour', '$PFRCReconcileReasons', '$PFRCFromHour', '$PFRCToHour', '$PFNFNotifyPriorExpiration', '$PFNFPriorExpirationRecipients', '$PFNFNotifyOnPasswordDisable', '$PFNFOnPasswordDisableRecipients', '$PFNFNotifyOnVerificationErrors', '$PFNFOnVerificationErrorsRecipients', '$PFNFNotifyOnPasswordUsed', '$PFNFOnPasswordUsedRecipients', '$PFPasswordLength', '$PFMinUpperCase', '$PFMinLowerCase', '$PFMinDigit', '$PFMinSpecial', '$PFPasswordLevelRequestTimeframe' );"
                    $UpdateRec = Invoke-Sqlcmd -ServerInstance $SQLServer -Database $SQLDatabase -Query $query -Username $SQLUsername -Password $Secret
                    Write-Verbose "ADDED RECORD INTO $TableName FOR PLATFORMID: $PFPlatformID"
                }catch{
                    Write-Verbose "FAILED TO ADD RECORD INTO $TableName FOR PLATFORMID: $PFPlatformID"
                    Write-VPASOutput -str "FAILED TO ADD RECORD INTO $TableName FOR PLATFORMID: $PFPlatformID" -type E
                    Write-VPASOutput -str $_ -type E
                }
            }
        }
        #######################
        return $true
    }
    End{
        $log = Write-VPASTextRecorder -inputval $CommandName -token $token -LogType DIVIDER
    }
}