2.Using Windows PowerShell Cmdlets and 3.Leveraging PowerShell Providers

简介: PS C:/> get-alias dirPS C:/> get-childitem C:/get-childitem |format-listget-childitem C:/ | format-list -property nameget-chi...

PS C:/> get-alias dir
PS C:/> get-childitem C:/
get-childitem |format-list
get-childitem C:/ | format-list -property name
get-childitem C:/ | format-list -property name, length
get-childitem C:/ | format-wide
get-childitem C:/Windows
get-childitem C:/Windows -recurse -include *.txt
get-childitem C:/Windows -recurse -include *.txt |format-wide -column 3
get-childitem C:/Windows -recurse -include *.txt |format-wide -property
name -groupby length -column 3
get-childitem C:/ | format-table
get-childitem C:/Windows
get-childitem C:/Windows -recurse -include *.txt
get-childitem C:/Windows -recurse -include *.txt |format-tableget-childitem C:/Windows -recurse -include *.txt |format-table -property
name, length, lastwritetime


get-command *
get-alias g*
gcm get-command
gcm get-command |format-list *
gcm get-command | format-list -property definition
(gcm get-command).definition
gcm -verb se*
gcm -noun o*
gcm -syntax get-command
gcm -syntax gcm
Get-Command
get-childitem C:/ | get-member
get-alias g*
gal g*
gal g* |sort-object -property definition
gci | gm
get-childitem | get-member -membertype property
get-childitem | get-member -membertype method
get-childitem | get-member -membertype m*
$wshShell = new-object -comobject "wscript.shell"
$wshShell.run("calc.exe")
$wshShell.ExpandEnvironmentStrings("%windir%")
test-path $profile
new-item -path $profile -itemtype file -force
notepad $profile
Set-alias gh get-help
function pro {notepad $profile}
gal | where-object {$_.definition -match "get-childitem"}
gci
gci | where-object {$_.length -gt 1000}
cls
gal cls
gal mred
clear-host
get-childitem | get-member -membertype property
get-childitem | where-object {$_.LastWriteTime}
get-childitem | where-object {$_.LastWriteTime -gt "12/25/2006"}
get-childitem "C:/fso"| where-object {$_.LastWriteTime -gt "12/25/2006"}
get-childitem -recurse "C:/fso"| where-object {$_.LastWriteTime -gt "12/25/2006" }
$wshnetwork = new-object -comobject "wscript.network"
$wshnetwork.EnumPrinterConnections()
$wshnetwork.EnumNetworkDrives()
$colPrinters = $wshnetwork.EnumPrinterConnections()
$colDrives = $wshnetwork.EnumNetworkDrives()
$userName = $wshnetwork.UserName
$userDomain = $wshnetwork.UserDomain
$computerName = $wshnetwork.ComputerName
$wshShell = new-object -comobject "wscript.shell"
$wshShell.Popup($userDomain+"/$userName $computerName")
$wshShell.Popup($colPrinters)
$wshShell.Popup($colDrives)

3.##################################################################################################Leveraging PowerShell Providers
Get-PSProvider
sl alias:/
GCI
GCI | Where-Object {$_.name -like "s*"}
Get-ChildItem |Get-Member
GCI | Where-Object {$_.definition -like "set*"}
GCI | Where-Object {$_.name -like "*w*"}
GCI | where {$_.name -like "*w*"}
Set-Location cert:/
Get-ChildItem
Get-ChildItem -recurse
GCI -path currentUser
sl currentuser/authroot
GCI | where {$_.subject -like "*c&w*"}
GCI | where {$_.subject -like "*SGC Root*"}
GCI | where {$_.thumbprint -eq "F88015D3F98479E1DA553D24FD42BA3F43886AEF"}
GCI | where {$_.thumbprint -eq "F88015D3F98479E1DA553D24FD42BA3F43886AEF"} |Format-List *
Certmgr.msc
Invoke-Item cert:/
Get-PSDrive
Set-Location env:/
Get-Item *
get-item * | Sort-Object  -property name
get-item windir
get-item windir | Format-List *
GI * | Sort -Property Name
New-Item -Path . -Name admin -Value mred
Get-Item admin
Get-Item admin | Format-List *
GCI | Sort -Property name
New-Item -Path . -Name admin -Value mred
Rename-Item -Path env:admin -NewName super
GCI | Sort -Property name
New-Item -Path . -Name super -Value mred
Remove-Item super
GCI C:/
GCI C:/ | where {$_.psiscontainer}
GCI C:/ | where {!$_.psiscontainer}
GCI  -Path C:/ | GM
GCI  -Path C:/ | GM | Where {$_.membertype -eq "property"}
GCI  -Path C:/ | GM | where {$_.membertype -eq "property" -AND $_.typename -like "*file*"}
GI * | Where {$_.PsisContainer -AND $_.name -Like "*my*"}
RI mytest -recurse
GI * | Where {$_.PsisContainer -AND $_.name -Like "*my*"}
New-Item -Path C:/ -Name mytest -Type directory
New-Item -Path C:/mytest -Name myfile.txt -type file
RI -Path C:/mytest/myfile.txt
New-Item -Path C:/mytest -Name myfile.txt -Type file -Value "My file"
Get-Content C:/mytest/myfile.txt
Add-Content C:/mytest/myfile.txt -Value "ADDITIONAL INFORMATION"
Get-Content C:/mytest/myfile.txt
Set-Content C:/mytest/myfile.txt -Value "Setting information"
Get-Content C:/mytest/myfile.txt
Set-Location function:/
GCI
GCI | Where {$_.definition -like "set*"}
GCI | Where {$_.definition -notlike "set*"}
Get-Content md
get-psDrive | where {$_.Provider -like "*Registry*"}
GCI -path HKLM:/software
GCI -Path 'HKLM:/SOFTWARE/Microsoft/Windows NT/CurrentVersion/HotFix'
GCI -Path 'HKLM:/SOFTWARE/Microsoft/Windows NT/CurrentVersion/HotFix' | where {$_.Name -like "*KB928388"}

