Forum Discussion
ezflow
Oct 07, 2022Copper Contributor
Get Current Month and Time
Hi,
We are automating user creation in the AD (on Prem). For the password field we want the following
to be capture in powershell in the following formatt: Month@HourMinunte or October@945
I want to pass it as a variable and not hardcoded
$dstPassword = "October@945 " | ConvertTo-SecureString
- LainRobertsonSilver Contributor
$Months = @("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $Timestamp = [datetime]::UtcNow; $dstPassword = "$($Months[$Timestamp.Month - 1])@$($Timestamp.ToString('hmm'))" | ConvertTo-SecureString -AsPlainText -Force;
Cheers,
Lain
- fatherjackCopper Contributor