Useful commands I've put together for automating tasks I do all the time
Just a quick simple script to generate a new secure password.
New-SecurePassword [-Length] <String> [<CommonParameters>]
Simple script to generate a new secure password where you only need to specify the length. The password will be shown using write-host and automatically copied to the clipboard.
New-SecurePassword.ps1 -Length 16
Enter the password length required. For example: 16
Starts a new aws SSM session
New-SSMSession [-instanceID] <String> [[-localport] <String>] [[-remoteport] <String>] [[-awsprofile] <String>]
[<CommonParameters>]
Starts a new AWS SSM session from an instanceID
PS C:\> New-SSMSession -instanceID $instanceID -awsprofile $awsprofile
The ID of the EC2 instance to connect to
The local port to use for the RDP ssm session. Defaults to 55678
The remote port to use for the RDP ssm session. Defaults to 3389
aws cli profile to use. defaults to default
Wrapper around New-SSMSession to connect using only an instance name
Connect-EC2Instance [-Name] <String> [[-awsprofile] <String>] [<CommonParameters>]
Wrapper around New-SSMSession to connect using only an instance name. Runs a command to determine instance ID from name, then starts an RDP session.
PS C:\> Connect-EC2Instance -name "PWM" -awsprofile "doubleline"
The Name of the EC2 instance to connect to
aws cli profile to use. defaults to default
Quick test if git is installed.
Test-IsGitInstalled [<CommonParameters>]
Quick test if git is installed. Returns true if it is, false if it's not.
PS C:\> Test-IsGitInstalled
Wrapper around git clone
that changes into the directory after cloning.
Invoke-GitClone [-url] <String> [<CommonParameters>]
Wrapper around git clone
that changes into the directory after cloning. Also makes sure URL is a valid git repo.
PS C:\> Invoke-GitClone -url "https://github.com/jrogers-dlp/JarTools.git"
Quickly open code to edit this module
Edit-JarTools [-file]
Quickly open code to edit this module. You can specify -file
to only open the module and not the directory.
PS C:\> Edit-JarTools
PS C:\> Edit-JarTools -file
return the $MyInvocation variable in a function.
Get-MyInvocation
return the $MyInvocation variable in a function.
PS C:\> Get-MyInvocation