# Help with getting Script to run

**URL:** <https://forums.powershell.org/t/help-with-getting-script-to-run/25601>\
**Category:** PowerShell Help\
**Created:** [March 18, 2025, 2:15pm UTC](https://forums.powershell.org/t/help-with-getting-script-to-run/25601 "2025-03-18T14:15:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![StareDog](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/staredog/32/5947_2.png) [@StareDog](https://forums.powershell.org/u/StareDog)\
**Post date:** [March 18, 2025, 2:15pm UTC](https://forums.powershell.org/t/help-with-getting-script-to-run/25601/1 "2025-03-18T14:15:24Z")

</div>

I am a complete newbie. I am unable to get this script running which I copy and pasted from Holger SCHWICHTENBERG’s book - Powershell 7 und Windows Powershell 5.

# Einstellungen

$InputFileName = “computernamen.txt“  
$OutputFileName = “softwareinventar.csv“  
$Query = “SELECT \* FROM Win32\_Product where not Vendor like ‘%Microsoft%’”

# Eingabedatei auslesen

$Computers = Get-Content $InputFileName

# Schleife über alle Computer

$Software = $Computers | foreach { Get-CimInstance -query $Query -computername $\_ }

# Ausgabe in CSV

$Software | select Name, Description, IdentifyingNumber, InstallDate,  
InstallLocation, InstallState, SKUNumber, Vendor, Version | export-csv  
$OutputFileName -notypeinformation

I put it into Powershell ISE and created the input and output file into a folder. computernamen.txt was put into the system32 folder.

I would appreciate your help to get this running.

Thank you.

---

<div class="post-metadata">

**Author:** ![grey0ut](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/grey0ut/32/5310_2.png) [@grey0ut](https://forums.powershell.org/u/grey0ut)\
**Post date:** [March 18, 2025, 2:32pm UTC](https://forums.powershell.org/t/help-with-getting-script-to-run/25601/2 "2025-03-18T14:32:06Z")

</div>

Hello and welcome to the forum. Please remember to format any shared code/output as “preformatted text” so that it maintains code syntax.  
Guide to posting code

Looking at the code that’s there nothing immediately jumps out at me as wrong.  
It might be time to break this down a bit and try something one at a time. If you’re already in ISE you can use F8, or the “Run Selection” button at the top.  
Execute your variable definitions, and the line defining $Computers. Then manually down in the shell maybe try something like this:

```Powershell
# load the first computer from your list in to a new variable
PS> $Computer = $Computers[0]
# manually run your ciminstance command against just this one computer
PS> Get-CimInstance -Query $Query -ComputerName $Computer

```

If that successfully produced output then you can proceed with running the whole line that defines $Software. When it’s done you can then call $Software from the shell below and make sure it contains objects. If it does, you can export to CSV.

---

<div class="post-metadata">

**Author:** ![david-zemdegs](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/david-zemdegs/32/1461_2.png) [@david-zemdegs](https://forums.powershell.org/u/david-zemdegs)\
**Post date:** [March 19, 2025, 9:24pm UTC](https://forums.powershell.org/t/help-with-getting-script-to-run/25601/3 "2025-03-19T21:24:01Z")

</div>

Win32\_product is evil! Dont use it.

> **[Please Stop Using Win32\_Product To Find Installed Software. Alternatives Inside!](https://xkln.net/blog/please-stop-using-win32product-to-find-installed-software-alternatives-inside/)**
>
> For years I’ve seen blog posts, scripts, forum messages, you name it - all referencing the WMI class when someone is looking for a way to list installed…

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [April 18, 2025, 9:24pm UTC](https://forums.powershell.org/t/help-with-getting-script-to-run/25601/4 "2025-04-18T21:24:08Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
