qshinoの日記

Powershell関係と徒然なこと

net LBFO cmdlet

コマンド分類

基本構造

  • Keyword: NetLbfoTeam
  • Verb: New, Remove, Get, Set, Add, Rename
  • Object: (none), Nic, Member

Verb-Object matrix

  • New: None
  • Add: Nic, Member
  • Remove: None, Member, Nic

  • Get: None, Member, Nic

  • Set: None, Member, Nic

  • Rename: None

NoneはObjectなし。Teamを表す。

Object説明

Teamが最上位のObject。その中に物理NICのMemberと論理NICnicがある。

Team: 上記ではNone。Teamの中に複数の物理NICメンバーで構成される複数の論理NICを持つ。Newで作成、Removeで削除。

member: チームを構成する物理NIC。TeamにAddで追加、Removeで削除。

nic: チームが作成する論理NIC。VLAN単位でNICが作成される。TeamにAddで追加、Removeで削除。

Team作成/削除

作成
# チームを作成
PS C:\> New-NetLbfoTeam -Name "Public-TEAM" -TeamMembers ("イーサネット 2", "イーサネット 3") -TeamingMode SwitchIndependent -LoadBalancingAlgorithm Dynamic -Confirm:$false
削除
Remove-NetLbfoTeam -Name "Public-TEAM"

モード

-TeamingMode

Lacp : LACP動的
Static : 静的
SwitchIndependent : スイッチ非依存

-LoadBalancingAlgorithm

Dynamic : ダイナミック
HyperVPort : Hyper-Vのポート
TransportPorts : アドレスのハッシュ
IPAddresses : IPアドレス (GUIでは設定できず、PowerShellからのみ設定可能)
MacAddresses: MACアドレス (GUIでは設定できず、PowerShellからのみ設定可能)

Member追加/削除

追加
# ネットワークアダプターの追加
Add-NetLbfoTeamMember -Team "Public-TEAM" -Name "イーサネット 3" -AdministrativeMode Active
削除
# ネットワークアダプターの解除
Remove-NetLbfoTeamMember -Team "Public-TEAM" -Name "イーサネット 3"

Nic追加/削除

追加
Add-NetLbfoTeamNIC -Team "Public-TEAM" -VlanID 2
削除
Remove-NetLbfoTeamNic -Team "Public-TEAM" -VlanID 2

Team設定

モードを変更する。TMとLBを変更可能。

  • TM: Teaming mode
  • LB: Load balancing mode
Set-NetLbfoTeam -Name "Public-TEAM" -TeamingMode Static  -LoadBalancingAlgorithm IPAddresses

Nic設定

VLAN idを変更する。

Nic/vlaid設定
Set-NetLbfoTeamNic -Name "Public-TEAM" -VlanID 1
# チーム名指定も可能
# Set-NetLbfoTeamNic -Team "Public-TEAM" -VlanID 1
Nic/vlanid削除
Set-NetLbfoTeamNic -Name "Public-TEAM - VLAN 1" -Default
# チーム名指定も可能 
# Set-NetLbfoTeamNic -Team "Public-TEAM" -Default

member設定

Active/Standbyを変更する。

Set-NetLbfoTeamMember -Name "イーサネット 3" -AdministrativeMode Standby

Rename

Rename-NetLbfoTeam -Name "Public-TEAM" -NewName "Public-TEAM-New"

IPアドレス設定/DNS設定

IPアドレスDNSをNet cmdletでnicを指定して設定する。

# IPアドレスの設定
Get-NetAdapter -Name "Public-TEAM - VLAN 2" | New-NetIPAddress -IPAddress "192.168.133.14" -PrefixLength 24 -DefaultGateway "192.168.133.1"
# DNSの指定
Set-DnsClientServerAddress -InterfaceAlias "Public-TEAM - VLAN 2" -ServerAddresses "192.168.133.2"
# IPv6のバインド停止
Get-NetAdapterBinding -Name "Public-TEAM - VLAN 2" -ComponentID ms_tcpip6 | Disable-NetAdapterBinding

