PowerShell 密码保险箱 [英] PowerShell Password Vault

查看:58
本文介绍了PowerShell 密码保险箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标:

我正在构建一个密码保险箱.我希望能够重组表并更改列的名称.

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

问题:

有可能完成这个任务吗?如果是,我将如何去做?

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

示例:

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(); $_ }
  }
}

推荐答案

#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

假设表格的格式使用与图片中显示的名称相同的变量,这应该允许您通过对表格应用 format-table 函数来重新格式化表格的名称.

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.

这篇关于PowerShell 密码保险箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