0

I've got the following bit of powershell checking a version file on the back of one of my apps.

invoke-webrequest "https://mypi.mydomain/version.htm" | Select-Object -Property Content

This returns a version number and the environment name:

Content             
-------             
0.3.552.2 webapilive

Trying to get some powershell to search the content for either webapilive or webapilive1 text.

This is to be used in Octopus Deploy and used across two different environments setup in Blue Green deployments. I need it to fail if trying to webapilive on top of webapilive app.

The powershell above returns the content from the page but need to figure out how to check it.

John Fox
  • 747
  • 1
  • 13
  • 28

2 Answers2

1

You have already selected the specific property. If you just want to check the content without the headers then just use the Dot method to access it.

(invoke-webrequest "https://mypi.mydomain/version.htm" | Select-Object -Property Content).Content

You can access any property like this.

Ranadip Dutta
  • 8,857
  • 3
  • 29
  • 45
0

Two ways of doing this is:

Wrap everything in parenthesis like ().content

$var = (invoke-webrequest "https://mypi.mydomain/version.htm" | Select-Object -Property Content).content
if($var -like "*webapilive*")
{
 # Your code
}

Or save it to a var and use $var.content

$var = invoke-webrequest "https://mypi.mydomain/version.htm" | Select-Object -Property Content
if($var.content -like "*webapilive*")
{
 # Your code
}
Desinternauta
  • 74
  • 1
  • 8