title: PowerShell Version 2 Invoke-WebRequest
body: <p>I'm needing to run a Powershell script that has the below syntax in it. What would be the PowerShell 2 equivalent of this line be?</p>
  
  <pre><code>Invoke-WebRequest "http://$Server/api/setobjectproperty.htm?id=$Id&amp;name=Inheritscheduledependency&amp;value=0&amp;username=$User&amp;passhash=$Hash" | out-null
  </code></pre>
  
  <p>This is the full script:</p>
  
  <pre><code>param([int]$Id = 5557,[int]$Duration = 1,[string]$Unit = "Hours")
  
  $Server     = "webpage.bla.org"
  $User       = "user"
  $Hash       = "45093450908"
  $DateFormat     = "yyyy-MM-dd-HH-mm-ss";
  $StartDate  = (Get-Date).ToString($DateFormat);
  
  switch($Unit){
  "Minutes"   { $EndDate = (Get-Date).AddMinutes($Duration).ToString($DateFormat); }
  "Hours"     { $EndDate = (Get-Date).AddHours($Duration).ToString($DateFormat); }
  "Days"      { $EndDate = (Get-Date).AddDays($Duration).ToString($DateFormat); }
  default     { $EndDate = (Get-Date).AddHours($Duration).ToString($DateFormat); }
  }
  
  Invoke-WebRequest "http://$Server/api/setobjectproperty.htm?id=$Id&amp;name=Inheritscheduledependency&amp;value=0&amp;username=$User&amp;passhash=$Hash" | out-null
  Invoke-WebRequest "http://$Server/api/setobjectproperty.htm?id=$Id&amp;name=maintenable&amp;value=1&amp;username=$User&amp;passhash=$Hash" | out-null
  Invoke-WebRequest "http://$Server/api/setobjectproperty.htm?id=$Id&amp;name=maintstart&amp;value=$StartDate&amp;username=$User&amp;passhash=$Hash" | out-null
  Invoke-WebRequest "http://$Server/api/setobjectproperty.htm?id=$Id&amp;name=maintend&amp;value=$EndDate&amp;username=$User&amp;passhash=$Hash" | out-null
  </code></pre>
  
  <p>Thanks</p>