Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

use a secure date value in a user script

$
0
0

I've got a script i'm putting together and i'm at a loss to figure out how to do something. hopefully my description makes sense.

-this script should check the current date and if that does not match the hard coded date it will not continue.

-the script would be accessible to the user and I don't want them to be able to manipulate the hard coded date.

my thought is to convertto-securestring the original and current dates and compare them.

Powershell
$Valid_date=convertto-securestring$secdate-asplaintext-force$current_date=(get-date).ToShortDateString()$current_date-secure=convertto-securestring$secdate-asplaintext-forceif(current_date-secure-eq$Valid_date){[System.Windows.Forms.MessageBox]::Show("This script is valid. ")}else{[System.Windows.Forms.MessageBox]::Show("This script has expired. ")}

or can you think...


Viewing all articles
Browse latest Browse all 15370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>