0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PowerShell/概要、初心者向け知識

Last updated at Posted at 2021-06-20

以下初心者向けに概要や知識のまとめ

PowerShell概要

Microsoftが開発したCUI(キャラクタユーザーインターフェース)の一種。
主にテキスト(文字列)を使って、PCを動かしているWindows OSへ直接コマンドで命令を下せる。

コマンドプロンプトの欠点であるスクリプトの記述が長くなってしまうこと、またUnixなど他のシェルと比べると機能が弱いことなどを改善している
(例:コマンドレットと呼ばれるPowerShell上で利用可能なコマンド…コマンドレットの組み合わせにより、従来のコマンドプロンプトでは難しいとされていた処理が短いコードで可能になる。)

※上記情報は以下の以下の情報を参考にさせていただき執筆しました。
[PowerShell IT用語辞典:(https://www.otsuka-shokai.co.jp/words/powershell.html)]

使用環境(業務)

OS:Windows10
Windows PowerShell(x86)
Windows PowerShell ISE

forとforeachの違い

自分が少しつまづいた箇所。

foreach:存在するデータ件数分処理を回す
for:条件式を指定し、その条件に沿ったデータを作成

・ソース例

PowerShell.script(example)
   #取得結果の変数[$_result]は、項目「first_number」「second_number」を持つ
- for($_cnt=0; $_cnt -le $_result.length; $_cnt++){
      if([String]::IsNullOrEmpty($_result[$_cnt].second_number)){
    #取得結果の対象項目「second_number」がNULLの場合
        $_list += $_LF + $_result.first_number + ","
      }else {
        $_list += $_LF + $_result.first_number + $_result.second_number      
      }
  }

※今後も追記予定

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?