Domanda

Sto creando un nuovo oggetto per i valori di esportazione in 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

Il problema è che una delle righe contiene un trattino (host-preset). Ovviamente lo cambierei semplicemente in un sottolineato, ma il mio CSV ha bisogno di questo valore per essere un trattino. Potrei anche fare un posto sull'intero CSV dopo che è stato creato, ma sembra sporco. C'è un modo per usare Dash qui?

Il mio errore di errore è:

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

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top