powershell 获取文件的第一个 x MB

标签 powershell

获取文本文件的前 x 行非常简单,但我需要文件的前 x MB。鉴于我是 PowerShell 新手,如果您能在脚本上给我一些注释,我将不胜感激。

最佳答案

Get-Content foo.exe -TotalCount 1MB -Encoding byte

如果您碰巧正在使用 PowerShell Community Extensions然后这样做:
Format-Hex foo.exe -count 1MB

注意:如果您使用的是 PowerShell V2,请确保获取 PSCX 的 1.2 测试版。

关于powershell 获取文件的第一个 x MB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/888063/

相关文章:

windows - 通过 Get-WmiObject : Exception calling SetDefaultPrinter : Not Supported 设置默认打印机时出错

azure - 从 Azure Blob 下载特定文件的列表

PowerShell,检测根父文件夹的正确方法

powershell - powerShell Set-acl奇怪的错误: there is not enough space on the disk

powershell - 通过appcmd检查iis模块是否存在

windows - 使用包含双引号的密码提取存档

powershell - 如何使用Powershell捕获DISM输出并使用进度条反射(reflect)状态?

Azure powershell Get-AzAutomationWebhook : Parameter set cannot be resolved

powershell - Powershell和自动化

linux - 如何从文件夹中的所有文件中删除具有特定字符串的行