Use PowerShell v3 to Keep a CookieJar and POST to a Web Form That Prohibits XSS

In my previous post, I outlined how to use PowerShell v2 to keep a CookieJar and POST to a Web Form that Prohibits XSS. The code was 35 lines long. Upon seeing my post, Lee Holmes suggested using PowerShell v3’s Invoke-WebRequest instead to get my code down to 1/5th of its original size.

I’m astounded at how easy Invoke-WebRequest made this task. It took care of knowing what type of authentication is required (Basic, in my example), and the cookie jar/session. So now I’m down from 35 lines of code to this:

Bravo, PowerShell team :D

Chrissy is a PowerShell MVP who has worked in IT for nearly 20 years, and currently serves as a Sr. Database Engineer in Belgium. Always an avid scripter, she attended the Monad session at Microsoft’s Professional Developers Conference in Los Angeles back in 2005 and has worked and played with PowerShell ever since. Chrissy is currently pursuing an MS in Systems Engineering at Regis University and helps maintain RealCajunRecipes.com in her spare time. She holds a number of certifications, including those relating to SQL Server, SuSE Linux, SharePoint and network security. She recently became co-lead of the SQL PASS PowerShell Virtual Chapter. You can follow her on Twitter at @cl.

Posted in PowerShell

Leave a Reply

Your email address will not be published. Required fields are marked *

*