Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4037588
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:22:00+00:00 2026-05-20T12:22:00+00:00

I have inherited the following Python script: import urllib2 a = urllib2.urlopen(‘http://mysite/mypage.aspx?action=dosomething’) a.read() a.close()

  • 0

I have inherited the following Python script:

import urllib2
a = urllib2.urlopen('http://mysite/mypage.aspx?action=dosomething')
a.read()
a.close()

and I would like to replace it with a powershell script.
I have googled a little but everything I find launches a browser window.

This script is going to be scheduled, so I’d like to just “post and forget” if possible?

Any help very gratefully received 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:22:00+00:00Added an answer on May 20, 2026 at 12:22 pm

    Here is a script I wrote a while back that shows how to post tweets with Geotags. This uses WebClient.

    http://www.ravichaganti.com/blog/?p=979

    Pasting the code here for easy reference.

    Function ByPass-Proxy {
        param ([string]$url)
        $webClient.Proxy.IsBypassed($url)
    }
    
    Function Get-GeoCoordinates {
        param ([String]$location)
        $baseURL = "http://maps.google.com/maps/geo?q="
        $apiKey = "Your API Key"
        $url = $baseURL + $location + "&output=xml&sensor=false&key=" + $apiKey
        $locCoords = (([xml]($WebClient.DownloadString($url))).kml.Response.Placemark.Point.coordinates)
        return $locCoords
    }
    
    Function Send-Tweet {
        param ([string]$Tweet,[string]$location)
        $geoCoord = Get-GeoCoordinates $location
        $long = $geoCoord.Split(",")[0]
        $lat = $geoCoord.Split(",")[1]
        $TwitURL = "http://twitter.com/statuses/update.xml"
        $WebClient.Credentials = $TwitCredentials
        #$str = [System.Text.Encoding]::UTF8.GetBytes( "status="  + $Tweet + "&lat=" + $lat + "&long=" + $long )
        $str = "status="  + $Tweet + "&lat=" + $lat + "&long=" + $long
        [System.Net.ServicePointManager]::Expect100Continue = $false
        $response = $WebClient.UploadString($TwitURL,$str)
        $response
    }
    
    function Get-Credential { 
    ## Grabbed this from http://poshcode.org/1480
    
    [CmdletBinding(DefaultParameterSetName="Better")]
    PARAM(
       [Parameter(Position=1,Mandatory=$false)]
       [Alias("Credential")]
       [PSObject]$UserName=$null,
       [Parameter(Position=2,Mandatory=$false)]
       [string]$Title=$null,
       [Parameter(Position=3,Mandatory=$false)]
       [string]$Message=$null,
       [Parameter(Position=4,Mandatory=$false)]
       [string]$Domain=$null,
       [Parameter(Mandatory=$false)]
       [switch]$GenericCredentials,
       [Parameter(Mandatory=$false)]
       [switch]$Inline
    )
    
    PROCESS {
       if( $UserName -is [System.Management.Automation.PSCredential]) {
          return $UserName
       } elseif($UserName -ne $null) {
          $UserName = $UserName.ToString()
       }
    
       if($Inline) {
          if($Title)    { Write-Host $Title }
          if($Message)  { Write-Host $Message }
          if($Domain) { 
             if($UserName -and $UserName -notmatch "[@\\]") { 
                $UserName = "${Domain}\${UserName}"
             }
          }
          if(!$UserName) {
             $UserName = Read-Host "User"
             if(($Domain -OR !$GenericCredentials) -and $UserName -notmatch "[@\\]") {
                $UserName = "${Domain}\${UserName}"
             }
          }
          return New-Object System.Management.Automation.PSCredential $UserName,$(Read-Host "Password for user $UserName" -AsSecureString)
       }
       if($GenericCredentials) { $Credential = "Generic" } else { $Credential = "Domain" }
    
       ## Now call the Host.UI method ... if they don't have one, we'll die, yay.
       ## BugBug? PowerShell.exe disregards the last parameter
       $Host.UI.PromptForCredential($Title, $Message, $UserName, $Domain, $Credential,"Default")
    }
    }
    
    $global:webClient = New-Object System.Net.WebClient
    $global:TwitCredentials = Get-Credential -title "Twitter Credentials" -message "Please enter your Twitter username/password"
    If (!(ByPass-Proxy "http://www.twitter.com")) {
        $global:Webclient.proxy.Credentials = Get-Credential -title "Proxy Credentials" -message "Please enter username/password for Proxy authentication"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a project that uses the following pattern for passing parameters from
I have the following list in Python: [[1, 2], [3, 4], [4, 6], [2,
I have the following situation in my python code: class Parent(object): def run(self): print
I have the following structure /templates/base.html templates/index.html --- here i have inherited base.html which
(resolved: see bottom) I have the following code snippet: Protected Sub SqlDataSource1_Inserted(ByVal sender As
I have inherited a client site which crashes every 3 or 4 days. It
I have inherited some legacy PHP code what was written back when it was
I have inherited an old crusty PHP application , and I'd like to refactor
I have inherited a VB6/Access application that we have developed and sold for many
I have inherited a poorly written web application that seems to have errors when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.