#author("2020-02-10T01:03:02+00:00","default:admin","admin")
#author("2020-02-27T02:01:41+00:00","default:admin","admin")
-[[powershell チートシート:https://qiita.com/jca02266/items/a0c71ae90d055ab3893c]]

-[[PowerShell - WIN.JUST4FUN.BIZ:https://win.just4fun.biz/?PowerShell]]

-[[Windows PowerShell でのスクリプティング:http://www.microsoft.com/japan/technet/scriptcenter/hubs/msh.mspx]]
-[[Windowsスクリプティング環境比較:PowerShell vs WSH:http://www.atmarkit.co.jp/fwin2k/operation/pshvswsh/pshvswsh_01.html]]
-[[Windows PowerShell徹底解説:http://itpro.nikkeibp.co.jp/article/COLUMN/20061106/252598/]]

-[[それ PowerShell でできるよ:https://qiita.com/cd01/items/da9a36582372e7d0a7f6]]
-[[PowerShell 使い方メモ:http://qiita.com/opengl-8080/items/bb0f5e4f1c7ce045cc57]]

-[[なぜPowerShellが危険なのか? 増え続ける悪用の現状:http://www.itmedia.co.jp/enterprise/articles/1702/08/news018.html]]
-[[MicrosoftがPowerShellをオープンソース化しLinuxやOS Xにも提供…Bash on Windowsとの差別化は?:http://jp.techcrunch.com/2016/08/19/20160818microsoft-open-sources-powershell-brings-it-to-linux-and-os-x/]]

-[[ナンバーズ予想で学ぶ PowerShell によるデータ分析:https://qiita.com/mwmsnn/items/0e3e5cc1980272858ad8]]

-[[PowerShellでファイルにリダイレクトしたときに勝手に改行される場合の対処:https://qiita.com/gimKondo/items/20e1a5a1b2898c5c5fbd]]
-[[PowerShellでSendKeysを使ってみた:https://qiita.com/nimzo6689/items/488467dbe0c4e5645745]]

-[[PowerShell のスコープ完全に理解した:https://tech.blog.aerie.jp/entry/powershell-advent-calendar-2018-18]]

*制御 [#ga96153f]
-[[powerShellで無限ループと待機処理:http://harikofu.blog.fc2.com/blog-entry-77.html]]

**スリープ [#aea9b2e8]
-[[【PowerShell】指定した期間動作を一時停止する:https://hosopro.blogspot.com/2017/01/powershell-start-sleep.html]]

*コマンド [#b2dddd24]
**Start-Process [#sa3d5baa]
-[[【Start-Process】PowerShellでプロセスをバックグラウンド起動する方法:https://cheshire-wara.com/powershell/ps-cmdlets/system-service/start-process-window/]]

**Select-Object [#t343706d]
-[[Select-Object コマンドレットを復習:https://qiita.com/miyamiya/items/059430d5499f0fe336ff]]

*ファイル操作 [#s70b474c]
-[[[PowerShell] フォルダ内のファイル一覧を取得し、一括でファイル操作をおこなう。:https://mseeeen.msen.jp/how-to-get-list-of-files-in-folder-with-powershell/]]

-カレントフォルダにある *.zip の中身を カレントフォルダに全て展開する
 Get-ChildItem -Recurse -File -Include *.zip | ForEach { Expand-Archive $_ -DestinationPath . }

*Tips [#h5b822ef]
-[[Powershell で省略しないで表示する:http://tooljp.com/qa/Powershell-not-Omit-735E.html]]
--以下のオプションを使用します。フォーマットとして自動サイズ調整、および自動改行のオプションを使用します。
 Format-Table -AutoSize -Wrap

**tail [#f090da93]
 > Get-Content C:\var\log\nlog-own-2017-11-27.log -wait -tail 10 -Encoding UTF8

**touch [#g0a801f1]
-作成日時
 > Set-ItemProperty .\test.txt -Name CreationTime -Value "2018/06/12 15:30:00"
-更新日時
 > Set-ItemProperty .\test.txt -Name LastWriteTime -Value "2018/06/12 15:30:00"

**grep [#m20ce9b6]
-[[grepコマンドとPowerShellのsls (Select-String)の比較:http://tech.sanwasystem.com/entry/2016/07/05/185717]]
-[[Windowsでgrep:http://d.hatena.ne.jp/ys4145/20110408/p1]]
-[[powershellでCSV等の区切り文字があるファイルの数値列の合計を計算する:https://qiita.com/gyoon/items/a74fe70959e51d584951]]

-実行例
 type target.txt | sls "foo" | sls "bar" | % { $_.ToString() } > hoge.txt

-「ファイル名:行番号」を出力しない
--これが一番良さそう
 cat [ファイル名] | sls [検索文字列] | Out-String -Width 4096
--select Line はイマイチ
 select-string [検索文字列] | select Line | Out-String -Width 4096
 select-string [検索文字列] | select Line | Format-Table -Property * -AutoSize | Out-String -Width 4096

-OR検索
 Select-String -Path "*.txt" -Pattern "hello","world"

-Not検索
 Select-String -Path "*.txt" -NotMatch -Pattern "hello","world"

-空行削除
 (gc [ファイル名] | ? {$_.trim() -ne "" }

**wc -l [#se7047d4]
 (Get-Content [ファイル] | Measure-Object).Count

-カレントディレクトリ以下のソースファイルの総行数をカウント
 (dir -include *.cs,*.cpp,*.h,*.idl,*.asmx,*.js,*.css -recurse | select-string .).Count

**cut [#a7427c45]
-[[Windows PowerShell : UNIXの cut コマンド相当の作業をする。:https://www.engineer-memo.net/20110122-2750]]
 Get-Content “.\list.txt” | Select-Object {$($_-split(“,”))[0]}

**uniq [#z76e4217]
-[[オブジェクトをユニークにして存在数を付加する PowerShell フィルター:https://www.vwnet.jp/Windows/PowerShell/2016092401/CountUnique.htm]]
-[[PowerShell で、多項目中、複数項目の数の集計:https://qiita.com/bunzaemon/items/43e515bf07379a5ba2af]]

-項目毎の件数を求める(uniq -c)
 cat hoge.txt | group $_ | select name,count

**which [#w0f4a109]
-[[PowerShellでwhichコマンド:https://qiita.com/Hiraku/items/e42bc5756157949a9742]]

*C# [#c4ee1ff3]
-[[PowerShellからC#, SQL Serverのコードをとっても便利に呼び出す:http://threeprogramming.lolipop.jp/blog/?p=812]]

*メール送信 [#m4bbfd5c]
-[[PowerShellでメール送信:https://qiita.com/arachan@github/items/e93c2fec8fe5f7f66bfa]]

*SQL Server [#laa48f99]
-[[PowerShellからC#, SQL Serverのコードをとっても便利に呼び出す:http://threeprogramming.lolipop.jp/blog/?p=812]]
-[[SQL Server に接続してテーブルの内容を SELECT する方法:https://bayashita.com/p/entry/show/107]]

*WCF [#o9a513ce]
-[[PowerShell で WCF:http://csharper.blog57.fc2.com/blog-entry-117.html]]
-[[WCF サービス開発には PowerShell を活用しよう:http://csharper.blog57.fc2.com/blog-entry-185.html]]

*サンプル [#jcb548fd]
-[[スクリーンセーバ抑止PowerShell:https://qiita.com/kfjt/items/d383b5ebec27c3e1dd42]]


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS