Goal is to do the following using batch script:
- Extract hostname from windows machine.
- apply sha256 hash on hostname value (obtained from step1).
My system's hostname is: W0000000000ZQ
My batch script looks like this:
@echo off
hostname>hostname.txt
CertUtil -hashfile hostname.txt SHA256 //<- this is generating wrong sha256 string because
// the above generated file contains CRLF and a new line
// screenshot of this file provided below.
CertUtil -hashfile hostname-manual.txt SHA256 //<- this is generating correct sha256 string because
// i manually created this file and pasted hostname
// only (W0000000000ZQ) without CRLF and new line.
// screenshot of this file provided below.
hostname.txt:
hostname-manual.txt
Output from the script:
Can you please suggest how to remove CRLF and a newline from "hostname.txt" so that Certutil will pick correct string to generate sha256 value.


