Hello,
I am trying to check if some software is installed on a remote system. I can get it to work if I do all the work inside of a ScriptBlock but if I try and do anything outside of the ScriptBlock I dont see what I feel like I should see (This is where I am having problems understanding). Here is inside the ScriptBlock:
Invoke-Command -cn $servername -ScriptBlock { $inst = Get-ItemProperty HKLM:SoftwareWow6432NodeMicrosoftWindowsCurrentVersionUninstall* | select displayname $inst += Get-ItemProperty HKLM:SoftwareMicrosoftWindowsCurrentVersionUninstall* | select displayname If ($inst.displayname -match "heat"){ "Heat Installed" } }
I get the correct output “Heat installed”.
When I run it like this I am unable to verify the $installed.displayname but I can see it if I just look at the information stored in $installed.
$installed = Invoke-Command -cn $servername -ScriptBlock { Get-ItemProperty HKLM:SoftwareWow6432NodeMicrosoftWindowsCurrentVersionUninstall* | select displayname Get-ItemProperty HKLM:SoftwareMicrosoftWindowsCurrentVersionUninstall* | select displayname }
What am I misunderstanding about being able to access the data in $installed in a way that I can use it?
submitted by /u/cpizzer
[link] [comments]
The post Going nuts checking for software on a remote system!! appeared first on How to Code .NET.