Skip to content

Instantly share code, notes, and snippets.

@ytez
Last active April 16, 2021 06:14
Show Gist options
  • Select an option

  • Save ytez/f0fabcb66383d548898988612dfd810b to your computer and use it in GitHub Desktop.

Select an option

Save ytez/f0fabcb66383d548898988612dfd810b to your computer and use it in GitHub Desktop.
# %USERPROFILE%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# 自動ログ保存
$logdir = "C:\PowerShellLog"
$fileName = (Get-Date).ToString("yyyyMMdd_HHmmss") + "_ps.log"
$logfile = join-path $logdir $filename
# ログディレクトリが存在する場合、ログ取得を開始
if ( Test-Path $logdir ) {
Start-Transcript $logfile -append
} else {
Write-Host ("No such directory : " + $logdir)
}
#--- タイトルを変更する
$a = (Get-Host).UI.RawUI
$a.WindowTitle = 'MyPS'
#--- 開始ディレクトリの指定
# Set-Location "D:\"
#--- 実行ポリシー確認
Write-Host "ExecutionPolicy: $(Get-ExecutionPolicy)" -ForegroundColor "Yellow"
#--- プロンプト
function Prompt {
$cwd = $executionContext.SessionState.Path.CurrentLocation
(Get-Host).UI.RawUI.WindowTitle = Split-Path $cwd -Leaf
"PS $cwd`n$('>' * ($nestedPromptLevel + 1)) ";
}
@echo off
start powershell.exe -ExecutionPolicy RemoteSigned %*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment