0

I am trying to put together a quick little script to help when I am using OpenSSL, for some reason I can't seem to get PowerShell to append the hostname to the front of my CSR file. It is basically giving me things like _09_26_2017.txt instead of something like hostname_09_26_2017.txt.

I have the following

$date = Get-Date -format MM_dd_yyyy
$csrName = $siteName + "_" + $date

$siteName = Read-Host "Enter the site name"

.\openssl.exe req -newkey rsa:4096 -sha256 -nodes -keyout "$siteName.pem" -out "$csrName.txt"

Any help would be greatly appreciated. Thank you very much in advance.

0

1 Answer 1

2

You define $sitename after you define $csrname. So

$csrName = $siteName + "_" + $date 

is behaving as

$csrName = $null + "_" + $date

Simply define $sitename before you try to use by moving the line up:

$date = Get-Date -format MM_dd_yyyy
$siteName = Read-Host "Enter the site name"
$csrName = $siteName + "_" + $date

.\openssl.exe req -newkey rsa:4096 -sha256 -nodes -keyout "$siteName.pem" -out "$csrName.txt"
Sign up to request clarification or add additional context in comments.

1 Comment

Oh wow, I can't believe I missed that. Yeah, that was it... Thank you so much for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.