Atermon
Atermon

Reputation: 111

True or False output to column

I use this script to import the csv file and modify it and then export it I want to read the data in column 'Member of' and if string '[Admin...whatever string...]' found, output in column 'Admin Priviledges' should be TRUE else FALSE.

I try with boolean like below:

Import-Csv csvdatacol.csv |
  Select-Object Name, Hostname, 'Last Logon Date', 'Member of',
                @{n='Admin Priviledges';e={[bool]()}}

Upvotes: 0

Views: 867

Answers (1)

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200373

Use something like this in the expression for the field "Admin Privileges":

@($_.'Member Of' -replace '^\[|\]$' -split ',') -contains 'Administrators'

Upvotes: 1

Related Questions