1
我創造出口值CSV一個新的對象:新物體不能包含破折號( - ),但「需要」
New-Object -TypeName PSObject -Property @{
host_name = ($server.name).ToLower()
address = $IPAddress
host_is_collector = "no"
host-preset = "windows-server"
} | Select-Object host_name,address,host-preset | Export-Csv -Path $nConf_import_host_file
的問題是,其中一條線包含劃線(主機-PRESET)。我當然會簡單地將它改爲下劃線,但我的CSV需要這個值是一個短劃線。在創建完成後,我也可以對整個csv進行更換,但看起來很髒。 有沒有一種方法可以在這裏使用短劃線?
我的錯誤味精是:
Missing '=' operator after key in hash literal.
At Z:\Scripts\Testscripts\ScanServers_and_check_nagiosV7.ps1:336 char:16
+ host-preset <<<< = "windows-server"
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingEqualsInHashLiteral
@Sune沒問題:) – 2012-01-18 13:25:42