日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Current_Path 获取脚本所在路径(当前路径),取当前时间做文件名(uformat)

發布時間:2023/12/20 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Current_Path 获取脚本所在路径(当前路径),取当前时间做文件名(uformat) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

獲取腳本當前所在路徑:

$CurrentPath = $MyInvocation.MyCommand.Path.substring(0,$MyInvocation.MyCommand.Path.LastIndexOf('\')+1)
$today = Get-Date -UFormat "%Y%m%d"
$LogFilePath = $CurrentPath+"Result_$today.txt"

get-process |out-file $LogFilePath -Append

?$Currentpath ? ? = Split-Path -parent $MyInvocation.MyCommand.Definition?

格式化日期:

$now = get-date -format 'yyyyMMddHHmm'
$dpunmountcmd_ScriptName = "DPUnmount_script_" + $now + ".txt"

$yes = (get-date).adddays(-1)
get-date -date $yes -uformat "%Y/%M/%d" 輸出: 2014/06/23

$yes.tostring("yyyy\/MM\/dd")??輸出: 2014/06/23

?

Get-Date使用Format參數考取年、月、日、時、分、秒

yyyy?? ?年
M?? ?月
d?? ?日
h?? ?小時(12小時制)
H?? ?小時(24小時制)
m?? ?分鐘
s?? ?秒

?

?

Get-Date -UFormat "%Y/%m/%d" ? :2014/04/18

?get-date -uformat %R ?:11:07

?==============================

Get-Date -UFormat %<value>

For example,

Get-Date -UFormat %d

Date-Time:

Date and time - full

(default) (Friday, June 16, 2006 10:31:27 AM)

c Date and time - abbreviated (Fri Jun 16 10:31:27 2006)

?

Date:

D Date in mm/dd/yy format (06/14/06)

x Date in standard format for locale (09/12/07 for English-US)

Year:

C Century (20 for 2006)

Y Year in 4-digit format (2006)

y Year in 2-digit format (06)

G Same as 'Y'

g Same as 'y'

Month:

b Month name - abbreviated (Jan)

B Month name - full (January)

h Same as 'b'

m Month number (06)

Week:

W Week of the year (00-52)

V Week of the year (01-53)

U Same as 'W'

Day:

a Day of the week - abbreviated name (Mon)

A Day of the week - full name (Monday)

u Day of the week - number (Monday = 1)

d Day of the month - 2 digits (05)

e Day of the month - digit preceded by a space ( 5)

j Day of the year - (1-366)

w Same as 'u'

Time:

p AM or PM

r Time in 12-hour format (09:15:36 AM)

R Time in 24-hour format - no seconds (17:45)

T Time in 24 hour format (17:45:52)

X Same as 'T'

Z Time zone offset from Universal Time Coordinate (UTC) (-07)

Hour:

H Hour in 24-hour format (17)

I Hour in 12 hour format (05)

k Same as 'H'

l Same as 'I' (Upper-case I = Lower-case L)

Minutes & Seconds:

M Minutes (35)

S Seconds (05)

s Seconds elapsed since January 1, 1970 00:00:00 (1150451174.95705)

Special Characters:

n newline character (\n)

t Tab character (\t)

詳細參考:http://www.cnblogs.com/dreamer-fish/p/3805726.html?

From:http://technet.microsoft.com/zh-cn/library/hh849887.aspx

總結

以上是生活随笔為你收集整理的Current_Path 获取脚本所在路径(当前路径),取当前时间做文件名(uformat)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。