我想提出條件,我的這部分代碼:PSObject,物業與條件
$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])"
}
我試着這種方式並沒有工作
鍵入哈希文字後缺少'='運算符。
有人知道該怎麼做嗎?
你可以用'添加-Member'添加該物業如果需要。我看到你最近在這裏問了一些問題,但還沒有接受任何答案,儘管已經有一些好的答案。請這樣做,或者對作者發表評論,以便他們可以根據需要進行修改。 – arco444