通过PowerShell快速初始化Windows Server 2019

powercfg /SETACTIVE 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
powercfg /LIST


Get-WmiObject -Class Win32_volume -Filter 'DriveType=5' |
  Select-Object -First 1 |
  Set-WmiInstance -Arguments @{DriveLetter='X:'}

# Set CD/DVD Drive to X:
$cd = $NULL
$cd = Get-WMIObject -Class Win32_CDROMDrive -ComputerName $env:COMPUTERNAME -ErrorAction Stop 
if ($cd.Drive -eq "D:")
{
   Write-Output "Changing CD Drive letter from D: to A:"
   Set-WmiInstance -InputObject ( Get-WmiObject -Class Win32_volume -Filter "DriveLetter = 'd:'" ) -Arguments @{DriveLetter='x:'}
}




"rescan" | diskpart
Get-Disk | where-object Isoffline -eq $True
Get-Disk | Where-Object FriendlyName

Initialize-Disk -Number 1 -PartitionStyle GPT
New-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter
Format-Volume -DriveLetter D -FileSystem NTFS -AllocationUnitSize 65536 -Confirm:$false

Get-WmiObject -Class Win32_Volume | Select BlockSize, Name | Format-Table -AutoSize
fsutil behavior query DisableDeleteNotify

Remove-WindowsFeature -Name "FS-SMB1"


Set-NetFirewallRule -Name FPS-ICMP4-ERQ-In -Enabled True
New-NetFirewallRule -DisplayName "SQL Server default instance" -Direction Inbound -LocalPort 1433 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "SQL Server Browser service" -Direction Inbound -LocalPort 1434 -Protocol UDP -Action Allow
netsh advfirewall set allprofiles state ons

Rename-Computer WIN-PACS-DB
shutdown -r -f -t 0

new-itemproperty -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name LocalAccountTokenFilterPolicy -Value 1


get-windowsfeature Net-Framework-Core
Install-WindowsFeature Net-Framework-Core -source D:\sxs
get-windowsfeature Net-Framework-Core


w32tm /config /syncfromflags:manual /manualpeerlist:"192.168.89.200"
w32tm /config /update
w32tm /resync
whoami /user

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注