#Histroy : # 2013/9/6 get-service **获得服务信息命令 echo "List the service that stopped " Get-Service | Where-Object...into file ." echo "the content of test.bat" cat test.bat echo "Using the Remove-Item Cmdlet " **删除文件操作命令...echo "After move " ls Move-Item c:\test\hello.txt c:\ -force echo "rename file or folder" **重命名文件命令...command :" get-childitem -recurse echo "Get-ChildItem env: " Get-ChildItem env: echo "get item with.../不包含条件 Get-ChildItem c:\* -exclude *.txt,*.log echo "get item by sort " **查看文件按文件大小排序: Get-ChildItem
执行命令 Get-PSDrive一、别名 Alias ProviderAlias Provider用来标记其他命令的对象,一般用来标记命令中比较长的函数或者命令,也支持在PowerShell当中指定CMD...命令如下: #进入别名provider cd alias: # 查询可用的别名 get-childItem# 获取别名的个数,操作系统版本不同可能会有差异get-childItem |measure...命令如下:# 进入环境变量providercd env:# 查询当前系统的环境变量列表get-childitem四、文件系统 FileSystem Provider文件系统是使用最频繁的Provider...命令如下:#进入功能函数Providercd function:#获取可用的功能函数列表get-childitem 说明:当前获取到的函数可以直接在PowerShell环境中执行。...命令:cd variable:get-childitem说明:变量的Provider只有单一层级。
简介: powershell命令仅输出目录列表 powershell命令仅输出目录列表 大于powershell 3.0版本可以使用Get-Item、ls、dir、gci Get-Item Get-ChildItem...-Directory Get-ChildItem "$path" | where {$_.Attributes -match'Directory'} Get-ChildItem "$path" -attributes...D -Recurse ls(alias) dir 小于powershell 3.0版本 Get-ChildItem -Recurse | ?...{ $_.PSIsContainer } Copy 如果你想要目录的原始字符串名称,你可以这么做 Get-ChildItem -Recurse | ?
PowerShell 脚本进阶:如何统计目录大小并包含隐藏文件 目录 引言 PowerShell 基础:Get-ChildItem 和文件统计 2.1 Get-ChildItem 基本用法 2.2...PowerShell 基础:Get-ChildItem 和文件统计 2.1 Get-ChildItem 基本用法 Get-ChildItem(别名 dir 或 ls)是 PowerShell 中用于列出文件和目录的核心命令...默认情况下,Get-ChildItem 不会返回隐藏或系统文件。...3.2 -Force 参数的作用 -Force 参数让 Get-ChildItem 返回 所有 文件,包括: 隐藏文件 系统文件 只读文件 示例:列出所有文件(含隐藏文件) Get-ChildItem...-Directory -Force:包含隐藏目录 Get-ChildItem -Recurse -File -Force:递归计算所有文件(含隐藏文件) 5.
Get-ChildItem -Path C:\Parent -Depth 2 # 使用Depth参数获取项(深度) # 3.获取当前目录和子目录中的子项(递归显示) Get-ChildItem -Path...-Path Cert:\* Get-ChildItem -Path Cert:\* -Recurse -CodeSigningCert # 获取具有代码签名权限的所有证书 Get-ChildItem...描述: md 命令是New-Item 命令别名....# 2.批量重命令将后缀为.txt得文件重名为.log结尾得文件(可以采用正则匹配元组来设置重命名得名称-思路值得学习) Get-ChildItem *.txt | Rename-Item -NewName...如果Tee对象是管道中的最后一个命令,则命令输出将显示在提示处(类似于Linux中的tee命令)。
Bash 脚本常见优化方法减少外部命令调用 尽量减少对外部命令的调用,使用内置命令或 shell 功能替代。...# 不推荐 foreach ($item in (Get-ChildItem C:\path\to\directory)) { Write-Host $item.Name }# 推荐 Get-ChildItem...# 不推荐 $files = Get-ChildItem C:\path\to\directory foreach ($file in $files) { if ($file.Length -gt...1MB) { Write-Host $file.Name } }# 推荐 Get-ChildItem C:\path\to\directory | Where-Object {...Select-Object Name | ForEach-Object { Write-Host $_.Name }使用 Measure-Command 测量执行时间 使用 Measure-Command 测量脚本或命令的执行时间
文件和目录操作 Get-ChildItem(别名:ls, dir, gci)是最常用的命令之一,用来列出文件和目录: # 列出当前目录所有文件 Get-ChildItem # 递归列出所有子目录的文件...Get-ChildItem -Recurse # 只显示文件夹 Get-ChildItem -Directory # 按大小排序显示文件 Get-ChildItem | Sort-Object Length...用来过滤对象: # 获取大于100MB的文件 Get-ChildItem | Where-Object {$_.Length -gt 100MB} # 获取最近7天修改的文件 Get-ChildItem...,我把一些常用的CMD命令和对应的PowerShell命令做个对比。...-然后按Tab,会循环显示所有可用参数 历史命令 PowerShell会记录你执行过的命令,可以用以下方式查看和使用: # 查看命令历史 Get-History # 执行历史中的特定命令 Invoke-History
是时候要掌握用命令行管理IIS了。在网上找了半天没有很好的教程,那就自己写一份吧,以后就不用再整理相关知识了,直接看这篇文章应该就可以了。...命令行管理IIS的方式现在比较流行的是Powershell,还另外一种方式,我这里就不讨论了。今天我主要还是分享使用Powershell来管理IIS。...Powershell对app pool管理 1.1 查看: Get-ChildItem –Path IIS:\AppPools Get-ItemProperty –Path IIS:\AppPools\...不确定 get-childItem IIS:SslBindings $cert = Get-ChildItem cert:\localmachine\my $bindingInfo = "IIS:\SSLBindings...view=winserver2012-ps 最后提一句Get-WebConfigurationProperty和Set-WebConfigurationProperty是非常强大的命令,需要配合IIS的配置文件进行使用
Linux痕迹清理 登陆linux机器后不想让别人知道执行的命令:history unset HISTORY HISTFILE HISTSAVE HISTZONE HISTORY HISTLOG; export...[root@centos]# last //查询不到登录成功的信息 清除相关日志信息: 清除用户最后一次登录时间:echo > /var/log/lastlog #lastlog命令...清除当前登录用户的信息:echo > /var/log/utmp #使用w,who,users等命令 清除安全日志记录:cat /dev/null > /var/log/...Security -Force | % {Wevtutil.exe cl $_.Logname} PowerShell对文件修改时间戳 Function edit_time($path){$date1 =Get-ChildItem...| Select LastWriteTime|Get-Random;$date2 =Get-ChildItem | Select LastWriteTime|Get-Random;$date3 =Get-ChildItem
Error: 0x800737013、使用AdvancedRun提权到TrustedInstaller执行命令删除KB5035849相关注册表后卸载WinDefend成功之所以删除kb5035849相关注册表...(Get-ChildItem...Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages" $pattern = "*KB5035849*" $keys = Get-ChildItem...key in $keys) { Remove-Item -Path "$path$key" -Recurse -Force -ErrorAction SilentlyContinue } (Get-ChildItem
比如下面的例子我们打开PowerShell,然后输入 New-Item 命令会提示位于命令管道位置 1 的 cmdlet New-Item请为以下参数提供值:Path[0]:这个时候我们不输入参数,直接点击回车按钮...get-help get-childitem -parameter *具体展示如下图:CodeSigningCert 表示为开关类型的数据,示例:D盘创建一个logs文件夹,文件夹内容如下图:首先获取文件夹内容get-childitem执行结果如下图:这里增加Recurse参数,这个参数可以实现下一级文件夹的递归访问...,命令如下:get-childitem -Recurse执行结果如下图:说明:针对开关函数,不需要去指定 true 和false ,如果加上 -参数,表示为true,如果执行命令不增加参数,表示为false...通过查询帮助命令的具体参数可以了解该命令是否有支持位置定义的函数。如下图的Path参数就是支持位置定义的参数。
.dll文件输入目录的绝对路径 空格 .dll,然后按路径排序,然后按住shift选择system32根目录的文件,右击点复制完整路径和文件名,粘贴到记事本文件里即可图片方法2:用powershell命令...比较牛逼的代码Get-ChildItem -Path C:\Windows\System32 -Filter ***.dll** -File | Sort-Object Length -Descending...| ForEach-Object { $_.Name }Get-ChildItem -Path C:\Windows\System32 -Filter ***.dll** -File | Sort-Object...Length -Descending | ForEach-Object { $_.BaseName }(Get-ChildItem -Path C:\Windows\System32 -Filter
我们可以使用powershell命令查看文件的所有属性(ls)[0]|fl *命令解析:以列表的形式展示当前目录第一个文件的所有信息 ?...powershell的命令为Get-ChildItem -Recurse -Filter *.php G:\ | sort -Descending CreationTime | Select-Object...FullName,Length,CreationTime,LastWriteTime | Select-Object -First 10命令解析:查找G盘所有目录下最新创建的10个PHP文件,并展示出文件路径...最后 为了真正修改文件时间,在使用菜刀修改文件时间后,还需要执行命令powershell ((Get-ChildItem shell.php).CreationTime='2000/8/30 23:
[TOC] 0x00 对象操作处理相关命令 描述: 下述命令常用于对象的相关操作,涉及创建、排序分组与比较等。 Get-Command -Noun Object | ?...$($p.Name) -Force } } Get-Member 命令 - 对象属性和方法获取 描述: Get-Member 可帮助发现可用于命令的对象、属性和方法。...Tips : 若要通过管道将命令传递到 Get-Member,命令必须生成基于对象的输出,例如以下命令是不行的 Get-Service -Name w32time | Out-Host | Get-Member...因此无法通过管道将该命令传输到 Get-Member。 。...Get-ChildItem -Path C:\Test | Sort-Object # 2.按文件长度对当前目录排序 PS> Get-ChildItem -Path C:\Test -File | Sort-Object
cmd或linux用户快速熟悉,所以我们找到其真正的标准名称是Get-ChildItem。...Get-ChildItem -Path F:\自媒体相关\其他文章分享\powershell\文件夹遍历 -Recurse 可以按【运行选择】将当前选择状态下的代码运行。...\childItems.csv 最后我们用PowerShell管道将Get-ChildItem和Export-Csv串起来,管道就是一个竖线符号,代表前面的结果直接输送到后面使用,即前面生成的文件、文件夹信息...,流到后面输出csv命令使用,代码如下: Get-ChildItem -Path F:\自媒体相关\其他文章分享\powershell\文件夹遍历 -Recurse | Export-Csv -Encoding...Default -Force -LiteralPath "F:\自媒体相关\其他文章分享\powershell\childItems.csv" 然后就生成了一个csv文件,里面存有我们Get-ChildItem
以隐藏的D:\Ghost和D:\Ghost\Backup.GHO为例 cmd命令: attrib +s +h +r /s /d D:\Ghost attrib -s -h -r /s /d D:\Ghost...cd /d "D:\Ghost" attrib +s +h +r /s /d *.* attrib -s -h -r /s /d *.* 上面几句cmd命令对应的powershell命令如下 Get-Item...Path "D:\Ghost" -Force | ForEach-Object { attrib -H -S -R $_.FullName } Set-Location -Path "D:\Ghost" Get-ChildItem...-Path "D:\Ghost" -Recurse -Force | ForEach-Object { attrib +H +S +R $_.FullName } Get-ChildItem -Path...-Value Normal Set-ItemProperty -Path "D:\Ghost\Backup.GHO" -Name Attributes -Value Normal powershell命令
folderPath = "C:\Your\Folder\Path" # 请修改为你的实际文件夹路径# 进入目标文件夹Set-Location $folderPath# 获取所有符合条件的文件$files = Get-ChildItem...-ForegroundColor Green方案二:简洁的单行命令对于熟悉PowerShell的用户,可以使用这个紧凑版本:Get-ChildItem "CDZCQ_500×263_*" | ForEach-Object...$_.BaseName -replace '.*_'))$($_.Extension)"; Rename-Item $_.Name $newName }技术解析核心代码逻辑文件筛选:$files = Get-ChildItem...建议先运行预览版本确认效果:# 预览模式 - 只显示将要重命名的文件,不实际执行$folderPath = "C:\Your\Folder\Path"Set-Location $folderPath$files = Get-ChildItem
背景:使用uupdump.net下载ISO过程中可能各种原因中途失败,会有dism mount残留,如何处理这些残留很关键,否则后面没法正常使用uupdump.net下载ISO,或者dism命令使用出现异常...Cleanup-Mountpoints dism /Cleanup-Wim # 定义注册表路径 $regPath = "HKLM:\SOFTWARE\Microsoft\WIMMount\Mounted Images" # 使用Get-ChildItem...递归遍历注册表项 Get-ChildItem -Path $regPath -Recurse | ForEach-Object { # 获取当前项的所有子项 $subKeys = Get-ItemProperty
”里面所有mp3文件标题名中的字符串“trimmed_佩格和小猫【英文版】” Deepseek的回复: 适用于 PowerShell 的脚本: PowerShell 脚本 powershell 复制 Get-ChildItem...NewName = _.Name -replace "trimmed_佩格和小猫【英文版】", "" Rename-Item -Path _.FullName -NewName NewName } 解释: Get-ChildItem...以下是修正后的 cmd 命令: CMD 命令 cmd 复制 for %f in ("F:\佩格和小猫\*.mp3") do @ren "%f" "%%~nxf:trimmed_佩格和小猫【英文版】=_%...复制PowerShell 脚本,在文件夹中右击,点击:在终端中打开 进入powershell命令行界面,粘贴刚才复制的脚本,然后按下enter键,运行脚本 文件标题全部重命名完成:
文件管理 常用命令 先来看看常用的文件管理命令。 Set-Location命令用于切换工作目录,它的别名是cd。 Get-Location命令用于获取当前工作目录,它的别名是pwd。...Get-ChildItem命令用于获取当前目录下的所有文件。 Get-Item命令用于获取给定文件的信息。...PS D:\devtools\cmder_mini> Get-ChildItem *.md 目录: D:\devtools\cmder_mini Mode...Get-ChildItem|Where-Object {$_ -match '\w*.md$' -and $_.Length/1kb -gt 5} 最后,Get-ChildItem不仅可以列出当前文件夹下的所有内容...Get-ChildItem -Recurse *.exe 修改hosts 访问谷歌的一种方式就是更改hosts文件。这里就用Powershell做一个修改hosts的功能。