Wednesday, September 29, 2021

Password generators for Powershell

There are several ways to create a random password in your PowerShell script. 

Powershell function: 

A function to create an random password string example:

function Get-RandomPassword($length, $characters) {
$random = 1..$length | ForEach-Object { Get-Random -Maximum $characters.length }
$private:ofs=""
return [String]$characters[$random]
}
Get-RandomPassword -length 15 -characters "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#"

Powershell script:

You can use a this script for more advanced functions:

GitHub - PowerShell random password generator

API:

You can use an API:

GitHub - fawazsullia/password-generator

Example:

$url = 'https://passwordinator.herokuapp.com/generate?num=true&char=true&caps=true&len=14'
$password = (Invoke-WebRequest -Uri $url ).content | ConvertFrom-Json
$password.data



Thursday, September 23, 2021

Restore a file with Powershell

Did you delete the wrong file? Need to restore an accidentally deleted file? This Powershell Module
can be the solution:

PowerForensics


PowerForensics is a free Powershell module for forensic research with Powershell. You can use this module for restoring deleted files. Of course there is no guarantee that you can restore it, but you can try it. Check this nice tutorial:

How to Recover Deleted Files from the Drive? | CQURE Academy



Thursday, September 2, 2021

How to create an ISO with Powershell

I don't like to install ISO creation software on every jump or management server. I use a script from this website:


The code is easy to copy to a server in a RDP session or copy a PS1 file to a share and you can run on the server. You don't need any additional modules.