$starttime=get-date

##此处为脚本内容##

(New-TimeSpan $starttime).TotalSeconds   #获取脚本运行时长