Ashley
asked on
Computer Name not Showing
So this script shows installed applications but it just becomes a jumble of information and doesnt show the computer name (from a list of servers in a text file). Can someone please tell me how to get that to show? This is a powershell script.
Thanks,
Ashley
InstalledApps.txt
Thanks,
Ashley
InstalledApps.txt
ASKER
I like the CSV output, but it still doesn't show the computer name. I attached the script I ran this time as InstalledAppsNew.txt and the output I received
installedapps.csv
InstalledAppsNew.txt
installedapps.csv
InstalledAppsNew.txt
That is because you changed line 6 from " $computername = $pc" to "$computername = $pc.Computername".
Change that back, or remove the line completely and change the ForEach in line 4 to use $computer instead of $pc:
Change that back, or remove the line completely and change the ForEach in line 4 to use $computer instead of $pc:
foreach ($computer in $computers) {
ASKER
Without the $pc.computername I get:
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
"
At C:\DGS Tools\Scripts\InstalledApp s.ps1:14 char:5
+ $reg=[microsoft.win32.regi strykey]:: OpenRemote BaseKey(‘L ocalMachin e’,$comput ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException
You cannot call a method on a null-valued expression.
At C:\DGS Tools\Scripts\InstalledApp s.ps1:18 char:5
+ $regkey=$reg.OpenSubKey($U ninstallKe y)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\DGS Tools\Scripts\InstalledApp s.ps1:22 char:5
+ $subkeys=$regkey.GetSubKey Names()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
No matter how I run it. I attached what I've run with changing out to $computer. It's the same output as above
InstalledAppsNew.txt
Exception calling "OpenRemoteBaseKey" with "2" argument(s): "The network path was not found.
"
At C:\DGS Tools\Scripts\InstalledApp
+ $reg=[microsoft.win32.regi
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException
You cannot call a method on a null-valued expression.
At C:\DGS Tools\Scripts\InstalledApp
+ $regkey=$reg.OpenSubKey($U
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You cannot call a method on a null-valued expression.
At C:\DGS Tools\Scripts\InstalledApp
+ $subkeys=$regkey.GetSubKey
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
No matter how I run it. I attached what I've run with changing out to $computer. It's the same output as above
InstalledAppsNew.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Question answered.
The most convenient is usually an export as csv, so that you can easily process it further or view it in Excel or whatever:
Open in new window
If you insist on the table view, you'll have to send the output through Out-String before passing it onto the the file:Open in new window