Powershell CSV Import Issue

JAMES, Clinton 0 Reputation points
2023-05-12T06:40:34.34+00:00

Hi all,

I am tearing out what little hair I have left. I am performing an import-csv routine, filtering it down to one record, to then update one element of that record. Powershell behaves nicely when I want to view the value of the record, but when I go to set a new value, it seems to have Alzheimers and can't find the element that is obviously there. I have tried workarounds to no avail short of making a lengthy code which I need prescribe the element names again to just be in the correct order.

Is anybody able to tell me why this is happening or a viable work-around. Screenshot provided.
Thank you

User's image

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,435 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,240 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 45,431 Reputation points
    2023-05-12T15:31:21.2533333+00:00

    You're creating an array, not a scalar value. Arrays don't have a 'Version' property.

    $InstallerName = "Install_Edge.ps1"
    $Config_Content_Full = Import-Csv "c:\junk\Installer_versions.csv"
    $Item =    @($Config_Content_Full | Where-Object {$_.InstallerName -like    $InstallerName})
    $NotItem = @($Config_Content_Full | Where-Object {$_.InstallerName -notlike $InstallerName})
    
    $Item |
        ForEach-Object{
            $_.Version
            $_.Version = "AAAA"
        }