رونوشت در Powershell مانند یک جلسه ضبط است. بنابراین هر زمان که یک رونوشت را در PowerShell شروع می کنید، شروع به ضبط دستورات و خروجی های شما می کند و مهم نیست که خروجی خطایی وجود داشته باشد، آن نیز ضبط می شود. برای شروع رونوشت، باید دستور Start-Transcript را در ابتدا اجرا کنید، و سپس هر چیزی که بنویسید، ضبط می شود.
برای شروع ضبط، باید دستور Start-Transcript را بنویسید و باید مسیر رونوشت را همانطور که در مثال زیر نشان داده شده است، بدهید.
مثال
Start-Transcript -Path C:Tempsessionrecord.txt
پس از وارد کردن دستور بالا، پیامی مانند شکل زیر دریافت خواهید کرد.
Start-Transcript -Path .Sessionrecording.txt
خروجی
PS E:scriptsPowershell> Start-Transcript -Path .Sessionrecording.txt Transcript started, output file is .Sessionrecording.txt
در زیر صفحه جلسه PowerShell پس از شروع رونوشت آمده است.
مثال
PS E:scriptsPowershell> Get-Service | Select -First 2 Status Name DisplayName ------ ---- ----------- Stopped AarSvc_777b7 Agent Activation Runtime_777b7 Running AdobeARMservice Adobe Acrobat Update Service PS E:scriptsPowershell> wrongcommand wrongcommand : The term 'wrongcommand' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + wrongcommand + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (wrongcommand:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
دستورات فوق باید در رونوشت ثبت شوند. به طور همزمان می توانید فایل رونوشت را بررسی کنید که دستورات و خروجی ها به صورت موازی ضبط شده اند.
برای متوقف کردن رونوشت، باید دستور Stop-Transcript را اجرا کنید .
مثال
PS E:scriptsPowershell> Stop-Transcript Transcript stopped, output file is E:scriptsPowershellSessionrecording.txt
اکنون فایل رونوشت sessionrecording.txt ذخیره شده در مکان فعلی را بررسی می کنیم.
********************** Windows PowerShell transcript start Start time: 20200711122407 Username: DESKTOP-9435KM9admin RunAs User: DESKTOP-9435KM9admin Configuration Name: Machine: DESKTOP-9435KM9 (Microsoft Windows NT 10.0.18362.0) Host Application: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe Process ID: 4520 PSVersion: 5.1.18362.752 PSEdition: Desktop PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.18362.752 BuildVersion: 10.0.18362.752 CLRVersion: 4.0.30319.42000 WSManStackVersion: 3.0 PSRemotingProtocolVersion: 2.3 SerializationVersion: 1.1.0.1 ********************** Transcript started, output file is .Sessionrecording.txt PS E:scriptsPowershell> Get-Service | Select -First 2 Status Name DisplayName ------ ---- ----------- Stopped AarSvc_777b7 Agent Activation Runtime_777b7 Running AdobeARMservice Adobe Acrobat Update Service PS E:scriptsPowershell> wrongcommand wrongcommand : The term 'wrongcommand' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + wrongcommand + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (wrongcommand:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException wrongcommand : The term 'wrongcommand' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + wrongcommand + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (wrongcommand:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS E:scriptsPowershell> Stop-Transcript ********************** Windows PowerShell transcript end End time: 20200711124434 **********************
در خروجی بالا متوجه می شوید که کاربری که دستورات را اجرا کرده، نام کامپیوتر، زمان شروع و زمان پایان نیز ثبت می شود.