コマンド一覧

PS C:\> Get-Command -Module NetLbfo

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Function        Add-NetLbfoTeamMember                              NetLbfo
Function        Add-NetLbfoTeamNic                                 NetLbfo
Function        Get-NetLbfoTeam                                    NetLbfo
Function        Get-NetLbfoTeamMember                              NetLbfo
Function        Get-NetLbfoTeamNic                                 NetLbfo
Function        New-NetLbfoTeam                                    NetLbfo
Function        Remove-NetLbfoTeam                                 NetLbfo
Function        Remove-NetLbfoTeamMember                           NetLbfo
Function        Remove-NetLbfoTeamNic                              NetLbfo
Function        Rename-NetLbfoTeam                                 NetLbfo
Function        Set-NetLbfoTeam                                    NetLbfo
Function        Set-NetLbfoTeamMember                              NetLbfo
Function        Set-NetLbfoTeamNic                                 NetLbfo

課題

nic追加の際に、nic名が自動で作成され、プログラム的に制御が複雑化する。

add-nic

add-nicのパラメータに-nameがあるので、これで新nic名を指定すれば名前を固定できるか?

Parameter Set: cim:CreateInstance0 Add-NetLbfoTeamNic [-Team] [-VlanID] [[-Name] ] [-AsJob] [-CimSession <CimSession[]> ] [-ThrottleLimit ] [-Confirm] [-WhatIf] [ ]

参考資料

technet https://technet.microsoft.com/ja-jp/library/jj130850(v=wps.630).aspx

sample http://blog.shibata.tech/entry/2016/04/13/211524

1週間メニュー

【2人で500円未満!】管理栄養士が考える節約献立1週間分

Nadia 「毎日」のことだからこそ、少しでも安く、そして美味しく作りたい夕食。そんな想いにお応えする【2人で500円未満の献立】をご紹介します。1食ワンコインで収めるための食材選びのポイントや食材を無駄なく使い切る方法に注目してみてください。

キーワード 節約 管理栄養士 献立

この記事をLineで送る

<月曜日:410円>野菜たっぷりボリューム満点!日持ちする根菜は買いだめしておこう

豚こまで♪玉ねぎた~ぷり♪柔かジューシー生姜焼き♪ https://oceans-nadia.com/user/22585/recipe/130772

にんじんの塩バターきんぴら♪ https://oceans-nadia.com/user/12769/recipe/139773

里芋と長ネギの胡麻味噌汁 https://oceans-nadia.com/user/39/recipe/119448

2人分:410円(調味料・乾物・主食は除く) ■内訳 豚こま切れ肉 150g:160円 たまねぎ 1/2個:25円 しょうが 1片:30円 きゃべつ 1/8個:40円 にんじん 1/2本:60円 さといも 2個:50円 長ねぎ 1/2本:45円 しょうが焼きはお得な豚こま切れ肉で。たまねぎをたっぷりと加えてボリュームUP! たれの染みた千切りきゃべつもたまりませんね。ごはんがすすむ定番おかずです。野菜は日持ちのする根菜を中心にお買い得の時にまとめ買いするのが良いでしょう。にんじんは湿ると痛みやすいため、こまめに水分を拭き取るのが長持ちの秘訣です。

<火曜日:434円>大根のダブル使い献立。お手頃食材、骨付き肉でうま味もたっぷり!

やわらか大根と手羽元オイスターソース煮 https://oceans-nadia.com/user/55/recipe/5507

豆苗ともやしのナムルサラダ https://oceans-nadia.com/user/11285/recipe/138278

大根と梅干しのコンソメスープ https://oceans-nadia.com/user/27305/recipe/137600

