2020-02-09から1日間の記事一覧

powershell - Copy-Item

sample code # ファイルをコピー PS> Copy-Item -path "test1.txt" -destination "test1.txt.bak" # フォルダをコピー PS> Copy-Item -path "mydir" -Recurse -destination "mydir.bak"

powershell - Remove-Item

sample code # ファイルを削除 Remove-Item -Path "aaa.txt" # フォルダを削除 Remove-Item -path "a1" -Recurse -Force

powershell - New-Item

sample code # ディレクトリを作成 New-Item -ItemType Directory "mydir" # 再帰的にディレクトリを作成 New-Item -ItemType Directory "a1\a2\a3" # ファイルを作成 New-Item -ItemType File "test1.txt" # ファイルを作成+内容 New-Item -ItemType File "…

powershell - Send-MailMessage

sample code $from = "xxxx@gmail.com" $to = "xxxx@gmail.com" $cc = "xxxx@gmail.com" $smtp = "smtp.gmail.com" $port = "587" $subject = "メール件名" $user = "xxxx@gmail.com" $password = "xxxxxxxxxxxxxxxxx" $pass = ConvertTo-SecureString $pass…

powershell - Test-Connection

sample code PS> Test-Connection -ComputerName localhost -Count 10

powershell - Write-Debug

参考 codezine.jp

powershell - GetLocation/SetLocation

sample code # 現在のロケーションを取得 PS> Get-Location # "d:\sandobox\ps" # 現在のロケーションに設定 PS> Set-Location "../" # "d:\sandobox"

powershell - GetDate format

sample code PS> Get-Date # 2020年2月9日 15:19:43 PS> Get-Date -Format "yyyy/MM/dd" # 2020/02/09 PS> [datetime]::Now.ToString("yyyy/MM/dd")

powershell - Test-Path

sample code # ファイルの存在確認 PS> Test-Path -path "./aaa.txt" -PathType Leaf # フォルダの存在確認 PS> Test-Path -path "./dir_aaa" -PathType Container

powershell - 文字切れ

参考 cncn-us.hatenablog.com