Get-Help *variable | Where-Object {$_.category -eq "cmdlet"}
Get-Help *variable | Where-Object {$_.category -eq "cmdlet"} | Format-List name, category, synopsis
SL variable:/
Get-ChildItem
Get-ChildItem | Sort {$_.Name}
Get-Variable ShellId
Get-Variable ShellId | Format-List *
New-Variable administrator
Get-Variable administrator
Set-Variable administrator -value mred
Get-Variable administrator
Remove-Variable administrator
Get-Variable administrator
Get-ChildItem |Get-Member | Where-Object {$_.membertype -eq "property"}
Get-PSDrive |where {$_.name -like "c*"}
Sl cert:/
GCI
GCI -recurse
GCI -recurse >C:/a.txt;notepad.exe a.txt
new-PSDrive -name al -PSProvider alias -Root.
SL al:/
GCI | Sort -Property name
GCI | sort -Property name | Where {$_.Name -gt "t"}c
SL C:/
Remove-PSDrive al
Get-PSDrive
Get-Item -Path env:/
Get-Item -Path env:/ | Get-Member
$objEnv=Get-Item -Path env:/
$objEnv.Count
$objEnv.Get_count
$objEnv.Get_count()
$objEnv.GetType()

目录
相关文章
|
4月前
|
Unix Shell Windows
Windows PowerShell技巧:使用findstr实现类似grep的功能
显示带有线路编号**: `/N`选项将显示每条结果前面带有其在线路上出现位置编号。
744 7
|
4月前
|
存储 Windows
Windows PowerShell操作:如何删除环境变量
此外,还有一些第三方工具可以用来管理环境变量,这些工具通常提供了更为用户友好的界面来添加、编辑或删除环境变量,但是使用PowerShell可以更直接地控制这些设置,并且可以很容易地集成到脚本中以自动化环境配置的管理。
611 7
|
安全 Shell Linux
内网渗透测试基础——Windows PowerShell篇
内网渗透测试基础——Windows PowerShell篇
646 0
|
Windows
【vscode】 VsCode终端崩溃C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe已终止,退出代码:2
【vscode】 VsCode终端崩溃C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe已终止,退出代码:2
3567 1
|
XML 监控 数据格式
利用powershell进行windows日志分析
0x00 前言   Windows 中提供了 2 个分析事件日志的 PowerShell cmdlet:一个是Get-WinEvent,超级强大,但使用起来比较麻烦;另一个是Get-EventLog,使得起来相当简单,可以实时筛选,接下来,我们利用PowerShell 来自动筛选 Windows 事件日志。
2867 0
|
存储 Ubuntu Linux
windows可以安装Ubuntu,ubuntu上也可以安装Powershell
powerhsell除了可以在windows上使用外,还可以在Ubuntu上部署开发环境。下面介绍Ubuntu上安装powershell的方法。
650 0
|
Shell Linux 开发工具
windows中cmd和PowerShell批处理命令
之前在 Git 批量删除本地分支,有用到 Linux 或 MacOS 下的批处理命令,这个命令中的 grep、xargs 本身是 Shell script,在 windows 中的 cmd 和 PowerShell 中是不能用的
|
JavaScript Windows
[Vue]解决 Windows PowerShell 不识别 vue 命令的问题
[Vue]解决 Windows PowerShell 不识别 vue 命令的问题
|
Windows
使用PowerShell获取Windows当前锁屏壁纸
使用PowerShell获取Windows当前锁屏壁纸 如果原始图片丢了,用这段代码就可以提取当前锁屏壁纸了!
352 0