我正在编写一个PowerShell脚本来清理旧数据库或表,但发现从Get-AzureRmDataLakeAnalyticsCatalogItem返回的对象没有创建时间。
答案 0 :(得分:0)
$DataLakeAnalyticsAccount = "yourAccountNameHere";
$outputFile = "ReferenceGuide/CatalogViews/CreateDate.txt";
$jobName = "GetCreateDate";
# U-SQL query
[string]$body =
"@query =
SELECT ""Database"" AS Object, name, create_date FROM usql.databases
UNION ALL
SELECT type_desc, ""master."" + name AS Table, create_date FROM master.usql.objects WHERE type == ""U""
UNION ALL
SELECT type_desc, ""TestReferenceDB."" + name AS Table, create_date FROM TestReferenceDB.usql.objects WHERE type == ""U"";
";
# OUTPUT statement
[string]$output =
"OUTPUT @query
TO ""$outputFile""
ORDER BY Object
USING Outputters.Tsv();";
# bring it all together
$script = $body + $output;
#Execute job``
$jobInfo = Submit-AzureRmDataLakeAnalyticsJob -Account $DataLakeAnalyticsAccount -Name $jobName -Script $script -DegreeOfParallelism 1
#check job progress
Get-AzureRmDataLakeAnalyticsJob -Account $DataLakeAnalyticsAccount -JobId $jobInfo.JobId -ErrorAction SilentlyContinue;