0

I have a output of PowerCLI stored in a variable. I want to check the string is present in the string, if present continue with for loop.

Below is my script:

$stringtosearch = "test"
$getds = Get-Datastore | Select-Object -ExpandProperty Name
if ($dsname -contains $getds) {
    Write-Host "datastore exists"
    continue
}

The above script is not getting into loop and continuing for loop.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
louis
  • 595
  • 3
  • 9
  • 24

0 Answers0