2人分:434円(調味料・乾物・主食は除く) ■内訳 鶏手羽元 6本 240円 大根:約1/2本 90円 豆苗:1袋 90円 もやし:1/2袋 14円 大根は主菜と汁物の両方使い! 調味や切り方を変えれば同じ食材でも食べ飽きることはありません。煮込み料理は骨付き鶏肉がおすすめ! もも肉やむね肉に比べてお手頃価格ですし、骨からうま味が溶け出すので味に深みも出ますよ! 副菜には節約食材の定番「もやし」と「豆苗」を使いましょう。一つのボウルで調理ができるのもウレシイですね。もやしは生のままだと日持ちしません。翌日の汁物に入れたりして有効活用しましょう!

<水曜日:370円>ゴロゴロ食材でボリュームアップ!体温まるポカポカ献立

ベルリン風 田舎オムレツ ホッペルポッペル https://oceans-nadia.com/user/26/recipe/122599

切り干しひじきのサラダきんぴら https://oceans-nadia.com/user/36/recipe/135716

コンソメ不要&時短。根菜とベーコンのぽかぽかスープ https://oceans-nadia.com/user/10649/recipe/134380

2人分:370円(調味料・乾物・主食は除く) ■内訳  ベーコン 80g:140円 じゃがいも 1個:50円 たまねぎ 1/2個:25円 卵 3個:60円  長ねぎ 1/2本:45円 大根 100g:20円 にんじん 1/4本 30円 ゴロゴロに切ったじゃがいもとベーコンの存在感が魅力的なボリューミーオムレツです。同じくサイコロ状に切ったベーコンと野菜を入れた、まさに「食べるスープ」を添えて。 この時期、温かい汁物は必須ですね。根菜や香味野菜は血行を促し体を中から温めてくれる効果があります。副菜には作り置きにおすすめの乾物レシピ。しっかりと水気を飛ばして炒めることで保存性が高まります。ちょっぴり物足りない「あともう一品」の強い味方にもなってくれますよ。

<木曜日:478円>魚料理も500円以内!切り身魚で満足度たっぷりの献立に

鮭の豆乳クリームシチュー https://oceans-nadia.com/user/24312/recipe/133639

カロリーダウン かぼちゃのヨーグルトサラダ https://oceans-nadia.com/user/12025/recipe/119976

2人分:478円(調味料・乾物・主食は除く) ■内訳 鮭 2切れ:200円 白菜 1/8個 75円 じゃがいも 1個:50円 にんじん 1/3本:40円 たまねぎ 1/4個 13円 しめじ 1/4袋:20円 かぼちゃ 150g:65円 きゅうり 1/2本:30円 焼き魚や煮魚ももちろん美味しいですが、ちょっぴり物足りない、なんて感じる魚料理。魚と旬の野菜をたっぷり入れた具だくさんシチューにしてみてはいかがでしょうか。 お手頃な塩鮭を使う場合は、薄い塩水もしくは水に少量の酒とみりんを加えたものに2~3時間付けておきましょう。余分な塩分が抜けて美味しくいただけます。さっぱりヘルシーなきゅうりのサラダは、食感も魅力。

<金曜日:355円>少なめお肉で食べごたえたっぷり。余った卵も最大限活用して!

主菜:かぼちゃのコロッケ https://oceans-nadia.com/user/24312/recipe/144149

副菜:白菜コールスロー https://oceans-nadia.com/user/11110/recipe/117365

汁物:トマトとえのきのかき玉味噌汁 https://oceans-nadia.com/user/28/recipe/112132

2人分:355円(調味料・乾物・主食は除く) ■内訳 豚ひき肉 65g:60円 かぼちゃ 200g:90円 たまねぎ 1/3個:15円 にんじん 1/4個:30円 白菜 100g:30円 ミニトマト 6個:90円 えのきたけ 1/2袋:40円 卵 1個:20円 かぼちゃがメインのコロッケは、少量のひき肉でもたまねぎと合わせて炒め、味を付けておくことでホクホクジューシーな仕上がり。揚げ物をする時は径の小さい鍋を使うと少ない油でも揚げやすくなります。他の料理を準備して、揚げ物は最後にとりかかりましょう。 コロッケの衣に使う卵、あまってしまうことはありませんか? 卵はあらかじめ半量程度取り分けておき、汁物に加えると無駄なく使い切れますよ。

