> For the complete documentation index, see [llms.txt](https://intrusionz3r0.gitbook.io/intrusionz3r0/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://intrusionz3r0.gitbook.io/intrusionz3r0/windows-penetration-testing/powershell-cheetsheet.md).

# Powershell Cheetsheet

## Conditionals

### While

### IF Conditional

```powershell
$file = "C:\Users\user\Downloads\.zip"

if(Test-Path $file){
    Write-Host "The file exists!"
}
elseif ($file -eq "C:\Temp\test.txt"){
    Write-Host "The file is a test"
}
else{
   Write-Host "The file does not exists!"
}
```

### For each

```sh
Get-Content "C:\Users\username\OneDrive\Desktop\IPs.txt" | % { Test-Connection -Count 1 $_  }
```
