New-UDPage -Url "/ApplicationServerV2" -Name "ApplicationServerV2" -Content {
New-UDTypography -Text 'Application Server request items (RITMs) submitted between 2023/02/27 and 2024/06/25 in which the field "VM Work Needed" is set to "Yes"'


    $ServerInstance = "itdintsql22p1.nd.gov\INTSQL22P1"
    $Database = "ITD-Systems-Automation"
    $Table = 'ServiceNow_RitmDump_ApplicationServerV2'

    $SqlQuery = "SELECT [number],[sys_id],[opened_at],[requested_for],[short_description],[request_type],[application_name],[environment],[additional_comments],[vm_work_needed],[server_name],[host_name],[server_type],[operating_system],[target_platform],[processors],[memory_gb],[cidr_block],[data_center],[licensing_restrictions],[agency_name],[application_info],[support_hours],[dr_protection],[startup_priority],[disk_1_os],[disk_2_swap_disk],[disk_3],[disk_4],[disk_5],[disk_6],[disk_7],[disk_8],[disk_9],[disk_10],[disk_11],[disk_12],[disk_13],[disk_14],[disk_15],[disk_16] FROM [$Database].[dbo].[$Table] WHERE vm_work_needed = '1'"
    $SqlRecords = Invoke-Sqlcmd -ServerInstance $ServerInstance -Database $Database -Query $SqlQuery -Credential $Secret:sql_itdpsu1 -Verbose

    New-UDTable -Columns @(
        New-UDTableColumn -Property 'number' -Title 'number' -ShowSort
        New-UDTableColumn -Property 'opened_at' -Title 'opened_at'
        New-UDTableColumn -Property 'server_name' -Title 'server_name' -ShowFilter
        New-UDTableColumn -Property 'host_name' -Title 'host_name' -ShowFilter        
        New-UDTableColumn -Property 'requested_for' -Title 'requested_for' -ShowFilter
        New-UDTableColumn -Property 'request_type' -Title 'request_type' -ShowFilter
        New-UDTableColumn -Property 'environment' -Title 'environment' -ShowFilter
        New-UDTableColumn -Property 'additional_comments' -Title 'additional_comments' -ShowFilter
    ) -Data ($SqlRecords | Select *,@{n='Open';e={$_.sys_id}} | Sort-Object -Descending number) -Dense -ShowPagination -PageSize 20
} -Icon @{
		type = 'icon'
		id = 'e91ed4ef-cecd-448a-9204-2b453db9db03'
	}