“PowerShell mengimpor file CSV ke pScustomObject” Kode Jawaban

Impor PowerShell File CSV

import-csv c:\users\[username]\Documents\MyImportFile.csv -delimiter ";"  
Pheatus

PowerShell mengimpor file CSV ke pScustomObject

# CSV file format:
# Variable, Value, Filter
# var1, val1, env1

Write-Verbose "Importing CSV File with Variables for env $VarNameFilter : $CsvFileVar"
$csv = Import-Csv $CsvFileVar

$variables = @()
$csv | Where-Object { $_.Filter -eq $VarNameFilter -or $_.Filter -like $VarNameFilter } | ForEach-Object { 
    $variables += [pscustomobject]@{
        Name = $_.Variable;
        Value = $_.Value;
    }
}
Magnificent Mallard

Jawaban yang mirip dengan “PowerShell mengimpor file CSV ke pScustomObject”

Pertanyaan yang mirip dengan “PowerShell mengimpor file CSV ke pScustomObject”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya