Thao tác với disk iscsi trên windows core

Lấy thông tin disk đã map (powershell):

 Get-IscsiSession | Get-Disk | Get-Partition | ft DiskNumber, DriveLetter

Get-IscsiSession | Get-Disk | Get-Partition | Select DiskNumber, PartitionNumber, DriveLetter

Get-IscsiSession | Get-Disk | Get-Partition | Get-Volume | Select DriveLetter, FileSystemLabel, FileSystem, SizeRemaining, Size
  

Online lại disk:

- Diskpart (cmd) > select disk

- Online disk 

- sửa readonly: Attributes disk clear readonly

 

Gỡ license 365 cho hàng loạt username

 # Gỡ license cho hàng loạt username từ file csv, có 1 cột UserToDisable
$csvPath = "D:\OneDrive\Downloads\Documents\ReportM365\UserToDisable.csv"
$users = Import-Csv $csvPath

$domain = "@tamanhhospital.vn"

# License cần remove
$targetLicenses = @(
    "4b585984-651b-448a-9e53-3b10f069cf7f", # Microsoft 365 F3
    "f8ced641-8e17-4dc5-b014-f5a2d53f6ac8", # Office 365 E1
    "46c3a859-c90d-40b3-9551-6178a48d5c18", # Office 365 E3
    "3ab6abff-666f-4424-bfb7-f0bc274ec7bc", # Microsoft Teams Essentials
    "7e31c0d9-9551-471d-836f-32ee72be4a01" # Microsoft Teams Enterprise (Teams add-on)
)

foreach ($user in $users) {
    try {
        # Ghép domain vào username
        $userId = $user.UserToDisable.Trim() + $domain

        # Get license hiện tại
        $currentLicenses = (Get-MgUser -UserId $userId -Property AssignedLicenses).AssignedLicenses.SkuId

        # Lọc license cần remove
        $removeLicenses = $targetLicenses | Where-Object { $_ -in $currentLicenses }

        if ($removeLicenses.Count -gt 0) {
            Set-MgUserLicense -UserId $userId -AddLicenses @() -RemoveLicenses $removeLicenses
            Write-Host "$userId - Removed license" -ForegroundColor Green
        }
        else {
            Write-Host "$userId - No target license" -ForegroundColor Yellow
        }
    }
    catch {
        Write-Host "$($user.UserToDisable) - ERROR: $($_.Exception.Message)" -ForegroundColor Red
    }
}

Tăng dung lượng cho Datastore

    Tăng (resize) cho volume trên SAN
    vSphere => Rescan storage
    vSphere => chọn storage > Action > Increase Storage Capacity > done
    check lại dung lượng đã tăng đủ

Upgrade cho ManageEngine theo lộ trình

Tải file update từ hãng, theo phiên bản đang sử dụng 

 https://www.manageengine.com/products/service-desk/on-premises/migration-sequence.html

Stop service:

net stop "ManageEngine ServiceDesk Plus" 

Chạy tool update: 

C:\ManageEngine\ServiceDeskPlus\bin\UpdateManager.bat

Làm theo hướng dẫn để backup rồi cài. Thời gian backup có thể khá lâu tùy lượng data đã có

Các bản archive: https://archives.manageengine.com/service-desk/
 

 

Update cho Windows Server Core

Import-Module PSWindowsUpdate Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -AutoReboot

Reset time cho remote desktop

# Remove-RDSTimebomb.ps1
# Remove registry value start with "L$RTMTIMEBOMB" in key GracePeriod
# Require: run as Administrator

$ErrorActionPreference = 'SilentlyContinue'
$path = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod"
if (Test-Path $path) {
    $values = (Get-Item $path).GetValueNames() | Where-Object { $_ -like "L$RTMTIMEBOMB*" }
    foreach ($v in $values) {
        try {
            Remove-ItemProperty -Path $path -Name $v -Force
            Write-Output ("{0} - Removed: {1} in {2}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $v, $path)
        } catch {
            Write-Output ("{0} - Error {1}: {2}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $v, ${_}.Exception.Message)
        }
    }
} else {
    Write-Output ("{0} - Not found key GracePeriod." -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'))
}
Write-Output "Success."

Cấu hình syslog cho SAN HP MSA 1040

 Xem thông số hiện tại:

# show syslog-parameters
Syslog Parameters
-----------------
Syslog Host IP: 0.0.0.0
Syslog Notification Level: none
Syslog Host Port: 0

Cấu hình thông số:

set syslog-parameters   [host-ip <IP-address>]   [host-port <port-number>]   notification-level crit|error|warn|info|none

Để xem hướng dẫn: thêm help ở đầu dòng 

Upgrade Microsoft Entra Connect Sync

Bản Entra Connect Sync cũ hơn thông báo dưới đây sẽ bị dừng hoạt động, không sync được nữa, do đó cần lên bản mới nhất có thể.

 

https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-upgrade-previous-version

Chú ý kiểm tra .NET và TLS như trong thông báo

Tự động gán user mới vào group AD

Tình huống:

User mới, tạo từ app nên đã được cho sẵn vào các OU, cần add group tương ứng OU cho user.

Xử lý:

- Tạo 1 file csv mapping các OU với AD Group cần thiết: "C:\bat\OU_List.csv". Export toàn bộ các OU bằng script:

Import-Module ActiveDirectory

$output = "C:\bat\OU_List.csv"
$ous = Get-ADOrganizationalUnit -Filter * | Select-Object Name, DistinguishedName
$ous | Export-Csv -Path $output -NoTypeInformation -Encoding UTF8
Write-Host "Exported to: $output"
 

Thao tác với disk iscsi trên windows core

Lấy thông tin disk đã map (powershell):   Get-IscsiSession | Get-Disk | Get-Partition | ft DiskNumber, DriveLetter Get-IscsiSession | Get-Di...