xud6的笔记本

徐岱青

Powershell 卸载程序

 •  Filed under 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: " + $uninstall32.QuietUninstallString)
            Start-Process -FilePath cmd.exe -ArgumentList '/c', $uninstall32.QuietUninstallString  -Wait
        }else{
            Write ("uninstall32 Normal: " + $uninstall32.UninstallString)
            Start-Process -FilePath cmd.exe -ArgumentList '/c', $uninstall32.UninstallString  -Wait
        }
    }
    if($uninstall64){
        if($uninstall64.QuietUninstallString){
            Write ("uninstall64 Quiet: " + $uninstall64.QuietUninstallString)
            Start-Process -FilePath cmd.exe -ArgumentList '/c', $uninstall64.QuietUninstallString  -Wait
        }else{
            Write ("uninstall64 Normal: " + $uninstall64.UninstallString)
            Start-Process -FilePath cmd.exe -ArgumentList '/c', $uninstall64.UninstallString  -Wait
        }
    }
}

Uninstall-Application("application name*")

PowerShell 自动提权

 • 

添加至脚本头

param([switch]$Elevated)

function Test-Admin {
    $currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
    $currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}

if ((Test-Admin) -eq $false)  {
    if ($elevated) {
        # tried to elevate, did not work, aborting
    } else {
        Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
    }
    exit
}

'running with full privileges'

Centos 开启 dns缓存

 •  Filed under centos, centos7

安装nscd

yum install nscd

在有IPA Client(或SSSD)的情况下修改/etc/nscd.conf中enable-cache为如下

enable-cache hosts yes
enable-cache passwd no
enable-cache group no
enable-cache netgroup no
enable-cache services no

启动

systemctl enable nscd
systemctl restart nscd

验证已经开启

time getent hosts www.bing.com

结果中

real    0m0.002s
user    0m0.001s
sys     0m0.000s

real 几乎等于 user + sys

centos 8 自动更新

 •  Filed under centos, centos8, linux

安装dnf-automatic

dnf install dnf-automatic

编辑/etc/dnf/automatic.conf

apply_updates = yes

启动定时器

systemctl enable --now dnf-automatic.timer

树莓派启动优化

 • 

关闭蓝牙

编辑/boot/config.txt添加

dtoverlay=disable-bt

或pi3B+对应选项
关闭蓝牙串口服务

sudo systemctl disable hciuart

关闭avahi

sudo systemctl disable avahi-daemon

关闭启动时彩虹屏幕

编辑/boot/config.txt添加

# Disable the rainbow splash screen
disable_splash=1

远程桌面服务通过远程桌面网关访问时提示发生验证错误(代码:0x607)

 •  Filed under windows, RemoteDesktopService, RDS

错误出现在远程桌面连接代理认证成功,连接至分配的远程桌面会话主机时。如果直接通过远程桌面网关访问远程桌面会话主机或者不通过远程桌面网关都正常
同时远程桌面会话主机的RemoteDesktopService-RdpCoreTS日志出现TCP 套接字读取操作失败,出现错误 64

原因为远程桌面会话主机上的证书有问题。
检查并删除 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\SSLCertificateSHA1Hash (如果存在)
检查组策略计算机配置/策略/管理模板/Windows 组件/远程桌面服务/远程桌面会话主机/安全/服务器身份验证证书模板确保未设置

更改后重启即可恢复

Windows 智能卡维护

 • 

查询智能卡

certutil -scinfo

其中

================ 证书 0 ================
--- 读卡器: FS USB Token 0
---   卡: xxxxxx
提供程序 = Microsoft Base Smart Card Crypto Provider
密钥容器 = te-PKIAuthUser-xxxxxxxx-xxxx-xxxx-xxxxx [默认容器]

提供程序为
密钥容器为

删除智能卡上证书

certutil -delkey -csp “<name of CSP>” “<key container>”