windows

A collection of 47 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.InstanceId }
windows

Powershell批量限制程序网络访问

$exeFileNames = Get-ChildItem -Path "C:\apps folder" -Recurse –File -Include "*.exe" | % { $_.FullName } foreach ($exeFileName in $exeFileNames) { # Code to execute for each item Write-Host "----" Write-Host $exeFileName $existFirewallRule = Get-NetFirewallRule -DisplayName $exeFileName | Where-Object { $_.Action -eq 'Block' -and $_.Direction -eq 'Outbound' -and $_.Enabled -eq $True} if ($null -eq $existFirewallRule) { $newRule = New-NetFirewallRule -DisplayName $e
windows

Office2024 KMS激活提示非正版软件警告

在64位windows上安装32位Office的时候需要在WOW6432Node添加KeyManagementServiceName注册表项 reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /f /v KeyManagementServiceName /t REG_SZ /d "" reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" /f /v KeyManagementServiceName /t REG_SZ /d "" /reg:32 参考 https://massgrave.dev/office-license-is-not-genuine
打印机

Windows 预安装打印机驱动

将打印机驱动复制到可以访问的共享路径 使用以下powershell脚本安装驱动 pnputil.exe /a "\\\koaxpj__.inf.inf" 之后确认安装后打印机驱动的路径,在C:\Windows\System32\DriverStore\FileRepository下 打开inf文件记录下实际打印机型号的名称,如 [KONICA MINOLTA.NTamd64] "KONICA MINOLTA C368SeriesPCL" "KONICA MINOLTA C3851SeriesPCL" 使用以下powershell脚本添加具体驱动 Add-PrinterDriver -Name "KONICA MINOLTA C368SeriesPCL" -InfPath "C:\Windows\System32\DriverStore\FileRepository\koaxpj__.inf_amd64_c4e736b89265dcc3\koaxpj__.inf" Add-PrinterDriver -Name "KONICA MINO
1 min read
windows

Powershell 卸载程序

function Uninstall-Application { $appName = $($args[0]) Write "application to uninstall: $appName" $uninstall32 = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -Match $appName } $uninstall64 = gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match $appName } if($uninstall32){ if($uninstall32.QuietUninstallString){ Write ("uninstall32 Quiet