MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
October
Sun Mon Tue Wed Thu Fri Sat
   
9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
2024
Months
OctNov Dec


Sun, Jun 30, 2024 9:12 pm

Determining the version of a PDF document

If you have a Portable Document Format (PDF) file and wish to determine the version of the PDF standard used for the document, that information is stored in the first line of the file. You can open the file with a text editor, such as the Windows Notepad application on a Microsoft Windows system and view the first line to determine the PDF version used for the file. You will see %PDF-x.y where x.y is the version of the PDF standard used in the creation of the file, e.g., %PDF-1.7 for version 1.7.

On a Microsoft Windows system, you could also open a PowerShell window (you can type PowerShell in the Windows Search field and click on the application when you see it returned in the list of results) and use the Get-Content cmdlet and the -First parameter followed by the number one. E.g.:

PS C:\> Get-Content "July 2024 Newsletter.pdf" -First 1
%PDF-1.7
PS C:\>

Related:

  1. PowerShell Get-Content equivalents to Linux head and tail commands
    Date: March 22, 2024

[/os/windows/PowerShell] permanent link

Mon, Apr 15, 2024 9:01 pm

Calculating a hash value for a file with Get-FileHash

The PowerShell cmdlet Get-FileHash provides a cryptographic hash function that will allow you to determine a hash value of a file on a Microsoft Windows system. By default, the cmdlet uses the SHA-256 hash function, but you can specify other functions, such as MD5, using the -Algorithm parameter. You can change the output to a list format by piping the output of the cmdlet to Format-List.

PS C:\users\public\downloads> Get-FileHash ".\rel_x64_Xming-7-7-1-1-setup.exe"

Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
SHA256          B7B4C0A191E315686A2481DCC8BBB27D6D7A156FBF689768E48CF08207B86560       C:\users\public\downloads\rel...


PS C:\users\public\downloads> Get-FileHash ".\rel_x64_Xming-7-7-1-1-setup.exe" | Format-List


Algorithm : SHA256
Hash      : B7B4C0A191E315686A2481DCC8BBB27D6D7A156FBF689768E48CF08207B86560
Path      : C:\users\public\downloads\rel_x64_Xming-7-7-1-1-setup.exe



PS C:\users\public\downloads> Get-FileHash -Algorithm MD5 ".\rel_x64_Xming-7-7-1-1-setup.exe"

Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
MD5             BA200636A596A84E0877901CE89D1C2E                                       C:\users\public\downloads\rel...


PS C:\users\public\downloads>

[ More Info ]

[/os/windows/PowerShell] permanent link

Fri, Mar 22, 2024 9:44 pm

PowerShell Get-Content equivalents to Linux head and tail commands

The Windows PowerShell Get-Content cmdlet can provide the equivalent to the Unix/Linux head and tail commands. E.g., suppose a file named somefile.txt contains the following ten lines:
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10

The following Get-Content commands could be used to obtain the first 5 and the last 5 lines in the file.

PS C:\Users\Arnold\Documents> Get-Content somefile.txt -Head 5
line 1
line 2
line 3
line 4
line 5
PS C:\Users\Arnold\Documents> Get-Content somefile.txt -Tail 5
line 6
line 7
line 8
line 9
line 10
PS C:\Users\Arnold\Documents> Get-Content somefile.txt -TotalCount 5
line 1
line 2
line 3
line 4
line 5
C:\Users\Arnold\Documents>

The TotalCount parameter can function like the Head parameter and will return the first x number of lines specified with x being 5 in the example above. You can also use it to obtain a specific line, though. E.g., if you wished to see the 7th line in the file, you could use the command below.

PS C:\Users\Arnold\Documents> (Get-Content Somefile.txt -TotalCount 7)[-1]
line 7
PS C:\Users\Arnold\Documents>

By default the delimiter for lines is the newline, aka end-of-line character, \n, but you can change that with the -Delimiter parameter.

References:

  1. Get-Content
    Microsoft Learn

[/os/windows/PowerShell] permanent link

Fri, Sep 15, 2023 5:14 pm

Determining the Serial Number of a Disk Drive with PowerShell

If you need to determine the serial number of a hard disk drive (HDD) attached to a Microsoft Windows system, you can do so from a PowerShell window using the cmdlet Get-Disk (you can open a PowerShell window by typing PowerShell in the Windows "Type here to search field on a Windows 10 system and then selecting the app when it is returned in the list of search results). If you just want a list of drives attached to the system by a USB connection, you can pipe the output of the cmdlet to the