> For the complete documentation index, see [llms.txt](https://resources.oskarklintrot.se/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://resources.oskarklintrot.se/cli-cheat-sheets/powershell.md).

# Powershell

[Rename files in bulk:](https://blogs.technet.microsoft.com/heyscriptingguy/2013/11/22/use-powershell-to-rename-files-in-bulk/)

```
> Get-ChildItem -Filter “*current*” -Recurse | Rename-Item -NewName {$_.name -replace ‘current’,’old’ }
```

Listen to new lines in a log fil containing a specific regex:

```
> Get-Content .\application_2017-05-30.log -Wait -Tail 0 | Select-String '.+(UserRepository).+'
```

Run first line only of a script:

```
> Get-Content <script> -First 1 | Invoke-Expression
```
