I am trying to copy files that match an environment identifier set to a variable. The output of the command looks good until in include the where-object section. I only want to copy files that contain the string in the $environmenttype string.
What do I need to change to get the where-object to operate correctly?
$environmenttype = "dev"
Write-Output "environmenttype is set to $environmenttype"
Get-ChildItem -path "\content" | Select-Object -ExpandProperty name | Where-Object {$_ -contains "$environmenttype"} | Copy-Item -Path "C:\newdir"