$results not changing in form - Job

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: $results not changing in form - Job

Post by apowershelluser »

The if statement is not working in the GUI but does in the ISE
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: $results not changing in form - Job

Post by jvierra »

How do you know. Did you run my code in the GUI? Write-Host outputs the value returned.

If Write-Host Product $product returns a blank product then the "if" didn't match.
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: $results not changing in form - Job

Post by apowershelluser »

I did and it was working as expected :D

I found my problem

I wasn't looking in the IF statement :(
But I'm rocking now
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: $results not changing in form - Job

Post by apowershelluser »

Working as expected once I figured out. Unfortunately, your script was pulling exactly as I was. But I’m still curious J how you would do it

Two different laptops
The registry model name is the same
Only difference is the processor

How would you, remotely distinguish between the two?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: $results not changing in form - Job

Post by jvierra »

If you Invoke-Command or call Get-WmiObject, both return "PsComputerName" of the remote system.
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: $results not changing in form - Job

Post by apowershelluser »

jvierra wrote: Thu Jan 04, 2018 3:04 pm If you Invoke-Command or call Get-WmiObject, both return "PsComputerName" of the remote system.
I know the computername
I need the model of the PC
So if you had two remote PCs
HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS\SystemProductName

Is the exact same

How would you differentiate between the two?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: $results not changing in form - Job

Post by jvierra »

Invoke-Command returns objects if you allow it to. The objects contain the computername.
Run the following and use any remote system to see what is returned.

Code: Select all

$sb = { Get-ItemProperty hklm:\HARDWARE\DESCRIPTION\System\BIOS }
Invoke-Command -ScriptBlock $sb -ComputerName Ws701 | 
    Select-Object PsComputerName, SystemProductName
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: $results not changing in form - Job

Post by apowershelluser »

jvierra wrote: Thu Jan 04, 2018 5:50 pm Invoke-Command returns objects if you allow it to. The objects contain the computername.
Run the following and use any remote system to see what is returned.

Code: Select all

$sb = { Get-ItemProperty hklm:\HARDWARE\DESCRIPTION\System\BIOS }
Invoke-Command -ScriptBlock $sb -ComputerName Ws701 | 
    Select-Object PsComputerName, SystemProductName
Yup now imagine, Ws701 and Ws702 have the same data return

How would you identify which is which, not using the PSComputerName
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: $results not changing in form - Job

Post by jvierra »

You can't.
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: $results not changing in form - Job

Post by apowershelluser »

jvierra wrote: Thu Jan 04, 2018 6:51 pmYou can't.
Hence where the processor comes into play :)
This topic is 6 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked