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)的更多相关文章
- Delphi获取文件名、文件名不带扩展名、文件名的方法;delphi 获取文件所在路径
取文件名 ExtractFileName(FileName); 取文件扩展名: ExtractFileExt(filename); 取文件名,不带扩展名: 方法一: Function Extrac ...
- bat(续五)-获取批处理文件所在路径
获取批处理文件所在路径 在开发时,经常需要使用批处理运行一些程序,java程序 犹其是这样,往往需要运行时根路径.Hardcode一个路径总是令自己觉得不自在,例如一个java程序从一台 ...
- C#: 获取执行程序所在路径和启动资源管理器
一. 获取执行程序所在路径 1.获取和设置当前目录的完全限定路径. string str = System.Environment.CurrentDirectory; //获取的是主程序目录,线程启 ...
- delphi根据进程PID获取程序所在路径的函数(用OpenProcess取得句柄,用GetModuleFileNameEx取得程序名)
uses psapi; {根据进程PID获取程序所在路径的函数}function GetProcessExePath(PID: Cardinal): string;varpHandle: THandl ...
- Qt 程序获取程序所在路径、用户目录路径、临时文件夹等特殊路径的方法
Qt 程序获取程序所在路径.用户目录路径.临时文件夹等特殊路径的方法 经常我们的程序中需要访问一些特殊的路径,比如程序所在的路径.用户目录路径.临时文件夹等.在 Qt 中实现这几个功能所用的方法虽然都 ...
- Application.StartupPath获取执行文件路径substring()取特定长度字符串取得根目录
Application.StartupPath获取执行文件路径substring()取特定长度字符串取得根目录 2012-07-20 10:48 257人阅读 评论(0) 收藏 举报 path usi ...
- dotnet 获取程序所在路径的方法
在 dotnet 有很多方法可以获取当前程序所在的路径,但是这些方法获取到的路径有一点不相同,特别是在工作路径不是当前的程序所在的路径的时候 通过下面几个方法都可以拿到程序所在的文件夹或程序文件 Ap ...
- python 获取脚本所在目录
平时写python经常会想获得脚本所在的目录,例如有个文件跟脚本文件放在一个相对的目录位置,那就可以通过脚本文件的目录找到对应的文件,即使以后脚本文件移到其他地方,脚本也基本不需要改动(相对于写死目录 ...
- 批处理文件中获取当前所在路径的几种方法,以及写文件到txt
@echo off setlocal EnableDelayedExpansion echo 当前正在运行的批处理文件所在路径:!cd! pause @echo off echo 当前目录是:%cd% ...
随机推荐
- Cloudera Manager安装之利用parcels方式(在线或离线)安装3或4节点集群(包含最新稳定版本或指定版本的安装)(添加服务)(Ubuntu14.04)(五)
前期博客 Cloudera Manager安装之Cloudera Manager 5.6.X安装(tar方式.rpm方式和yum方式) (Ubuntu14.04) (三) 如果大家,在启动的时候,比如 ...
- python-cgi-demo
简单的Python CGI 在linux平台实现注意:路径是以当前路径为根目录 ,Python文件一般放在/cgi-bin/目录下在linux命令行运行:python -m CGIHTTPServ ...
- 64位WIN7上安装11G R2 ,PLSQL的配置方法
64位WIN7上安装11G R2 ,PLSQL的配置方法:1. 1.1. 去http://www.oracle.com/technetwork/topics/winsoft-085727. ...
- win10+GTX1080+Tensorflow1.6安装
安装参考网站:http://blog.csdn.net/lp654063449/article/details/79340655 依照安装目录依次安装,所需安装包均已下载,在最后的一步中,打开cuda ...
- 我爱Markdown (2)
Markdown的语法很简单,所以很容易上手.下面介绍一下常用的Markdown的语法, 本文将介绍: 01 - Back-ticks 反尖号 02 - Headers 标题 03 - Emphasi ...
- 使用postman模拟上传文件到springMVC的坑:the request was rejected because no multipart boundary was found
参考该文解决问题:http://blog.csdn.net/sanjay_f/article/details/47407063 报错 threw exception [Request processi ...
- 【angular5项目积累总结】一些正则积累
/^[1-9][0-9]{0,4}$/ /^[1-9][0-9]{0,4}(,[1-9][0-9]{0,4})*$/ /^([a-zA-Z0-9_\-])+\@(([a-zA-Z0-9\-])+\.) ...
- 第6章 通过CrawlSpider对招聘网站进行整站爬取
通过前几章的2个项目的学习,其实本章的拉钩网项目还是挺容易理解的. 本章主要的还是对CrawlSpider源码的解析,其实我对源码还不是很懂,只是会基本的一些功能而已. 不分小节记录了,直接上知识点, ...
- XAMPP环境的搭建
XAMPP是一个强大的集成软件包(什么是集成软件包?就是多个软件打包一起安装了,比如office办公软件包括了word.Excel.PPT) XAMPP包括了Apache,MySQL,PHP,Perl ...
- Cheatsheet: 2018 04.01 ~ 04.30
Web Writing VS Code Extensions with TypeScript Docker How to write excellent Dockerfiles Raspberry P ...