目标:
我正在建立一个密码库。我希望能够重组表并更改列的名称。
问题:
是否可以完成此任务?如果是的话,我将如何去做呢?
示例:
UserName Resource Password Properties
-------- -------- -------- ----------
username My App password {[hidden, False], [applicationid, 0...
是否可以为以后的条目永久更改UserName,Resource和Password列的名称?
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
假设表的格式使用的名称与图片中显示的名称相同,这应该允许您通过将格式表功能应用于表的格式来重新设置其名称。
关于powershell - PowerShell密码库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41914442/