我想用另外 4 个字符串替换 4 个字符串并将它们写入文件。
$file = 'C:\Defender.psd1'
(Get-Content $file) | ForEach-Object {
$_.replace("'MSFT_MpSignature.cdxml',", "'MSFT_MpSignature.cdxml')")
$_.replace("'MSFT_MpWDOScan.cdxml')", "")
$_.replace("'Remove-MpThreat',", "'Remove-MpThreat')")
$_.replace("'Start-MpWDOScan')", "") `
} | Out-File $file
Run Code Online (Sandbox Code Playgroud)
但文件中的每个字符串都被重复了 4 次。脚本将用于 PowerShell 4 和 5.1。
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.bmp\OpenWithProgids -Name Paint.Picture -Type None -Value ([byte[]]::new(0)) -Force
Run Code Online (Sandbox Code Playgroud)
在 Windows 10 中可以运行,但在 Windows 8.1 中存在问题。
powershell ×2