Ive been having a blast playing with Powershell but Ive ran into what I think is a simple issue that has me stumped.
Invoke-Command -ComputerName $i -ScriptBlock {foreach ($i in $i)
{Write-Output "Name: $i" + "`n" + "=========================="; Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Format-Table –AutoSize}} -credential $cred
Its in the Write-Output portion. I want each result returned to start with the hostname so I know which results belong to which system.
Currently I get this output
Name:
+
==========================
With this {“Name:” + $i + “`n” + “==========================”; I get
Name:
I know $i has to have my variable in it or my script wouldnt work at all.
Thanks in advance!