XDQ的笔记本

windows

A 10 post collection


Powershell 操作 windows更新

 •  Filed under 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 = $SearchResult
$Result = $Installer.Install()

检查是否需要重启

$Result.rebootRequired

PS脚本

function log($str){
    Write-Host $str
}

#Define update criteria.
$Criteria = "IsInstalled=0 and Type='Software'"

#Search for relevant updates.
$Searcher = New-Object -ComObject Microsoft.Update.Searcher
$SearchResult = $Searcher.Search($Criteria).Updates
$MissingPatches = @($SearchResult).length
log("$($MissingPatches) patches found")
$SearchResult | select Title,IsBeta,IsHidden,IsInstalled,MsrcSeverity | Format-Table -AutoSize

if($MissingPatches -gt 0){
    #Download updates.
    log("download updates")
    $Session = New-Object -ComObject Microsoft.Update.Session
    $Downloader = $Session.CreateUpdateDownloader()
    $Downloader.Updates = $SearchResult
    $Downloader.Download()

    #Install updates.
    log("install updates")
    $Installer = New-Object -ComObject Microsoft.Update.Installer
    $Installer.Updates = $SearchResult
    $Result = $Installer.Install()

    $Result
    #Reboot if required by updates.
    if($Result.rebootRequired){
        log("Reboot required")
    }else{
        log("Reboot not required")
    }
}else{
    log("no patch found")
}

robocopy

 •  Filed under windows
ROBOCOPY "\\servername\sharelocation" "\\newservername\newsharelocation" /MIR    /SEC /LOG:location:\nameoflogfile

Windows Server Core 配置 Windows Internal Database 内存限制

 •  Filed under windows, wid, sql server
安装Microsoft ODBC Driver 13.1 for SQL Server

http://go.microsoft.com/fwlink/?LinkId=825608

安装Microsoft Command Line Utilities 13.1 for SQL Server

https://www.microsoft.com/en-us/download/details.aspx?id=53591

执行sqlcmd
cd c:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn
SQLCMD.EXE -E -S \\.\pipe\Microsoft##WID\tsql\query
显示高级选项
exec sp_configure 'show advanced option', '1';
reconfigure;
查询当前设置(max server memory行)
exec sp_configure;
go
设置内存限制为(2048MB)
exec sp_configure 'max server memory', 2048;
reconfigure with override;
go
退出
quit
重启wid服务