無駄なく使い切る上手な食材の買いかたとは?

食材を無駄なく選び、使い切ることが節約の第一歩。日持ちのする根菜や乾物、調味料などは、お買い得なときにまとめ買いをしておきましょう。肉や魚、傷みやすい葉物野菜はこまめに買い足しましょう。 この季節、特におすすめしたいのが毎食の「汁物作り」。汁物に入れる食材はアレンジ自在! レシピの指定食材にこだわらず、冷倉庫にある残り野菜でアレンジしながら温かい汁物を作ってくださいね。 こちらの記事もチェック! 21時以降の夕飯に。ヘルシーだけど食べ応えのある献立5つ 【4人分3000円未満!】管理栄養士が教える!節約献立1週間分 レンチン調理で時短!20分で3品献立1週間 【20分で3品献立】管理栄養士が教える!時短献立1週間分

この記事のライター  

藤原朋未 https://oceans-nadia.com/user/24312

藤原さんの記事コピペ。

EAPoL forwarding

802.1x認証で使用されるEAP

スイッチではEAPoLをフォワードしない。それではすべてのポートに認証機能を使う高価なスイッチしか使用できない。

そのため、EAPoLをフォワード機能付きのスイッチもある。EAPoLフォワードにより、基幹スイッチのみ802.1x認証し、その他は安価なスイッチを使用でき、ポートセキュリティーを安価に実現できる。

スイッチ状況による場合

単なるHUBとして使用する時はEAPoLフォワードするが、ルーティングする場合はフォワードしない場合

EAPoLフォワードする

  1. portVLAN&ipアドレスなし

EAPoLフォワードしない

  1. portVlan&ipアドレス設定
  2. portVlan&ipアドレスなし&bviあり
  3. portVlan&ipアドレスなし&tagVlanへのブリッジ
  4. base if & ipアドレス設定
  5. base if & ipアドレスなし

wpf drag and drop powershell

wpf drag and drop by powershell

powershellでのドラックアンドドロップ実装方法。

手順 1. xamlでAllowDrop=“True” 2. PowerShellでハンドラ実装 - Add_DropEnter - Add_DropLeave - その他のハンドラ

AllowDrop

<Window
  Name="w1"
  AllowDrop="True" >
  <StackPanel>
  </StackPanel>
</Window>

ハンドラ

$w : Window Object

function de($sender, $args){
  Wright-Host "Enter"
}

function dl($sender, $args){
  Wright-Host "Leave"
}

function dd($sender, $args){
  Wright-Host "Drop"
  $d = $args.Data.GetData("myformat")
}

# explorerのファイルの場合

function dde($s,$e){
    [string[]]$a = $e.Data.GetData(System.Windows.DataFormats.FileDrop);
  foreach($f in $a){
    Write-Host $f
  }
}


$w.Add_DragEnter( {de $this $_} )
$w.Add_DragLeave({dl $this $_ })
$w.Add_Drop({dde $this $_})

$args : DragEventArgs

参考

http://posaune.hatenablog.com/entry/2012/12/07/220208

https://www.codeproject.com/Articles/43614/Drag-and-Drop-in-WPF

http://www.wpftutorial.net/draganddrop.html

https://msdn.microsoft.com/ja-jp/library/ms742859(v=vs.110).aspx

http://qiita.com/Go-zen-chu/items/c6dbd4c472909118fad0

階層構造 System.Object   System.EventArgs    System.Windows.RoutedEventArgs       System.Windows.DragEventArgs

wpf converter

wpf converter

動作未確認だが、Converterの実装方法を調査中。

xaml

