Hi All I'm trying to extract a word from a text output. It should be pretty easy but I've already spent so much time on it. Right now I can extract the line but not just the word.
For example
w32tm /query /status | Select-String -pattern "CMOS"
outputs the line "Source: Local CMOS Clock"
I only want to extract "Local CMOS Clock"
$var1=w32tm /query /status | Select-String -pattern "CMOS"
$var2=($var1 -split ':')[1] | Out-String
I was able to come up with the above it seems to work I'm not sure if there's a better way, I'm trying to evaluate it through a true/false seem to always pass as true though For example
if($var2 = "Local CMOS Clock"){
Write-Output "True";
}Else{
Write-Output "False";
}
Always true: even when the condition is wrong
thanks in advance.