powershell
WPF簡単文書表示HTML編 XAML 早速XAML <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="HTMLVIEW" Height="100" Width="200"> <StackPanel> <WebBrowser Source="file:///c:/tmp/a.html" Name="bs1" /> </StackPanel> </Window> コード 上記X…
C# in PowerShell PowerShell 内でC#を使う。 C#のコードを文字列に格納 $cs = "csharp code..." Add-Typeコマンドレットでロード Add-Type $cs 参照アセンブリがある場合は、 ReferencedAssemblies <アセンブリ[]> C#以外の言語なら、 Language <言語名> 言…
WPF バインディング まずは用語から、 バインディングソース 提供元オブジェクト バインディングターゲット 提供先オブジェクト ソースプロパティ 提供元プロパティ ターゲットプロパティ 提供先プロパティ バインディングソースになれるもの CLRオブジェク…
CI Windows環境のCI Linuxならgit push -> post-update で何でも出来るが、windowsだとLinuxからのキック方法からして面倒。 例えば、 Windows版OpenSSH 懐かしのWindows telnet server PowerShell Remote Jenkins Linux -> IIS -> webAPI 前提 現在考えてい…
PowerShellのリスク セキュリティ面ではPowerShellにはリスクがある。PowerShellではファイルアクセスなしにShellコードを実行される可能性がある。 きになる方は参考をご覧になって。 参考 http://colesec.inventedtheinternet.com/hacking-with-powershell…
ActiveDirectory by PowerShell 基本コマンド New-ADUser Get-ADUser Set-ADUser Remove-ADUser Get-ADUserResultantPasswordPolicy ユーザー作成 簡単に New-ADUser taro -DisplayName 山田太郎 姓名指定 New-ADUser taro -Surname 山田 -GivenName 太郎 -D…
excelスケジュール制御 参考 http://nasunoblog.blogspot.jp/2013/12/powershell-excel.html?m=1
WMIイベント by PowerShell 参考 https://technet.microsoft.com/ja-jp/library/ff898417.aspx
WPF子ウインドウ 参考 http://vdlz.xyz/Csharp/WPF/Control/Window/AnothorWindow/AnotherWindowOpen.html http://gushwell.ldblog.jp/archives/52335648.html Show()とShowDialog() http://gushwell.ldblog.jp/archives/52285322.html
WPF簡単文書表示 Xamlを使って簡単に文書表示ウインドウを作る。主要なものは下記の3点。 コントロール: DocumentViewer 文書: XPSファイル 文書型: FixedDocument 使用する文書ファイルはXPS形式。MicroSoft版のPDFの様な もの。Wordで保存できる。また、プ…
外部プログラム起動方法調査 コンソールアプリを別ウインドウで非同期実行しつつ、標準出力を受け取る。 無理? まずは外部プログラム実行方法 & 同期 start-process 非同期/同期(-wait) start-job 非同期 System.Diagnostics.Process C#で書く? 期待値は、…
仕様 https://download.microsoft.com/download/B/F/D/BFDCBB01-276F-4F8F-B5D9-2364FE1409A8/Windows PowerShell Language Specification Version 3.0.docx
クオータ不足 PowerShell & WPFで頻発する。 WPFのコントロールはDisposeが不要との情報があるが、リファレンスカウント制御があるので、変数破棄or $null化が必要? 参考 http://www.powertheshell.com/wpfquota/ https://blogs.msdn.microsoft.com/japan_p…
confirm システムに変更を加えるコマンド、例えばIPアドレス削除では、デフォルトでconfirm メッセージがでる。 これを止める方法は、 -confirm:$false 参考 https://blogs.msdn.microsoft.com/powershell/2006/12/14/confirmpreference/
初心者向けWindows.Forms by PowerShell 参考 https://social.technet.microsoft.com/wiki/contents/articles/25911.how-to-add-a-powershell-gui-event-handler-part-1.aspx
初歩的なWPF by PowerShell xml -> reader -> ShowDialog の流れ 参考 https://blogs.technet.microsoft.com/heyscriptingguy/2014/08/01/ive-got-a-powershell-secret-adding-a-gui-to-scripts/
Windowsサービス 関連コマンド net start/stop sc.exe 参考 https://msdn.microsoft.com/ja-jp/magazine/mt703436.aspx
PowerShell 例外処理 例外処理には二種類。 Trap [例外] {} Try{}Catch[例外]{}Finally{} Trap 書式: Trap [例外] {例外処理} Trap例外処理中の break,continue break: 処理を終了する。 continue: 処理を継続する。 Try Catch 書式: Try{}Catch[例外]{}Fina…
Powershell 圧縮 Comでshell にzipファイルを渡してCopyHere($filename) 注意点は、非同期処理対応。 重複試験はhashかなぁ。 なお、圧縮パスワードは設定できない。 解凍パスワードは、引数指定不可、ダイアログが表示される。 下記では、全ファイルをCopyH…
Ether IP on linux 参考 http://trema.hatenablog.jp/entry/20120415/1334487392 Github etherip https://github.com/kjmkznr/etherip/tree/master http://www.ihanet.info/Home/samples/etherip
ショートカットファイル作成 Powershell でショートカットファイル作成。 com のwshで作成する。 $wsh = New-Object -comObject WScript.Shell $link = $wsh.CreateShortcut("D:\desktop\notepad.lnk") $link.TargetPath = "notepad.exe" $link.Description …
Object廃棄 on Powershell Remove-Variable x 参考 http://stackoverflow.com/questions/13782788/powershell-clear-item-variable-vs-remove-variable http://m.chiebukuro.yahoo.co.jp/detail/q1342962568 http://stackoverflow.com/questions/1999858/how…
ComObject廃棄 変数廃棄 Remove-Variable aaa 例 $x = New-Object -com Excel.Application $x.Visible = $True Start-Sleep 5 $x.Quit() [System.Runtime.Interopservices.Marshal]::ReleaseComObject($x) Remove-Variable x 参考 https://technet.microsoft…
Powershell jobの終了通知 Register-ObjectEvent で終了通知可能。 Register-ObjectEvent $job -EventName StateChanged -SourceIdentifier ハンドラ名 -Action { アクション } 取扱物件は ターゲットジョブ ハンドラ ハンドラジョブ ハンドラを登録するとハ…
ホスト名、IPアドレス取得 ホスト名 [Net.Dns]::GetHostName() $Env:COMPUTERNAME hostname (Get-CimInstance -Class Win32_ComputerSystem).Name IPアドレス Get-NetIPAddress [Net.Dns]::GetHostAddresses(‘’).IPAddressToString [Net.Dns]::GetHostAddres…
Powershell で改行なら、 $nl = [Environment]::NewLine 最近はOpenSourceになって改行コードが異なる環境でも動く様なので、移植性を考えて。
書式付き出力 -f 演算子 書式文字列 -f 引数 例) “Hi, {0}! I give you {1:d2} Yen. rn” -f “Taro”, 20 書式文字一覧 c 通貨 d 10進数 精度は最小桁数 e 浮動小数点数 n.nen精度=小数部桁数 f 浮動小数点数 n.nnn 精度=小数点以下 g 浮動小数点数 ne±n 精度=…
日付をファイル名に $now = Get-Date -Format "yyyy-MMdd-HHmmss" Write-Output "poi" | Out-File "memo-$now.txt" 連番をファイル名に 日付を打つのが面倒なので、連番をファイル名にする。先のが2行に対して2行多い4行。 $index = "index.txt" (Get-Date -…
DES暗号化その2 by powershell 使い方から $in="password" $key="keyword" $des=get-des($in,$key) $undes=get-undes($des,$key) $in $des $undes 暗号 function get-des($in, $key) { $des = New-Object System.Security.Cryptography.DESCryptoServiceProv…
Module Manifest ファイル名が .psd1 作成方法は3種類 人手作成 New-ModuleManifest コマンド テンプレートを写す 人手作成 こんな感じ '@{ModuleVersion="1.0"}' > myModuleName.psd1 New-ModuleManifestコマンド こんな感じ New-ModuleManifest myModuleNa…