標籤:str rem let 數字 dash html while rip color
在cmd下執行powershell進入shell模式:Windows下的命令都可以執行如:
date ping ipconfig shutdown -r ipconfig | select-string -pattern 255ipconfig | findstr "Address"
1、執行指令碼準備:Get-ExecutionPolicy你可以選擇使用的執行策略有:Restricted - 指令碼不能運行。RemoteSigned - 本地建立的指令碼可以運行,但從網上下載的指令碼不能運行(除非它們擁有由信任的發行者簽署的數位簽章)。AllSigned – 僅當指令碼由信任的發行者簽名才能運行。Unrestricted – 指令碼執行不受限制,不管來自哪裡,也不管它們是否有簽名。你可以使用下面的cmdlet命令設定PowerShell的執行策略: Set-ExecutionPolicy <policy name> Set-ExecutionPolicy RemoteSigned 2、如何執行指令碼: C:\Scripts\Script.ps1OR.\Script.ps1ORpowershell devicelist.ps1 3、常用指令碼:
while (1) {date >>a.logsleep 2ping baidu.com >>a.log} for($i=0; $i -lt 100;$i=$i+1){Write-Host $iecho "ee"} do {Write-Host $i$i++}while ($i -le 5)
4、執行python指令碼:
$i = 1while (1) {date >>20171103.logecho "$i">>20171103.log$i++python devicelist.pysleep 10}
-le -gt-eq
http://www.powershellpro.com/powershell-tutorial-introduction/logic-using-loops/http://www.splaybow.com/powershell-2.htmlhttp://zh.wikipedia.org/wiki/Windows_PowerShell#.E6.8A.80.E8.A1.93.E5.9F.BA.E7.A4.8E
Windows Powershell指令碼執行