PS,power shell,随笔,不断更新

一、入门

get-help

get-help get-command

get-command

  get-command get-process

get-process

get-process notepad

 

二、管道符|

get-command get-pro | get-help

 

三、变量

$i="Hellow World"

echo $i

 

四、循环

1. 全

for ($i=1; $i -le 10; $i=$i+1)
 {
$sum=$sum+$i;
echo $i
 }

2. for括号里只有判断条件,初始化和执行在其他地方

$sum=0
$i=1
for(;$i -le 100;)
{
    $sum+=$i
    $i++
}
$sum

 3.读取文本文件

for($file=[IO.File]::OpenText("c:autoexec.bat") ; !($file.EndOfStream);$line=$file.ReadLine() )
{
    $line;
}
$file.Close()
REM Dummy file for NTVDM

 

posted @ 2020-08-10 16:28  die_melodie  阅读(76)  评论(0)    收藏  举报