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

Printed on: April 18, 2024 at 04:04 o'clock

Mitglied: 135111
Solution 135111 Jan 09, 2018 updated at 13:47:12 (UTC)
Goto Top
Export-Csv
Export-CSV Doku lesen dort findest du den Parameter -Append
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell. ...