Skip to content

Windows的一些常用命令

hyper-v

powershell
#关闭
bcdedit /set hypervisorlaunchtype off
#启用
bcdedit /set hypervisorlaunchtype auto

通过 Powershell 获取 md5

powershell
function Get-FormattedFileLastWriteTime {
    param (
        [string]$filePath,
        [string]$format = "yyyy-MM-dd HH:mm:ss"
    )

    # 获取文件对象
    $fileItem = Get-Item $filePath

    # 获取文件的修改时间并将其格式化
    $formattedTime = $fileItem.LastWriteTime.ToString($format)

    return $formattedTime
}

function Get-FileMD5Hash {
    param (
        [string]$filePath
    )

    # 使用 Get-FileHash cmdlet 计算文件的 MD5 哈希值
    $fileHash = Get-FileHash -Algorithm MD5 -Path $filePath

    # 获取 MD5 哈希值的字符串表示
    $md5Hash = $fileHash.Hash

    return $md5Hash
}

function info {
    param (
        [string]$filePath
    )
    echo (Get-FormattedFileLastWriteTime $filePath)
    echo (Get-FileMD5Hash $filePath)
}