PowerShell和文件系统相关的cmdlet
PowerShell中有大量与文件系统(驱动器、文件夹、文件)相关的cmdlet,为了便于对文件系统的操作,把这些cmdlet收集总结一下是相当必要的。
文件系统相关的cmdlet在名称上大多带上Item和Path这样的关键字,所以,我们可以通过如下命令来把这些cmdlet找出来。
PS C:\Users\zhanghong> Get-Command -noun item*,path
输出如下:
CommandType Name Definition
----------- ---- ----------
Cmdlet Clear-Item Clear-Item [-Path] <String[]...
Cmdlet Clear-ItemProperty Clear-ItemProperty [-Path] <...
Cmdlet Convert-Path Convert-Path [-Path] <String...
Cmdlet Copy-Item Copy-Item [-Path] <String[]>...
Cmdlet Copy-ItemProperty Copy-ItemProperty [-Path] <S...
Cmdlet Get-Item Get-Item [-Path] <String[]> ...
Cmdlet Get-ItemProperty Get-ItemProperty [-Path] <St...
Cmdlet Invoke-Item Invoke-Item [-Path] <String[...
Cmdlet Join-Path Join-Path [-Path] <String[]>...
Cmdlet Move-Item Move-Item [-Path] <String[]>...
Cmdlet Move-ItemProperty Move-ItemProperty [-Path] <S...
Cmdlet New-Item New-Item [-Path] <String[]> ...
Cmdlet New-ItemProperty New-ItemProperty [-Path] <St...
Cmdlet Remove-Item Remove-Item [-Path] <String[...
Cmdlet Remove-ItemProperty Remove-ItemProperty [-Path] ...
Cmdlet Rename-Item Rename-Item [-Path] <String>...
Cmdlet Rename-ItemProperty Rename-ItemProperty [-Path] ...
Cmdlet Resolve-Path Resolve-Path [-Path] <String...
Cmdlet Set-Item Set-Item [-Path] <String[]> ...
Cmdlet Set-ItemProperty Set-ItemProperty [-Path] <St...
Cmdlet Split-Path Split-Path [-Path] <String[]...
Cmdlet Test-Path Test-Path [-Path] <String[]>...
看到了吗,很容易就把这些与文件系统相关的cmdlet找出来了,有文件或文件夹对象的,有路径的,有兴趣的朋友一个个cmdlet去研究一下。
如果大家觉得光是这个干瘪的cmdlet不好理解,那可以对照一下相关的别名(Alias),就好懂了。命令如下:
Get-Alias -Definition *-item*, *-path* |
Select-Object Name, Definition
输出如下:
Name Definition
---- ----------
cli Clear-Item
clp Clear-ItemProperty
copy Copy-Item
cp Copy-Item
cpi Copy-Item
cpp Copy-ItemProperty
del Remove-Item
erase Remove-Item
gi Get-Item
gp Get-ItemProperty
ii Invoke-Item
mi Move-Item
move Move-Item
mp Move-ItemProperty
mv Move-Item
ni New-Item
rd Remove-Item
ren Rename-Item
ri Remove-Item
rm Remove-Item
rmdir Remove-Item
rni Rename-Item
rnp Rename-ItemProperty
rp Remove-ItemProperty
si Set-Item
sp Set-ItemProperty
cvpa Convert-Path
rvpa Resolve-Path
关于PowerShell中的与文件系统相关的cmdlet,洪哥就说这么多,希望对大家有所帮助,谢谢!
要饭二维码
