This commit is contained in:
Zack Meier
2026-04-15 15:45:50 -05:00
commit 1d304511b8
613 changed files with 140998 additions and 0 deletions
@@ -0,0 +1,21 @@
$Navigation = @(
New-UDListItem -Label 'Home' -OnClick {
Invoke-UDRedirect -Url '/Home'
}
New-UDListItem -Label 'ServerBuildRequestV1' -OnClick {
Invoke-UDRedirect -Url '/ServerBuildRequestV1'
}
New-UDListItem -Label 'ApplicationServerV2' -OnClick {
Invoke-UDRedirect -Url '/ApplicationServerV2'
}
New-UDListItem -Label 'SpCmdbCompare' -OnClick {
Invoke-UDRedirect -Url '/SpCmdbCompare'
}
)
New-UDApp -Title 'PowerShell Universal' -Pages @(
Get-UDPage -Name 'Home'
Get-UDPage -Name 'ApplicationServerV2'
Get-UDPage -Name 'ServerBuildRequestV1'
Get-UDPage -Name 'SpCmdbCompare'
) -Navigation $Navigation
@@ -0,0 +1,25 @@
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'
}
@@ -0,0 +1,3 @@
New-UDPage -Name 'Home' -Content {
New-UDTypography -Text 'Home' -Id 'homeText'
} -Generated
@@ -0,0 +1,130 @@
New-UDPage -Url "/ServerBuildRequestV1" -Name "ServerBuildRequestV1" -Content {
New-UDForm -Content {
New-UDTypography -Text 'To sync vCenter to Sharepoint, enter a VMware VM name below and click the Submit button'
New-UDRow -Columns {
New-UDColumn -SmallSize 6 -LargeSize 6 -Content {
New-UDTextbox -Id 'VMName'
}
}
} -OnValidate {
$FormContent = $EventData
if ($FormContent.VMName -eq $null -or $FormContent.VMName -eq '') {
New-UDFormValidationResult -ValidationError "VMName is required"
}
else {
New-UDFormValidationResult -Valid
}
} -OnSubmit {
Show-UDToast -Message ($EventData.VMName + " sync in progress.") -Duration 5000
Invoke-PSUScript -Script 'Sync-ITDVMwareVMMetadataToSharePoint.ps1' -VMName $EventData.VMName -Wait | Out-Null
Show-UDToast -Message ($EventData.VMName + " sync finished.") -Duration 10000
} -OnProcessing {
New-UDTypography -Text ("Syncing " + $EventData.VMName + " ...")
New-UDProgress
}
New-UDTypography -Text "`nServer Build Request request items (RITMs) submitted after 2024/06/25"
$ServerInstance = "itdintsql22p1.nd.gov\INTSQL22P1"
$Database = "ITD-Systems-Automation"
$Table = 'ServiceNow_RitmDump_ServerBuildRequestV1'
New-ITDServiceNowSession -Environment Production -Credential $Secret:snow_vmcred
$SqlQuery = "SELECT [RitmNum],
[RitmSysId],
[opened_at],
[requested_for],
[request_type],
[environment]
,[host_name_ref]
,[host_name]
FROM [ITD-Systems-Automation].[dbo].[ServiceNow_RitmDump_ServerBuildRequestV1]"
$SqlRecords = Invoke-Sqlcmd -ServerInstance $ServerInstance -Database $Database -Query $SqlQuery -Credential $Secret:sql_itdpsu1 -Verbose
New-UDTable -Dense -ShowPagination -PageSize 20 -Size small -Data ($SqlRecords | Sort-Object -Descending opened_at) -Columns @(
New-UDTableColumn -Property 'NewSP' -Title 'New' -Render {
New-UDButton -Id "btnNewSP$($EventData.host_name)" -Text "New" -Color Secondary -Size small -OnClick {
Show-UDToast -Message ("Creating new record " + $EventData.host_name) -Duration 5000
switch($EventData.request_type){
'New' {
$Fqdn = $EventData.host_name
$RitmNum = $EventData.RitmNum
Invoke-PSUScript -Script 'New-ITDVMwareSharePointVMRecordFromRITM.ps1' -Fqdn $Fqdn -RitmNum $RitmNum
}
'Removal' {
$Fqdn = $EventData.host_name
$RitmNum = $EventData.RitmNum
}
}
}
}
New-UDTableColumn -Property 'SyncSP' -Title 'SyncVCtoSP' -Render {
New-UDButton -Id "btnSyncSP$($EventData.host_name)" -Text "Sync" -Color primary -Size small -OnClick {
Show-UDToast -Message ("Sync to SharePoint - " + $EventData.host_name) -Duration 5000
switch($EventData.request_type){
'Change' {
$Ritm = Get-ITDServiceNowRecord -ItemType 'Request Item' -Number $EventData.RitmNum -IncludeVariableSet
ForEach($row in $Ritm.VariableSet){
$Cmdb_Ci = Get-ITDServiceNowRecord -Table 'cmdb_ci_server' -SysId $row.host_name_ref
If ($Cmdb_Ci.name.display_value -eq $EventData.host_name){
$Fqdn = $Cmdb_Ci.fqdn.display_value
}
}
Invoke-PSUScript -Script 'Sync-ITDVMwareVMMetadataToSharePoint.ps1' -VMName $Fqdn -Wait | Out-Null
}
'New' {
$Fqdn = $EventData.host_name
}
}
}
}
New-UDTableColumn -Property "ImplSRM" -Title 'ImplSRMtoSP' -Render {
New-UDButton -Id "btnImplSRM$($EventData.host_name)" -Text "SRM" -Color secondary -Size small -OnClick {
Show-UDToast -Message ("Sync to SharePoint - " + $EventData.host_name) -Duration 5000
switch($EventData.request_type){
'Change' {
$Ritm = Get-ITDServiceNowRecord -ItemType 'Request Item' -Number $EventData.RitmNum -IncludeVariableSet
ForEach($row in $Ritm.VariableSet){
$Cmdb_Ci = Get-ITDServiceNowRecord -Table 'cmdb_ci_server' -SysId $row.host_name_ref
If ($Cmdb_Ci.name.display_value -eq $EventData.host_name){
$Fqdn = $Cmdb_Ci.fqdn.display_value
}
}
}
'New' {
$Fqdn = $EventData.host_name
}
}
Invoke-PSUScript -Script 'Sync-ITDVMwareVMMetadataToSharePoint.ps1' -VMName $Fqdn -SRMImplemented -Wait | Out-Null
}
}
New-UDTableColumn -Property 'RitmUrl' -Title 'RitmUrl' -Render {
New-UDLink -Url ("https://northdakota.service-now.com/nav_to.do?uri=sc_req_item.do?sys_id=" + $EventData.RitmSysId) -Id "lnkRitm" -Content {
New-UDImage -Url "https://psuniversal.nd.gov/PSUniversal_Extras/servicenow_logo_icon_168835.png" -Height 20 -Width 20
}
}
New-UDTableColumn -Property 'RitmNum' -Title 'RitmNum' -ShowFilter
New-UDTableColumn -Property 'opened_at' -Title 'opened_at' -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
)
} -Icon @{
id = '7d67b921-68aa-4085-84e8-025e92671771'
type = 'icon'
}
@@ -0,0 +1,73 @@
New-UDPage -Url "/SpCmdbCompare" -Name "SpCmdbCompare" -Content {
# Use Get-UDPage -Name 'SpCmdbCompare' to use this page in your dashboard
##
New-UDForm -Content {
New-UDTypography -Text 'Enter FQDN to Compare'
New-UDRow -Columns {
New-UDColumn -SmallSize 6 -LargeSize 6 -Content {
New-UDTextbox -Id 'VMName'
}
}
} -OnValidate {
$FormContent = $EventData
if ($FormContent.VMName -eq $null -or $FormContent.VMName -eq '') {
New-UDFormValidationResult -ValidationError "VMName is required"
}
else {
New-UDFormValidationResult -Valid
}
} -OnSubmit {
New-ITDServiceNowSession -Environment Production -Credential $Secret:snow_vmcred
#Invoke-PSUScript -Script 'Sync-ITDVMwareVMMetadataToSharePoint.ps1' -VMName $EventData.VMName -Wait | Out-Null
$SPItem = Get-ITDVMwareSharePointVMGuestList -Credential $Secret:ndgov_svcitdiaassprw | Where-Object Title -eq $EventData.VMName
$Hostname = $SPItem.Title.split('.')[0]
$Cmdb = Get-ITDServiceNowRecord -Table cmdb_ci_server -Filter "name=$HostName"
New-UDLink -Url ("https://northdakota.service-now.com/nav_to.do?uri=" + $Cmdb.sys_class_name.value + ".do?sys_id=" + $Cmdb.sys_id.value) -Id "lnkCmdbCi" -Text "Open Cmdb Record"
New-UDLink -Url ("https://northdakota.service-now.com/now/nav/ui/classic/params/target/cmdb_ci_server_list.do%3Fsysparm_query%3DnameSTARTSWITH$HostName") -Text "Open Cmdb Table View"
New-UDTypography -Text "SpTitle and Cmdb HostName" -Variant h5
New-UDTextBox -Id SpTitle -Value $SPItem.Title
New-UDTextBox -Id SpTitle -Value $Cmdb.name.display_value
New-UDTypography -Text "Environment" -Variant h5
New-UDButton -Id "btnEnvironment" -Text "Push Environment to Cmdb" -Color Secondary -Size small -OnClick {
Update-ITDServiceNowRecord -Table cmdb_ci_server -SysId $Cmdb.sys_id.value -Values @{environment = $SPItem.Environment}
}
New-UDTextBox -Id SpTitle -Value $SPItem.Environment
New-UDTextBox -Id SpTitle -Value $Cmdb.environment.display_value
New-UDTypography -Text "AppName" -Variant h5
New-UDButton -Id "btnAppName" -Text "Push AppName to Cmdb" -Color Secondary -Size small -OnClick {
Update-ITDServiceNowRecord -Table cmdb_ci_server -SysId $Cmdb.sys_id.value -Values @{u_nd_application_svc = $SPItem.AppName}
}
New-UDTextBox -Id SpTitle -Value $SPItem.AppName
New-UDTextBox -Id SpTitle -Value $Cmdb.u_nd_application_svc.display_value
New-UDTypography -Text "LicensingRestrictions" -Variant h5
New-UDButton -Id "btnLicesning" -Text "Push Licensing to Cmdb" -Color Secondary -Size small -OnClick {
Update-ITDServiceNowRecord -Table cmdb_ci_server -SysId $Cmdb.sys_id.value -Values @{u_nd_licensing_restrictions = $SPItem.LicensingRestrictions}
}
New-UDTextBox -Id SpTitle -Value $SPItem.LicensingRestrictions
New-UDTextBox -Id SpTitle -Value $Cmdb.u_nd_licensing_restrictions.display_value
New-UDTypography -Text "DR_Protection" -Variant h5
New-UDButton -Id "btnDRProtection" -Text "Push DR_Protection to Cmdb" -Color Secondary -Size small -OnClick {
Update-ITDServiceNowRecord -Table cmdb_ci_server -SysId $Cmdb.sys_id.value -Values @{u_nd_dr_protection = $SPItem.DR_Protection}
}
New-UDTextBox -Id SpTitle -Value $SPItem.DR_Protection
New-UDTextBox -Id SpTitle -Value $Cmdb.u_nd_dr_protection.display_value
New-UDTypography -Text "SRM Recovery Type" -Variant h5
New-UDButton -Id "btnSRMRecoveryType" -Text "Push SRM Recovery Type to Cmdb" -Color Secondary -Size small -OnClick {
Update-ITDServiceNowRecord -Table cmdb_ci_server -SysId $Cmdb.sys_id.value -Values @{u_srm_recovery_type = $SPItem.SRM_RecoveryVMtype}
}
New-UDTextBox -Id SpTitle -Value $SPItem.SRM_RecoveryVMtype
New-UDTextBox -Id SpTitle -Value $Cmdb.u_srm_recovery_type.display_value
}
} -Title "SpCmdbCompare" -Icon @{
id = '1d8ccbbe-f274-4e34-bc59-6ed19e2dfa0e'
type = 'icon'
}