Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell Password Vault

Tags:

powershell

Goal:

I am building a Password Vault. I want to be able to restructure the table and change the names of the columns.

Question:

Is it possible to complete this task? And if yes how would I go about doing it?

Example:

UserName                                Resource                               Password                               Properties                            
--------                                --------                               --------                               ----------                            
username                                My App                                 password                               {[hidden, False], [applicationid, 0...

Is it possible to change the name of the column UserName,Resource and Password permanently for future entries?

function Get-SystemCreds{
  param(
    [switch]$AddCred,
    [switch]$Getcred,
    [switch]$RemoveCred
  )
  $vaultAssembly = [void][Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime]
  if($AddCred -eq $true){
    $vaultAssembly
    $ID= Read-Host 'Enter ID'
    $Password= Read-Host 'Password'
    $URL = Read-Host 'Enter URL'
    $vault=New-Object Windows.Security.Credentials.PasswordVault
    $cred=New-Object Windows.Security.Credentials.PasswordCredential($ID, $Password, $URL)
    $vault.Add($cred)
  }
  if ($RemoveCred -eq $true){
    $vaultAssembly
    $ID = Read-Host 'Enter ID'
    $cred = Get-SystemCreds -Getcred |
    Where-Object {$_.UserName -eq $ID}
    $vault.Remove($cred)
  }
  if ($Getcred -eq $true){
    $vaultAssembly
    (new-object Windows.Security.Credentials.PasswordVault).RetrieveAll() | % { $_.RetrievePassword(); $_ }
  }
}
like image 533
Alexander Sinno Avatar asked May 09 '26 12:05

Alexander Sinno


1 Answers

#Formats username column, sets different title for column
$format= @{Expression={$_.UserName};Label="UserNameColumnNameHere"} #Add comma and add formatting for other columns after here
(new-object Windows.Security.Credentials.PasswordVault).RetrieveAll() | % { $_.RetrievePassword(); $_ } | format-table $format

Assuming the format of the table uses variables named the same as those shown in your picture, this should allow you to reformat your table's names by applying the format-table function to it.

like image 166
DeepS1X Avatar answered May 12 '26 04:05

DeepS1X



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!