Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

If Else statement comparing variables not working as hoped.

$
0
0

Hi all, 

I have been searching for an answer for this for days now, so hopefully someone here can show me what I'm doing wrong. 

Also, forgive me, I am just learning coding. 

So I have this code:

Function NameCheck() 
{

$x = Get-WmiObject -Class Win32_Bios | select PSComputerName
$y = Get-WmiObject -Class Win32_Bios | Select SerialNumber


if($x -eq $Y)
{ 
Write-Host "All good here."
}

else
{
Write-Host "We need to be Synched up."
}

}

no by my reckoning, if the serial number and the device name are the same, I should be getting All good here, but after renaming the machine I am still getting We need to be Synched up..

Can anyone point out the obvious to me please?

Cheers 

Paddy


Judge not the man by the accomplishments but by the effort he exerts to accomplish.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>