thorsten-rehm
Goto Top

Powershell Logfile Frage

Hi!

Ich habe mir das mit dem Logfile bei dem Part II des PowerShell For Runaway mal näher angeschaut.
Was mich dabei etwas irritiert, ist die Tatsache, dass man für jeden Befehl den das Skript ausführt, extra auch noch out-file angeben muss.
Gibt es da nichts einfacheres?
Ich stelle mir da was in die Richtung vor:
out-file ALLES WAS JETZT IM ANSCHLUSS IN DER KONSOLE AUSGEGEBEN WIRD, SCHREIB IN EIN LOGFILE!

Habt ihr da nen Tipp für mich?

Content-Key: 93031

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

Ausgedruckt am: 19.03.2024 um 07:03 Uhr

Mitglied: TuXHunt3R
TuXHunt3R 28.07.2008 um 13:52:49 Uhr
Goto Top
Hallo thorsten-rehm

So weit ich weiss, geht das nicht. Sobald meine Ferien aber vorbei sind, werde ich mal mein PowerShell-Buch konsultieren. Es gibt allerdings so eine Art Alias zu dem gesamten "| out-file -filepath C:\log.txt"-Zeugs. Dies sieht ungefähr gleich aus wie bei Batch, also so:

Bestehendes Logfile überschreiben:
"Blabla" >C:\log.txt  

Zeile an bestehendes Logfile anhängen:
"Blabla" >>C:\log.txt  

Achtung:
Die PowerShell legt standardmässig Textfiles im Unicode an. Damit ein ANSI-File erzeugt wird, habe ich überall den Parameter "-encoding default" angehängt. Der Vorteil: Die Files werden nicht zu gross und die 256 Zeichen vom ANSI-Zeichensatz reichen für ein Logfile meiner Meinung nach vollkommen aus.


Grüsse aus der Schweiz
TuXHunT3R
Mitglied: thorsten-rehm
thorsten-rehm 28.07.2008 um 14:06:23 Uhr
Goto Top
Ok, danke mal. Kannst dich ja dann mal melden. Ich probier mal weiterhin was...
Mitglied: TuXHunt3R
TuXHunt3R 28.07.2008 um 16:45:43 Uhr
Goto Top
Wenn du was hast, melde dich. Würde mich auch interessieren.....
Mitglied: thorsten-rehm
thorsten-rehm 28.07.2008 um 17:14:27 Uhr
Goto Top
Ich hab was. Sogar genau so wie ich mir das vorgestellt habe!

PS C:\> get-help Start-Transcript

NAME
    Start-Transcript

SYNOPSIS
    Creates a record of all or part of a Windows PowerShell session in a text file.


SYNTAX
    Start-Transcript [[-path] <string>] [-force] [-noClobber] [-append] [-whatIf] [-confirm] [<CommonParameters>]


DETAILED DESCRIPTION
    The Start-Transcript cmdlet creates a record of all or part of a Windows PowerShell session in a text file. The tra
    nscript includes all command that the user types and all output that appears on the console.


RELATED LINKS
    Stop-Transcript

REMARKS
    For more information, type: "get-help Start-Transcript -detailed".  
    For technical information, type: "get-help Start-Transcript -full".  


Und das passende Gegenstück

PS C:\> get-help Stop-Transcript

NAME
    Stop-Transcript

SYNOPSIS
    Stops a transcript.


SYNTAX
    Stop-Transcript [<CommonParameters>]


DETAILED DESCRIPTION
    The Stop-Transcript cmdlet stops a transcript that was started by using the Start-Transcript cmdlet. You can also s
    top a transcript by ending the session.


RELATED LINKS
    Start-Transcript

REMARKS
    For more information, type: "get-help Stop-Transcript -detailed".  
    For technical information, type: "get-help Stop-Transcript -full".