3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PowerShellスクリプト実行時の各種情報を出力してみる

Posted at

PowerShellスクリプト実行時の各種情報を出力してみる。

EnvOutputTest.ps1
$sep = "*" * 50

Write-Output $sep
Write-Output "カレントディレクトリ関連情報"
Write-Output $sep

Write-Output "`$pwd=$pwd"
# $tmp = Get-Location
# Write-Output "Get-Location=$tmp"
Write-Output "Get-Location=$(Get-Location)"

Write-Output $sep
Write-Output "コマンド実行情報"
Write-Output $sep

$MyInvocation
$basedir = Split-Path -Path $MyInvocation.InvocationName -Parent
$name = Split-Path -Path $MyInvocation.InvocationName -Leaf
Write-Output "当スクリプトの場所=$basedir"
Write-Output "当スクリプトの名前=$name"

Write-Output $sep
Write-Output "環境変数一覧"
Write-Output $sep
# cd env:
Push-Location env:
Get-ChildItem
Pop-Location

Write-Output $sep
Write-Output "システム日時"
Write-Output $sep
$date = Get-Date -Format "yyyymmdd"
$timestamp = Get-Date -Format "yyyymmdd-HHmmss"
Write-Output "システム日付=$date"
Write-Output "タイムスタンプ=$timestamp"
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?