基本上需要写powershell给我的子目录的列表。在子目录中,我的文件夹结构是101.10.1 101.10.2 101.10.3现在想写一个条件,从文件夹(101.10.3)取一个更高的目录,然后删除ms SQL 2005应用程序。
像这样的
****$path = "C:abcxyzhVersions"
$contents = Get-ChildItem -Path $path | sort | Select-Object -Last 10
$contents.Name
$condition = $contents.Name
if ( $condition -gt "$path/$condition" )
{
# do something"
}****
假设你有:
101.10.1
101.10.2
101.10.211
101.10.3
101.10.323
101.10.4
101.10.5
101.10.610
如果运行这个命令:
gci | sort -property name | ?{$_.name -gt '101.10.3'} | %{ echo "dosomething $_" }
你:
dosomething 101.10.323
dosomething 101.10.4
dosomething 101.10.5
dosomething 101.10.610
现在,你可以改变echo "dosomething $_"到另一个有用的命令。