Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »


https://www.tutorialspoint.com/powershell/index.htm


Enable the script to run

link
in powershell

Set-ExecutionPolicy Unrestricted

set-ExecutionPolicy
PS C:\windows\system32> Get-ExecutionPolicy
Restricted
PS C:\windows\system32> Set-ExecutionPolicy Unrestricted

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): yes
PS C:\windows\system32> Get-ExecutionPolicy
Unrestricted
PS C:\windows\system32>
Hello World
create

create a .ps1 file

>>>> write-host "hello world"


use ISE

run

> "hello world.ps1"

or

>& '.\hello world.ps1'

Print out

write-host "Welcome to my script"


Loop forLink


Loop while

write-host "Welcome to my script"

while ($true){

#test-connection 172.16.128.2
ping 172.26.128.2 -n 1 -l 1472
Start-Sleep -Seconds 6

}

create a ping and curl loopInvoke-WebRequest

for ($i=0; $i -lt 30; $i++){
#Start-Process powershell.exe -ArgumentList "ping 172.26.128.2 -n 100 -l 1472"
Start-Process powershell.exe -ArgumentList "Invoke-WebRequest 172.26.128.2 -UseBasicParsing"
Start-Process powershell.exe -ArgumentList "Invoke-WebRequest 172.26.128.2 -UseBasicParsing"
Start-Process powershell.exe -ArgumentList "Invoke-WebRequest 172.26.128.2 -UseBasicParsing"
Start-Process powershell.exe -ArgumentList "Invoke-WebRequest 172.26.128.2 -UseBasicParsing"
Start-Sleep -Seconds 1
}










  • No labels