VMware ESX vCenter Linux windows CCNA 忍者ブログ

IT号 着地号 いろいろ号

 ITに関しての調べ物です。バージョンや出展はつど記事に記載予定です。

カレンダー
05 2025/06 07
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
リンク
カテゴリー
かぶりもの
最新CM
[06/07 gay]
[02/16 gay]
[02/12 ヴィトン セカンドバッグ スーパーコピー ヴィトン]
[09/30 vente boutique canada goose paris]
[09/28 canada goose belgique]
最新記事
プロフィール
HN:
ESXi
性別:
非公開
バーコード
RSS
ブログ内検索
アーカイブ
最古記事
(01/14)
(01/20)
(01/20)
(01/26)
(01/26)
忍者アナライズ

PowerShellの勉強

# 実行中のパス取得/移動
$path = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $path

# サービスの実行状況
$RunningService = get-wmiobject win32_service | Where-Object {$_.State -eq "Running"} | select Name

# 正とするファイル読み込み
$fileName = $path + "\RunningOnly002.txt"
$file = New-Object System.IO.StreamReader($fileName, [System.Text.Encoding]::GetEncoding("sjis"))
while (($line = $file.ReadLine()) -ne $null)
{
Write-Host($line)
}
Write-Host("")
$file.Close()

# 終了
Write-Host("終了")






# 実行中のパス取得/移動
$path = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $path

# サービスの実行状況
$RunningService = get-wmiobject win32_service | Where-Object {$_.State -eq "Running"} | select Name

# $RunningService を1行づつ読み込む。そして検索する。
foreach ($hoge in $RunningService){
Select-String -Path .\RunningOnly002.txt -Pattern $hoge
}










get-wmiobject win32_service | select Name,State,StartMode,StartName | sort Name | Export-csv C:\list.txt -encoding Default

get-wmiobject win32_service | select Name | sort Name | more


get-wmiobject win32_service | Where-Object {$_.State -eq "Running"} | select Name | more

get-wmiobject win32_service | select Name,State | Where-Object {$_.State -eq "Running"} | select Name | more
get-wmiobject win32_service | select Name,State | Where-Object {$_.State -eq "Running"} | Where-Object {$_.State -eq "Name"} | more
get-wmiobject win32_service | select Name,State | Where-Object {$_.State -eq "Running"} | more

http://www.atmarkit.co.jp/ait/articles/1004/15/news106.html
PowerShellではパイプを「オブジェクトもしくはその配列」が「プロパティ値を保持したまま」渡ることがポイントである。


http://nasunoblog.blogspot.jp/2014/01/powershell-get-service-matome.html
ステータスで並び替える
Get-Service | Sort-Object status
サービス名で並び替える
Get-Service | Sort-Object name
表示名で並び替える
Get-Service | Sort-Object displayname
降順で並び替える
Get-Service | Sort-Object displayname -Descending



http://qiita.com/kmr_hryk/items/9b0d28ed0fda5b34f07c
なんらかの事情で新旧で一致している行も表示したい場合には
PS> Compare-Object $A $B -IncludeEqual


get-wmiobject win32_service | select Name,State | Select-String "Running" | % { $_.Line } | more

get-wmiobject win32_service | select Name,State | Select-String "Running" | % { $_.Matches.Value } | more

Get-Content c:\list.txt | Select-String "Running" | more

拍手[0回]

PR
2017.03.13 (Mon)
Category[Windows系]
Comment(0)

コメント

この記事にコメントする
Name:
Mail:
URL:
Title:
Comment:
Password:
  Vodafone絵文字 i-mode絵文字 Ezweb絵文字

Copyright © ESXi All Right Reserved.
Powered by Ninja Blog.
Template-Designed by ガスボンベ.