2021-11-01から1ヶ月間の記事一覧

powershell - 世代管理

> 対象DIR > sampleDB_2021-11-20_17-00-00.bak > sampleDB_2021-11-21_17-00-00.bak > sampleDB_2021-11-22_17-00-00.bak > sampleDB_2021-11-23_17-00-00.bak # 2件残して後は削除 Get-ChildItem | Sort-Object -Property Name -Descending | Select-Objec…

sqlserver - 日付フォーマット

declare @d datetime = GETDATE() declare @date varchar(10) = CONVERT(varchar, @d, 120); declare @time varchar(10) = REPLACE(CONVERT(char(8), @d, 108), ':', '-' ); declare @datetime varchar(20) = @date + '_' + @time select @datetime 出力--> …

powershell - 数日前の0時

$date = [Datetime](Get-Date).AddDays(-3).ToString("d"); or $date = [Datetime](Get-Date).AddDays(-3).ToString("yyyy/MM/dd"); Write-Host $date.ToString(); > 2021/11/22 0:00:00

sqlserver - ジョブのログ

www.webdevqa.jp.net

tool - ダミーファイル作成

www.mynikko.com

圧縮 - 7-Zip

sevenzip.osdn.jp itojisan.xyz sevenzip.osdn.jp www.webdevqa.jp.net 基本の使い方、コマンドを直書き $input = "C:\data\testfile.txt"; $output = "C:\data\testfile.txt.zip"; # サブフォルダ "7-Zip" .\7-Zip\7z.exe a $output $input スクリプトを文…

windows - 計測

# cpu 10秒単位 > typeperf -si 10 "\processor(_total)\% processor time" # ファイルへ出力 > typeperf -si 10 -y "\processor(_total)\% processor time" -o d:\temp\process_log.csv # メモリ空き容量(10秒単位) > typeperf -si 10 "\Memory\Available…

powershell - Test-Path

mtgpowershell.blogspot.com social.technet.microsoft.com

powershell - 並列処理

直列 $job1 = Start-job -ScriptBlock { Get-Service | out-null; $ret=@{} $ret.Add("status", "finish-job1"); return $ret; } $job2 = Start-job -ScriptBlock { Get-Service | out-null; $ret=@{} $ret.Add("status", "finish-job2"); return $ret; } Ge…

powershell - パスワードファイルを使ってログイン

blog.macorin.net www.lifewithunix.jp qiita.com www.kayura-se.com

powershell - モジュールの読み込み

qiita.com 基本的にはドットソース演算子を利用ですかね。

powershell - vscodeデバッグ

blog.janjan.net

powershell - 関数の戻り値

winscript.jp

powershell - カスタムオブジェクト

www.vwnet.jp function CreateCustomObject() { $data = New-Object PSObject | Select-Object one, two, three; return $data } $datas = @() $o1 = CreateCustomObject $o1.one = "a1" $o1.two= "b1" $o1.three= "c1" $datas += $o1; $o2 = CreateCustomOb…

powershell - Read-Host

soma-engineering.com [ValidateSet("y","n")] $res= Read-Host "ok?(y or n)" Write-Host $res

powershell - help

> Get-Help Get-ChildItem -detailed #> help Get-ChildItem 名前 Get-ChildItem 構文 Get-ChildItem [[-Path] <string[]>] [[-Filter] <string>] [<CommonParameters>] Get-ChildItem [[-Filter] <string>] [<CommonParameters>] パラメーター -Attributes <FlagsExpression[FileAttributes]> -Depth <uint32> -Directory -Exclude <…</uint32></flagsexpression[fileattributes]></commonparameters></string></commonparameters></string></string[]>

powershell - Format-Table 出力の改善(AutoSize,Wrap)

Get-Service -Name win* | Format-Table -Property Name,Status,StartType,DisplayName,DependentServices -Wrap Name Status StartType DisplayName DependentServices ---- ------ --------- ----------- ----------------- WinDefend Stopped Manual Micr…

powershell - 詳細情報

docs.microsoft.com Get-Process -Name explorer | Where-Object{$_.id -eq 9964} | Format-List -Property * Name : explorer Id : 9964 PriorityClass : Normal FileVersion : 10.0.22000.258 (WinBuild.160101.0800) HandleCount : 4724 WorkingSet : 381…

powershell - フォーマット

docs.microsoft.com

powershell - オブジェクトの構造

docs.microsoft.com

powershell - NoProfile パラメーター

docs.microsoft.com ja.gouma.org