小编Ale*_*nno的帖子

由Invoke-RestMethod或ConvertFrom-Json返回的格式[pscustomobject]实例

我正在尝试从我从RESTful API接收的JSON文件创建一个表.

当我打印json对象的属性时,我得到一个这样的输出:

PS> Write-Output JSON.Object

Object1           : @{key1=property; key2=property; key3=property; key4=property}
Object2           : @{key1=property; key2=property; key3=property; key4=property}
Object3           : @{key1=property; key2=property; key3=property; key4=property}
Object4           : @{key1=property; key2=property; key3=property; key4=property}

我希望看到的输出是这样的:

Name              key1        key2        key3        key4
-----             ----        ----        ----        ----
Object1           property    property    property    property
Object2           property    property    property    property
Object3           property    property    property    property

另外,是否可以避免显示特定键及其属性?

例:

Name              key1        key2        key4      # ← Not displaying key3
-----             ----        ----        ----
Object1           property    property    property
Object2           property    property    property
Object3 …

powershell formatting json output-formatting

5
推荐指数
1
解决办法
1588
查看次数

PowerShell 密码保险箱

目标:

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

题:

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

例子:

UserName                                Resource                               Password                               Properties                            
--------                                --------                               --------                               ----------                            
username                                My App                                 password                               {[hidden, False], [applicationid, 0...
Run Code Online (Sandbox Code Playgroud)

是否可以为将来的条目永久更改列用户名、资源和密码的名称?

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 …
Run Code Online (Sandbox Code Playgroud)

powershell

3
推荐指数
1
解决办法
1621
查看次数

标签 统计

powershell ×2

formatting ×1

json ×1

output-formatting ×1