▍Windows Server¶
Примонтировать SMB шару:¶
> New-PSDrive -Name "X" -PSProvider "FileSystem" -Root "\\srv-nas\w2k" -Scope 'Global' -Persist
Name Used (GB) Free (GB) Provider Root CurrentLocation
---- --------- --------- -------- ---- ---------------
X 767,47 401,88 FileSystem \\srv-nas\w2k
$registryPath="HKCU:\Network\X"
New-ItemProperty -Path $registryPath -Name ConnectionType -Value 1 -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $registryPath -Name DeferFlags -Value 4 -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' -Name EnableLinkedConnections -Value 1 -PropertyType 'DWord'
или так:
Установить Windows Admin Center¶
## Download the msi file
Invoke-WebRequest 'https://aka.ms/WACDownload' -OutFile "$pwd\WAC.msi"
## install windows admin center
$msiArgs = @("/i", "$pwd\WAC.msi", "/qn", "/L*v", "log.txt", "SME_PORT=6666", "SSL_CERTIFICATE_OPTION=generate")
Start-Process msiexec.exe -Wait -ArgumentList $msiArgs
New-NetFirewallRule -DisplayName "Allow Windows Admin Center" -Direction Outbound -profile Domain -LocalPort 6666 -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "Allow Windows Admin Center" -Direction Inbound -profile Domain -LocalPort 6666 -Protocol TCP -Action Allow
Проверка сетевого подключения¶
> Test-NetConnection -Port 6666 -ComputerName 192.168.0.15 -InformationLevel Detailed
ComputerName RemotePort RemoteAddress PingSucceeded PingReplyDetails (RTT) TcpTestSucceeded
------------ ---------- ------------- ------------- ---------------------- ----------------
192.168.0.15 6666 192.168.0.15 False True
Если в браузере наблюдаем ошибку ERR_UNSAFE_PORT
, то в свойствах ярлыка браузера, например, хрома добавляем параметр:
--explicitly-allowed-ports=6666
Активировать удаленное подключение через Powershell
Показать сколько места занято/свободо¶
Get-WmiObject -Class Win32_LogicalDisk |
Select-Object -Property DeviceID, VolumeName, @{Label='FreeSpace (Gb)'; expression={($_.FreeSpace/1GB).ToString('F2')}},
@{Label='Total (Gb)'; expression={($_.Size/1GB).ToString('F2')}},
@{label='FreePercent'; expression={[Math]::Round(($_.freespace / $_.size) * 100, 2)}}|ft
или
Отключение запроса на перезагрузку/выключение сервера¶
if ( -Not (Test-Path 'registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Reliability'))
{
New-Item -Path 'registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT' -Name Reliability -Force
}
Set-ItemProperty -Path 'registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Reliability' -Name ShutdownReasonOn -Value 0