我想在这部分代码中添加条件:
$objInfos = New-Object PSObject -Property @{
Dossier = [string]"$($logs[0])"
"Taille totale" = [double]$logs[1]
"Categorie recherchee" = [double]$logs[2]
"Pourcentage" = [double]$logs[3]
"Date de dernier acces" = [DateTime]"$($logs[5])"
}
我需要每个案例都有条件,比如:
$objInfos = New-Object PSObject -Property @{
if ($test -eq 1){
Dossier = [string]"$($logs[0])"
}
"Taille totale" = [double]$logs[1]
"Categorie recherchee" = [double]$logs[2]
"Pourcentage" = [double]$logs[3]
"Date de dernier acces" = [DateTime]"$($logs[5])"
}
我尝试过这种方式,但没有奏效
散列文字中的键后缺少“=”运算符。
请问有人知道该怎么做吗?