I want to use WPF DataTrigger to check value greater than X. I know that this is only possible with IValueConverter. I have found many C# examples for that, but I need it in powershell. Could someone help me translate this to powershell?

The C# code to translate:

public class CutoffConverter : IValueConverter {
    public object ConvertTo(object obj, Type type) {
        return ((int)obj) > Cutoff;
    }

    public object ConvertFrom(object obj, Type type) {
        throw new NotImplementedException();
    }

    public int Cutoff { get; set; }
}
And the XAML

<Window.Resources>
    <myNamespace:CutoffConverter x:Key="AgeConverter"/>
</Window.Resources>

<DataTemplate.Triggers>
    <DataTrigger Binding="{Binding Path=Age,
                           Converter={StaticResource AgeConverter},
                           ConverterParameter=30}">
        <Setter TargetName="Age" Property="Foreground" Value="Red"/> 
    </DataTrigger>
</DataTemplate.Triggers>

c

$src = @'
using System;
using System.Globalization;
using System.Windows.Data;

namespace MyNamespace
{
    public class CutoffConverter : IValueConverter
    {
        public int Cutoff { get; set; }

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return ((int)value) > Cutoff;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
'@

Add-Type -AssemblyName PresentationFramework    
Add-Type -TypeDefinition $src -ReferencedAssemblies PresentationFramework

参考

https://stackoverflow.com/questions/14281671/how-to-use-ivalueconverter-from-poweshell

https://social.technet.microsoft.com/Forums/ie/en-US/c54f1c71-3545-4db2-aab2-9c4ce6732c06/how-to-use-ivalueconverter-from-powershell-in-xaml-gui?forum=winserverpowershell

wpf DragDrop FileList

wpf DragDrop

ポイント 1. Window でAllowSrop=“True” 2. PreviewDragOverとDropイベント使用

xaml

Window x:Class="DragFromExplorerSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clr-namespace:DragFromExplorerSample"
        Title="MainWindow" Height="350" Width="525"
        AllowDrop="True"
        Drop="Window_Drop" PreviewDragOver="Window_PreviewDragOver">
    <Window.DataContext>
        <my:MyFileList />
    </Window.DataContext>
    <Grid>
        <ListBox HorizontalAlignment="Stretch"
                 VerticalAlignment="Stretch"
                 ItemsSource="{Binding FileNames}" />
    </Grid>
</Window>
using System.Collections.ObjectModel;
using System.Windows;
namespace DragFromExplorerSample {
    /// <summary>
    /// MainWindow.xaml の相互作用ロジック
    /// </summary>
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
        private void Window_Drop(object sender, DragEventArgs e) {
            MyFileList list = this.DataContext as MyFileList;
            string[] files = e.Data.GetData(DataFormats.FileDrop) as string[];
            if (files != null) {
                foreach (var s in files)
                    list.FileNames.Add(s);
            }
        }
        private void Window_PreviewDragOver(object sender, DragEventArgs e) {
            if (e.Data.GetDataPresent(DataFormats.FileDrop, true))
                e.Effects = DragDropEffects.Copy;
            else
                e.Effects = DragDropEffects.None;
            e.Handled = true;
        }
    }
    public class MyFileList {
        public MyFileList() {
            FileNames = new ObservableCollection<string>();
        }
        public ObservableCollection<string> FileNames {
            get;
            private set;
        }
    }
}

参考

http://gushwell.ldblog.jp/archives/52326682.html

青森

夕方に着いてホテルへ。11Fで綺麗な部屋で快適。有名なのは、帆立味噌焼き、焼き干しラーメン、青森味噌おでん、そして最近流行?の牛乳ラーメン?

まずは帆立味噌焼き。かなりのお店で出しているメニューで、お店毎に違うかもしれないが中々美味しい。とは言え過剰な期待をすると、お店によっては裏切られ感があるかもしれない。

もう1日あるので、都合がつけば他も試してみたい。