Hi,
This article is quite off from my regular PowerShell topic, but it's fun doing it . So the situation is like that, One of my friend wrote a Powershell script but someone he wants to encrypt or password protected so that on one else {his fellow colleagues who just believes in COPYING & PASTING and make no efforts to learning technologies} use it, copy it .
When is asked me this question, i was not sure what to do,,as i always believe is sharing...then VIM come to my mind and in my one previous article i also mentioned about vim in this blog. You can find the article here:
http://newdelhipowershellusergroup.blogspot.in/2011/11/hi-i-hope-some-of-you-know-about-what.html
Let's start.
so we have a enc.ps1 file in D drive and that file contains a two line script.
run the script , So all is good... we have a script file and that file is running successfully.
, I hope that you already have VIM on you laptop if not check my previous article which i mentioned in the beginning of this article.
now just open the enc.ps1 file in vim so that we can check that if file is opening in the vim or not.
ok, file is opening, now press "ESCAPE" key and type q! in vim. {q means quit}
now open the file again with -x parameter on vim. {small x not X (as VIM is based on Linux and Linux is case sensitive)}
Now it ask you to enter a encryption password, provide it .
Ok type the same password again.
It open our .PS1 file,, now type,press "Escape" key again., in colon type wq! and press enter {w=write, q=quit}
okies we are back to our Powershell console.
Now lets open our enc.Ps1 Powershell script file in notepad.
Ooops,, i don't know this "Alien's" scripting language,, i think we need "Sherlock Holmes" to decode it..
Mission accomplished :-)
Now whenever you open the same file in VIM it ask you for password first.
asking for password to open the file.
and if someone runs it. :)
Damn!!!!! :)
oh !!!! and how to change or remove password :)
Open the file in VIM , Enter you password to open it . press "ESCAPE" key and type :X {capital } and hit enter.
if you want to change password provide it , if you want to remove the password, jut keep it blank and press Enter.
Press Enter again
now press "Escape" , type wq! {write, quite, forcefully}
Now we are back in Powershell console. now open the same file in "notepad"
Wow !! we back from where we start.
I hope that you enjoyed this post.
Thanks
Aman Dhally
The theme of your blog is very beautiful and the article is written very well, I will continue to focus on your blog.
ReplyDeletePgp software
Quick question:
ReplyDeleteI've encrypted a ps1 script using VIM as above, now i need to share this script on different computers, but i don't want to share the password or else it will easily decrypted. Is there any way to run it on a powershell providing the password as a secured string?
Sorry, Tyrant,
Deleteby using VIM , if you encrypted the script, then eother you have to share the password, or you have to decrypt it.
:(
i think these are the only tow ways,
thanks
aman