Get-Help.dk - Don's PowerShell Tools

Go back to the main page

About Everything

Credentials

I use credentials a lot. A lot! In ten minutes I can easily log on to different Azure tenants using 5 different sets of credentials.
Copy/pasting from Keepass, LastPass or whatever is too slow, as is using a clipboard manager thingy, so I figured I could just use save the credentials to disk and retrieve it using a simple menu.
So first, run Save-Credential. This asks for a login and password, and after that it'll create a folder, "<profile>\AppData\Roaming\PowerShell\Credentials".
And here it will save the credentials.
To retrieve any of the credentials you created, just use
$cred = Import-Credential
New-PSSession -Credential $Cred   # ....or whatever command you need to use

Files and Folders

I sometimes save files. And why not have a function to quickly test if a filename is valid? That's why I use Test-Filename.
Also, I use different folders for different tasks and projects. I hate copy/pasting paths all the time, so I created a cmdlet to allow me to quickly switch between paths.
Just run "Set-Folder"; this cmdlet shows a menu where your Desktop and My Documents are always listed first (and don't worry if you redirected the folders, it's supported).
If you want to add folders to the list, run
Set-Folder -Customise
This will load the configuration file in Notepad - so just add the folder names to that file.
E.g.
# Each line should contain a path.
# Lines beginning with a hashtag are ignored.
c:\Code\Project1\Source
c:\Users\whatever\Pictures
Note that leading and trailing whitespace is ignored.

Modules

Sometimes I want to know what module a certain command comes from. Or I want to see what cmdlets are in a given module.
So I wrote Get-ModuleCommand. Basically it just gets all available modules and commands and shows a nice list. Filtered if I wanted to.

Full list of cmdlets in the module:

Save-Credential Saves a credential object to a file (or asks first, and then saves)
Import-Credential Loads a credential object from disk - or shows a menu first, and then loads
Set-Folder Shows a list of folders and goes to the selected entry. Can be adapted.
Test-Filename Tests if a filename (no path) is allowed.
Get-DataFolder Gets the full path of a folder for saved data. Mainly a helper function for this module.
Get-ModuleCommand Shows available cmdlets and which module they come from.

To get more help, the PowerShell cmdlet "Get-Help" is your friend.

Import-Module DonsTools
Get-Help Set-Folder
etc. etc. etc.