CSV sample:
I have the below code, where I would like to overwrite the current value in the PreviousGroup field. I know that -append
adds to the end of the column, but that's not what I want to do.
$UserGroup = read-host "Enter Group Name"
$csvFile = Import-Csv "C:\HomeFolder\Locations.csv"
if ([string]::IsNullOrEmpty($PreviousGroup)) {$PreviousGroup = ""}
else {$PreviousGroup = $csvFile | Select-Object $csvFile.PreviousGroup -Verbose}
$csvFile.PreviousGroup = $UserGroup
$csvFile | Export-Csv
Secondly, is it possible to link Dom*_Groups in the below code to the list on the CSV?
param([Parameter(Mandatory = $false)]
[ValidateSet(*"list from csv"*)] [string]$Dom1_Groups)
param([Parameter(Mandatory = $false)]
[ValidateSet(*"list from csv"*)] [string]$Dom2_Groups)