Assignment 3 Sawan

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Assignment- 3

Course: Windows server and PowerShell

Title: Writing Transcript

Submitted to: kamal deep mam

Submitted by: Sawan kumar

Aim: to learn how to create a profile in PowerShell by using transcript.

Ex. 3.1

Ex 3.2# Create new folders

New-Item -ItemType Directory -Path C:\PS -ErrorAction SilentlyContinue

New-Item -ItemType Directory -Path C:\PS\Transcript -ErrorAction SilentlyContinue

New-Item -ItemType Directory -Path C:\PS\Scripts -ErrorAction SilentlyContinue

$profilePath = "$env:USERPROFILE\Documents\PowerShell\Microsoft.PowerShell_profile.ps1"

if (-not (Test-Path $profilePath)) {

New-Item -ItemType File -Path $profilePath -Force

}
# Edit Player Shell v7 profile using Notepad

Start-Process notepad.exe $profilePath

# Log/Save each session to a transcript file

$transcriptPath = "C:\PS\Transcript\$(Get-Date -Format 'yyyyMMdd-HHmmss').txt"

Start-Transcript -Path $transcriptPath

# Set default path and script location

$scriptPath = "C:\PS\Scripts"

Set-Location $scriptPath

# Change prompt

function prompt {

"With Great Power Comes Great Responsibility!"

"Your PowerShell is Ready..."

"PS4382-$(Get-Location) sawan>"

# Save profile script

$profilePath | Out-File -FilePath "$env:USERPROFILE\Documents\PowerShell\


Microsoft.PowerShell_profile.ps1"

Copy-Item -Path $profilePath -Destination "Z:\"

Stop-Transcript

You might also like