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%’”
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:
# 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.