Suppose I have the following snippet:
$assoc = New-Object PSObject -Property @{
Id = 42
Name = "Slim Shady"
Owner = "Eminem"
}
Write-Host $assoc.Id + " - " + $assoc.Name + " - " + $assoc.Owner
I'd expect this snippet to show:
42 - Slim Shady - Eminem
But instead it shows:
42 + - + Slim Shady + - + Eminem
Which makes me think the +
operator isn't appropriate for concatenating strings and variables.
How should you approach this with PowerShell?
question from:
https://stackoverflow.com/questions/65848544/need-to-delete-multiple-lines-between-two-strings-using-powershell 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…