Powershell

PowersShell で ファイル名を一括変換する方法

> Get-ChildItem | Rename-Item -NewName { $_.Name -replace 'userInterests','userInterest'}

Powershell でcsvファイルの文字コードをUTF16からUTF8に変換する方法

> Get-ChildItem -Recurse *.csv | ForEach-Object {Get-Content $_ | Set-Content -Encoding UTF8 ($_.FullName -replace 'csv','csv_')}

PowerShell 文字列操作

拡張子がcsvのファイルをマージする。 特定の文字を含む行を削除する。 バーティカルバーをタブに置換する。 カンマをタブに置換する。 を一回でやる方法 > Get-Content *.csv | Select-String -NotMatch "^SourceSystem", "^FileName", "^PreparedDatetime"…

PowerShell のスクリプトを実行するには

PowerShell を管理者として実行後、ExecutionPolicy を RemoteSigned にするとスクリプトを実行できます。 > Get-Content .\sample.ps1 #★サンプルコード $strMsg = "Hello World !" write-host $strMsg > .\sample.ps1 #★エラーになります File C:\Users\us…