azure-devopsscriptingazure-powershellpowershell-5.1devops-services

Change the format of timestamp that return my script - azure devops service


The timestamp is returning a timestamp with a strange format:

"TimeStamp":  {
                      "value":  "\/Date(1674758644068)\/",
                      "DisplayHint":  2,
                      "DateTime":  "jueves, 26 de enero de 2023 12:44:04 p. m."
                  },

The problem is that I want to upload the information to powerBi and it gives me an error, for this I would like to make my script return this type of format:

"TimeStamp": "2022-08-08T19:00:53.0907571-05:00"

In my script the timestamp calls it in this function.

try {
$projectsDataArray = getProjects| ForEach-Object {
    @{ 
        TimeStamp = Get-Date
        ProjectMeta = processProject($_)
    }
}
#****Llamada con el recorrido para obtener el id de cada definiiton
$projectsDataArray | ConvertTo-Json -Depth 8 | Set-Content C:\Users\60085367\Documents\Proyecto3ApiDevOps\NuevaPrueba\devopsmetaFinal.json

}
catch { Write-Output $_ }


Solution

  • TimeStamp = Get-Date -Format "o"