Windows Powershell脚本执行


在cmd下执行powershell进入shell模式:
变量定义:$i = 10
$a = ifconfig | findstr "192"
Windows下的命令都可以执行如:
date  ping   ipconfig  shutdown -r 
ipconfig | select-string -pattern 255
ipconfig | findstr "Address"
1、设置执行策略:
Dos窗口下执行powershell进入shell模式后执行Set-ExecutionPolicy RemoteSigned
 
2、执行脚本: 
powershell devicelist.ps1
 
3、常用脚本:
while (1) {
date >>a.log
sleep 2
ping baidu.com >>a.log
}
 
for($i=0; $i -lt 100;$i=$i+1)
{Write-Host $i
echo "ee"
}
 
do {
Write-Host $i
$i++
}
while ($i -le 5)


if(1){echo "AAA"} else{echo "BBB"}

#行注释符使用井号(#);块注释符使用“<#”和 “#>”来引起一段注释
 
4、执行python脚本:
$i = 1
while (1) {
date >>20171103.log
echo "$i">>20171103.log
$i++
python devicelist.py
sleep 10
}
-le 
-gt -eq


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM