formats/psworkitem.format.ps1xml

<!--
Format type data generated 07/25/2022 14:53:42 by THINKX1-JH\Jeff
 
This file was created using the New-PSFormatXML command that is part
of the PSScriptTools module.
 
https://github.com/jdhitsolutions/PSScriptTools
-->
<Configuration>
  <ViewDefinitions>
    <View>
      <Name>default</Name>
      <ViewSelectedBy>
        <TypeName>PSWorkItem</TypeName>
      </ViewSelectedBy>
      <GroupBy>
        <PropertyName>Path</PropertyName>
        <Label>Database</Label>
      </GroupBy>
      <TableControl>
        <!--Delete the AutoSize node if you want to use the defined widths.-->
        <AutoSize />
        <TableHeaders>
          <TableColumnHeader>
            <Label>ID</Label>
            <Width>5</Width>
            <Alignment>right</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Name</Label>
            <Width>18</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Description</Label>
            <Width>41</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>DueDate</Label>
            <Width>23</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Category</Label>
            <Width>11</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Pct</Label>
            <Width>11</Width>
            <Alignment>right</Alignment>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <Wrap />
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>ID</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
              if ($host.name -match "console|code") {
                $ts = New-TimeSpan -Start (Get-Date) -End $_.duedate
                If ($ts.TotalDays -le 0) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightred, $_.name, $psstyle.reset
                }
                ElseIf ($ts.totaldays -le 3) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $_.name, $psstyle.reset
                }
                else {
                    <!--use the PSWorkItemCategory hastable to add custom highlights-->
                    "$($PSWorkItemCategory["$($_.category)"])$($_.name)$($PSStyle.Reset)"
                }
            }
            else {
                $_.Name
            }
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
              if ($host.name -match "console|code") {
                $ts = New-TimeSpan -Start (Get-Date) -End $_.duedate
                If ($ts.TotalDays -le 0) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightred, $_.Description, $psstyle.reset
                }
                ElseIf ($ts.totaldays -le 3) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $_.Description, $psstyle.reset
                }
                else {
                    "$($PSWorkItemCategory["$($_.category)"])$($_.Description)$($PSStyle.Reset)"
                }
            }
            else {
                $_.Description
            }
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                <!--format the due date with leading zeros and no seconds-->
                $cult = Get-Culture
                if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") {
                  $dd = "{0:MM/dd/yyyy hh:mm tt}" -f $_.DueDate
                }
                else {
                  $dd = "{0:$($cult.DateTimeFormat.ShortDatePattern) $($cult.DateTimeFormat.LongTimePattern)}" -f $_.DueDate
                }
              if ($host.name -match "console|code") {
                $ts = New-TimeSpan -Start (Get-Date) -End $_.duedate
                If ($ts.TotalDays -le 0) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightred, $dd, $psstyle.reset
                }
                ElseIf ($ts.totaldays -le 3) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $dd, $psstyle.reset
                }
                else {
                    "$($PSWorkItemCategory["$($_.category)"])$($dd)$($PSStyle.Reset)"
                }
            }
            else {
                $dd
            }
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  if ($host.name -match "console|code") {
                  "$($PSWorkItemCategory["$($_.category)"])$($_.category)$($PSStyle.Reset)"
                  }
                  else {
                  $_.category
                  }
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  if ($host.name -match "console|code") {
                  "$($PSWorkItemCategory["$($_.category)"])$($_.progress)$($PSStyle.Reset)"
                  }
                  else {
                  $_.progress
                  }
                </ScriptBlock>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
    <View>
      <Name>countdown</Name>
      <ViewSelectedBy>
        <TypeName>PSWorkItem</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <!--Delete the AutoSize node if you want to use the defined widths.-->
        <AutoSize />
        <TableHeaders>
          <TableColumnHeader>
            <Label>ID</Label>
            <Width>5</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Name</Label>
            <Width>21</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Description</Label>
            <Width>39</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>DueDate</Label>
            <Width>23</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>TimeRemaining</Label>
            <Width>23</Width>
            <Alignment>right</Alignment>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>ID</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>Name</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>Description</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                <!--format the due date with leading zeros and no seconds-->
                $cult = Get-Culture
                if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") {
                  $dd = "{0:MM/dd/yyyy hh:mm tt}" -f $_.DueDate
                }
                else {
                  $dd = "{0:$($cult.DateTimeFormat.ShortDatePattern) $($cult.DateTimeFormat.LongTimePattern)}" -f $_.DueDate
                }
                $dd
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <!--this is the simplest way to handle negative values-->
                <ScriptBlock>$_.TimeRemaining.ToString().substring(0,$_.TimeRemaining.ToString().LastIndexOf("."))</ScriptBlock>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
    <View>
      <Name>default</Name>
      <ViewSelectedBy>
        <TypeName>PSWorkItemArchive</TypeName>
      </ViewSelectedBy>
      <GroupBy>
        <PropertyName>Path</PropertyName>
        <Label>Database</Label>
      </GroupBy>
      <TableControl>
        <!--Delete the AutoSize node if you want to use the defined widths.-->
        <AutoSize />
        <TableHeaders>
          <TableColumnHeader>
            <Label>ID</Label>
            <Width>5</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Name</Label>
            <Width>21</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Description</Label>
            <Width>39</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Category</Label>
            <Width>11</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Completed</Label>
            <Width>12</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <Wrap />
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>ID</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>Name</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>Description</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>Category</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>CompletedDate</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
    <View>
      <Name>category</Name>
      <ViewSelectedBy>
        <TypeName>PSWorkItem</TypeName>
      </ViewSelectedBy>
      <GroupBy>
        <PropertyName>Category</PropertyName>
        <Label>Category</Label>
      </GroupBy>
      <TableControl>
        <!--Delete the AutoSize node if you want to use the defined widths.
        <AutoSize />-->
        <TableHeaders>
          <TableColumnHeader>
            <Label>ID</Label>
            <Width>5</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Name</Label>
            <Width>20</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Description</Label>
            <Width>25</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>DueDate</Label>
            <Width>22</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Pct</Label>
            <Width>4</Width>
            <Alignment>right</Alignment>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <Wrap />
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>ID</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
              if ($host.name -match "console|code") {
                $ts = New-TimeSpan -Start (Get-Date) -End $_.duedate
                If ($ts.TotalDays -le 0) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightred, $_.name, $psstyle.reset
                }
                ElseIf ($ts.totaldays -le 3) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $_.name, $psstyle.reset
                }
                else {
                    $_.name
                }
            }
            else {
                $_.Name
            }
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>Description</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                <!--format the due date with leading zeros and no seconds-->
                $cult = Get-Culture
                if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") {
                  $dd = "{0:MM/dd/yyyy hh:mm tt}" -f $_.DueDate
                }
                else {
                  $dd = "{0:$($cult.DateTimeFormat.ShortDatePattern) $($cult.DateTimeFormat.LongTimePattern)}" -f $_.DueDate
                }
              if ($host.name -match "console|code") {
                $ts = New-TimeSpan -Start (Get-Date) -End $_.duedate
                If ($ts.TotalDays -le 0) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightred, $dd, $psstyle.reset
                }
                ElseIf ($ts.totaldays -le 3) {
                    "{0}{1}{2}" -f $psstyle.Foreground.brightyellow, $dd, $psstyle.reset
                }
                else {
                    $dd
                }
            }
            else {
                $_.DueDate
            }
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>Progress</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
    <View>
      <!--Created 03/11/2023 14:14:12 by PROSPERO\Jeff-->
      <Name>age</Name>
      <ViewSelectedBy>
        <TypeName>PSWorkItem</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <!--Delete the AutoSize node if you want to use the defined widths.
        <AutoSize />
        -->
        <TableHeaders>
          <TableColumnHeader>
            <Label>ID</Label>
            <Width>5</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Name</Label>
            <Width>40</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Age</Label>
            <Width>10</Width>
            <Alignment>left</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Created</Label>
            <Width>22</Width>
            <Alignment>right</Alignment>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>ID</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>Name</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                "{0:dd\.hh\:mm}"-f $_.age
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                <!--format the creation date with leading zeros and no seconds-->
                $cult = Get-Culture
                if ($cult.DateTimeFormat.ShortDatePattern -match "^M/d/yyyy$") {
                  $dd = "{0:MM/dd/yyyy hh:mm tt}" -f $_.TaskCreated
                }
                else {
                  $dd = "{0:$($cult.DateTimeFormat.ShortDatePattern) $($cult.DateTimeFormat.LongTimePattern)}" -f $_.TaskCreated
                }
                $dd
                </ScriptBlock>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
  </ViewDefinitions>
</Configuration>