adminst
Goto Top

Powershell output auf neue Linie

Hallo zusammen
Ich möchte gerne meine Clients auf die Spectre/Meltdown lücken testen mit dem Skript von MS.
Die Hosts stehen im c:\temp\computers.txt. Als erstes soll ein Check gemacht werden, ob der Client online ist. Wenn ja, soll der Test ausgeführt werden und das Resultat ins csv in eine neue
Linie geschrieben werden.

PS Skript
</$computers = Get-Content "C:\temp\computers.txt"  

foreach ($computer in $computers) {
    #Überprüfen ob der PC läuft
    if(Test-Connection $computer -Count 2) {
      
      Import-Module SpeculationControl

$scriptstring = Get-Content -Path (Get-Module SpeculationControl).Path | % { if (-not ($_ -match “^\# “)) { $_ }} | Out-String
$scriptstring += '  
function Write-Host {}

'  
$scriptstring += 'Get-SpeculationControlSettings'  

$script=[scriptblock]::create($scriptstring)

$results = Invoke-Command -ComputerName $computer -ScriptBlock $script
$results | Export-Csv .\SpeculationControlSettings.csv -NoTypeInformation



    } else {
        Write-Output "Der Computer $computer ist momentan nicht erreichbar."  
    }
}
Das Problem ist, dass es mir im Moment das CSV überschreibt, es sollte jedoch das Resultat jedes Clients auf eine weitere Zeile einfügen.
Kann mir jemand dabei helfen?

Danke und Gruss
adminst

Content-Key: 360443

Url: https://administrator.de/contentid/360443

Ausgedruckt am: 19.03.2024 um 04:03 Uhr

Mitglied: 135111
Lösung 135111 09.01.2018 aktualisiert um 14:47:12 Uhr
Goto Top
Export-Csv
Export-CSV Doku lesen dort findest du den Parameter -Append
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell. ...