powershell

A collection of 5 posts
windows

Powershell移除隐藏设备

#获取所有隐藏设备 $unknown_devs = Get-PnpDevice | Where-Object{$_.Status -eq 'Unknown'} #打印 $unknown_devs | Format-Table #过滤想移除的设备 $removeDeviceFriendlyName="Insert Device Name Here" $remove_devs = $unknown_devs | Where-Object{$_.FriendlyName -eq $removeDeviceFriendlyName} #打印 #$remove_devs | Format-Table #使用pnputil删除所有设备 ForEach($dev in $remove_devs){ #移除注释执行 # pnputil /remove-device $dev.
powershell

Powershell 操作 windows更新

定义更新搜索 $Criteria = "IsInstalled=0 and Type='Software'" 搜索可用的更新 $Searcher = New-Object -ComObject Microsoft.Update.Searcher $SearchResult = $Searcher.Search($Criteria).Updates 下载更新 $Session = New-Object -ComObject Microsoft.Update.Session $Downloader = $Session.CreateUpdateDownloader() $Downloader.Updates = $SearchResult $Downloader.Download() 安装更新 $Installer = New-Object -ComObject Microsoft.Update.Installer $Installer.Updates
1 min read