powershell命令

一、用win10自带的powershell可以轻松修改文档/文件夹创建时间、修改时间。而且可以批量修改。

1、修改文件夹下面文件的属性

powershell.exe -command "ls '*.*' | foreach-object { $_.LastWriteTime = '01/11/2004 22:13:36'; $_.CreationTime = '01/11/2004 22:13:36'; $_.LastAccessTime = '01/11/2004 22:13:36'; }"

-command: tells powershell to run the following command and return immediately

  ls: list all matching files at the path specified

  foreach-object: run the following block on each file that ls found

powershell.exe -c "dir '*.*' | % { $_.LastWriteTime = '01/11/2004 22:13:36'; $_.CreationTime = '01/11/2004 22:13:36'; $_.LastAccessTime = '01/11/2004 22:13:36' }"

2、修改文件夹下面的文件夹及文件的属性

powershell.exe -c "Get-Childitem -path 'C:\Users\soka\Desktop\1' -Recurse | foreach-object { $_.LastWriteTime = '01/11/2004 22:13:36'; $_.CreationTime = '01/11/2004 22:13:36'; $_.LastAccessTime = '01/11/2004 22:13:36' }"

锁定用户账号

我们可以使用useraccount选项来锁定本地用户账号:
wmic useraccount where name=’demo’ set disabled=false

用户账号重命名
wmic useraccount where name=’demo’ rename hacker

限制用户修改密码
wmic useraccount where name=’hacker’ set passwordchangeable=fals

(0)

相关推荐