search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
How to connect secure web page with Powershell?
Posted in Windows Powershell | 5 Comments | 7,580 views | 31/05/2009 08:32

You can connect to secure web pages with powershell using your username and password.

1
2
3
4
5
6
7
$url = "http://secure.yusufozturk.info/secured_page.aspx"
$username = "ysfozy"
$pass = "my_password"
$domain = "DOMAIN"
$webclient = new-object System.Net.WebClient
$webclient.Credentials = new-object System.Net.NetworkCredential($username, $pass, $domain)
$webpage = $webclient.DownloadString($url)

Simply use write-host to see contents of the web page.


Comments (5)

Randy

June 22nd, 2009
23:03:44

Hi Yusuf
I am new to Powershell and am trying to make your script work for me. I’ve tried to use write-host to write the content to the screen but it’s not working. Can you give me a little more guidance on how to make the web page write to the screen? Thanks.


admin

June 23rd, 2009
00:08:32

Hello Randy,
Did you try “write-host $webpage” to see contents? Also I posted a new article about how to parse a webpage and see specific parts of the web page. You can reach post from here:
http://www.yusufozturk.info/powershell/how-to-parse-a-web-page-and-find-a-specific-info-with-powershell.html


Randy

June 23rd, 2009
01:03:45

Ahh. Such a easy mistake. Thank you for your help. Your examples are really awesome.


admin

June 23rd, 2009
01:30:57

You are welcome :)


Anis

October 14th, 2011
12:08:34

Thanks ! It’s a useful script in corporate contexts where usage of a web browser is restricted on servers.



Leave a Reply