When I'm executing the script nothing is logging into Test.json
.
Can any one tell me how to call function from where-object
in inline query?
function getDateOfTimeStamp($dateString) {
[string[]] $format = @("MM/d/yyyy hh:mm:ss tt", "M/d/yyyy hh:mm:ss tt", "MM/dd/yyyy hh:mm:ss tt", "M/dd/yyyy hh:mm:ss tt")
$result = $null
$format.ForEach( { [DateTime] $dt = New-Object DateTime; if ([datetime]::TryParseExact($dateString, $_, [System.Globalization.CultureInfo]::InvariantCulture, [System.Globalization.DateTimeStyles]::None, [ref] $dt)) { $result = $dt } })
$result
}
$storageaccount = Get-AzureRmStorageAccount -StorageAccountName test123 -ResourceGroupName testinggroup
$table = Get-AzureStorageTable -Name testtable123
$query = New-Object Microsoft.WindowsAzure.Storage.Table.TableQuery
$data = $table.CloudTable.ExecuteQuery($query)
$data | % { EntityToObject $_ } | Select-Object PartitionKey, RowKey, DateModified| Where-Object {getDateOfTimeStamp DateModified -lt ((Get-Date).ToUniversalTime().AddDays(-10))} | ConvertTo-Json | Out-File "C:\Test.json"
See Question&Answers more detail:os