1.時間相差秒數計算
$start = Get-Date
Get-HotFix
$end = Get-Date
Write-Host -ForegroundColor Red ('Total Runtime: ' + ($end - $start).TotalSeconds)//若開始時間保存為字符串$startTime = Get-Date -Format 'yyyyMMddTHH:mm:ss'
$startTime=[datetime]::ParseExact("$startTime","yyyyMMddTHH:mm:ss", $null)$EndTime = Get-Date -Format 'yyyyMMddTHH:mm:ss'
$EndTime=[datetime]::ParseExact("$EndTime","yyyyMMddTHH:mm:ss", $null)$apiTime=($EndTime - $startTime).TotalSeconds
2.獲取文件時間
$(Get-Item abc.txt) 表示獲取文件的句柄;
$(Get-Item abc.txt).creationtime 獲取文件創建時間
$(Get-Item abc.txt).lastaccesstime 獲取文件最后訪問時間
$(Get-Item abc.txt).lastwritetime 獲取文件修改時間
?