{"id":14064279,"url":"https://github.com/jdhitsolutions/PSJsonCredential","last_synced_at":"2025-07-29T17:33:09.948Z","repository":{"id":145020783,"uuid":"77288319","full_name":"jdhitsolutions/PSJsonCredential","owner":"jdhitsolutions","description":"A PowerShell module for exporting and importing a PSCredential to a JSON file","archived":false,"fork":false,"pushed_at":"2023-08-04T15:53:29.000Z","size":77,"stargazers_count":23,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-03T07:37:16.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdhitsolutions.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2016-12-24T15:09:49.000Z","updated_at":"2024-01-09T06:52:51.000Z","dependencies_parsed_at":"2024-02-15T00:22:28.780Z","dependency_job_id":"3d4e09c3-4e5c-4747-a2ac-79d4f12e886e","html_url":"https://github.com/jdhitsolutions/PSJsonCredential","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSJsonCredential","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSJsonCredential/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSJsonCredential/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhitsolutions%2FPSJsonCredential/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdhitsolutions","download_url":"https://codeload.github.com/jdhitsolutions/PSJsonCredential/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228032926,"owners_count":17858918,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:03:47.451Z","updated_at":"2024-12-04T02:31:30.831Z","avatar_url":"https://github.com/jdhitsolutions.png","language":"PowerShell","funding_links":[],"categories":["PowerShell"],"sub_categories":[],"readme":"# PSJsonCredential\r\n\r\n[![PSGallery Version](https://img.shields.io/powershellgallery/v/PSJsonCredential.png?style=for-the-badge\u0026logo=powershell\u0026label=PowerShell%20Gallery)](https://www.powershellgallery.com/packages/PSJsonCredential/) [![PSGallery Downloads](https://img.shields.io/powershellgallery/dt/PSJsonCredential.png?style=for-the-badge\u0026label=Downloads)](https://www.powershellgallery.com/packages/PSJsonCredential/)\r\n\r\nThis PowerShell module contains a set of functions for storing a PSCredential object in a JSON file. Previous versions of this module relied on the CryptoAPI which limited it to Windows platforms only. This version uses a user-defined key to convert the password to a secure string that can be stored in the JSON file. The module should now work in Windows PowerShell and PowerShell 7.\r\n\r\n## Release\r\n\r\nThe most current version is available from the PowerShell Gallery.\r\n\r\n```powershell\r\nPS C:\\\u003e Install-Module PSJsonCredential\r\n```\r\n\r\n## Why?\r\n\r\nYou can achieve similar results using the [Export-CliXML](http://go.microsoft.com/fwlink/?LinkId=821767) and [Import-Clixml](http://go.microsoft.com/fwlink/?LinkId=821813) cmdlets. But those techniques rely on the CryptoAPI and are limited to Windows platforms. The files can also only be used on the computer where they were created only by the original user. Earlier versions of this module relied on these techniques.\r\n\r\nThe current version of the module relies on a user-defined key which you can think of as a password or passphrase. __You need to know the key to export and import the credential__. This has the added benefit of making the JSON file portable between computers.\r\n\r\n## Usage\r\n\r\n### Export\r\n\r\nYou can pipe any PSCredential object to [Export-PSCredentialToJson](docs/Export-PSCredentialToJson.md).\r\n\r\n```powershell\r\nPS C:\\\u003e $cred = Get-Credential Company\\Administrator\r\nPS C:\\\u003e $skey = Read-Host \"Enter a 16 character key\" -asSecureString\r\nEnter a 16 character key: ****************\r\nPS C:\\\u003e $skey.Length\r\n16\r\nPS C:\\\u003e $cred | Export-PSCredentialToJson -Path c:\\work\\admin.json -key $skey\r\n```\r\n\r\nThe export process will also capture metadata information about who converted the credential.\r\n\r\n```powershell\r\nPS C:\\\u003e Get-Content C:\\work\\admin.json\r\n{\r\n  \"UserName\": \"company\\\\administrator\",\r\n  \"Password\": {\r\n    \"value\": \"76492d1116743f0423413b16050a5345MgB8AEUARwBrAHAASABwAE8AdgBOAEgAWgA2AHkAWAA4AEYANgA4AEkAVQBKAEEAPQA9AHwAZQAzADAAMAA1ADEAOQAzADEANAA0AGIAYQA3AGEAOQBmAGMAZQAwADQANAAzADMAOAAxADEAMgA5ADAAMABkADkANwAzADAAZgAzADcAYgA0AGYAZQBiAGUANQBhADAAMgBmADEAZABkAGUAZQBjADMAZAA2AGYAYQA5AGUAMQA=\"\r\n    },\r\n  \"Metadata\": {\r\n    \"ExportDate\": \"7/19/2023 7:54:02 PM\",\r\n    \"ExportUser\": \"DESK10\\\\Jeff\",\r\n    \"ExportComputer\": \"DESK10\"\r\n    \"Comment\": \"\"\r\n  }\r\n}\r\n```\r\n\r\nBeginning with v2.2.0, you also have the option to encrypt the user name in the JSON file.\r\n\r\n```powershell\r\nPS C:\\\u003e $credential | Export-PSCredentialToJson -NoMetaData -EncryptUserName -Key $key -Path D:\\Save\\export.json\r\nPS C:\\\u003e Get-Content D:\\Save\\export.json\r\n{\r\n    \"Username\":  \"76492d1116743f0423413b16050a5345MgB8AHUASwBjADQAagArAFgAUABaAGoARwB0AGcASgBJAFcANgBqADkAcABWAGcAPQA9AHwAOQBlADkAZQA5AGMAZAA1ADgAOQBlAGIAYgBlADgAYQA5ADYAMwBhADIANQAwADQAOQA2AGMAMgBjADEAZQA1ADAAZAAzAGMAMABjADAAMgAwAGQAZgA3ADQANwBlADAANwA4ADcAOQBkADMAOAA0AGMANQA2ADEAYQBiADYAZABhAGUAYwAyAGQAYQA2ADUAMABhADkAMQAzADkAMgA0AGQAMwBmADEANABlADUAYQA3ADYAZgA4AGIAOQAzADUA\",\r\n    \"Password\":  \"76492d1116743f0423413b16050a5345MgB8ADQAcABVAEMAaQA5AHQARgBTAGMAYQBZAG0ATQBwAHAAUwByADIASABXAEEAPQA9AHwAZQAyADUAOAAxADgAYwAyADEAOQBlAGMANgAyAGYAYgAyADYAMwA3AGEAYwAxADYANgA0AGQAZABkADMAMQBmADYANQBiADgANAAwADEAZgA1AGMAOQBhAGYAMQBiADEAYwAyADMAYwAwAGEAOQBhAGMAZABjADIAOAA2ADMAMQA=\"\r\n}\r\n```\r\n\r\n### Viewing the Export\r\n\r\nYou can \"get\" the credential from the JSON file but without converting the password with [Get-PSCredentialFromJson](docs/Get-PSCredentialFromJson.md)\r\n\r\n```powershell\r\nPS C:\\\u003e Get-PSCredentialFromJson -Path C:\\work\\admin.json\r\n\r\n\r\n   Path: C:\\work\\admin.json\r\n\r\n\r\nUsername       : company\\administrator\r\nPassword       : 76492d1116743f0423413b16050a5345MgB8AEwAcAB3AGoARABOAGk\r\n                 AbABKAFgARAB6AEEAUQBPADYAVwBPAHgAZgB1AEEAPQA9AHwAYwA0AG\r\n                 MAZgAyAGMAYQBjAGEAMQBlAGMAMQBhADgAOQAwADAANgBkADgAYgA3A\r\n                 DMANgA4AGUAZABiADUAOAA0AGYANgA3ADYAYgBlAGYAOAA0AGUAOQBl\r\n                 ADIAOAAwADcANQBjADgAYwA1AGUAMQBhAGMANgBhADAAYgBkADIAYgA=\r\nExportDate     : 8/2/2023 12:53:32 PM\r\nExportUser     : COMPANY\\Jeff\r\nExportComputer : DESK11\r\nComment        :\r\n```\r\n\r\nThere is also a named list view called `nometa`.\r\n\r\n```powershell\r\nPS C:\\\u003e Get-PSCredentialFromJson -Path C:\\work\\admin.json | Format-List -view nometa\r\n\r\n\r\n   Path: C:\\work\\admin.json\r\n\r\n\r\nUsername       : company\\administrator\r\nPassword       : 76492d1116743f0423413b16050a5345MgB8AEwAcAB3AGoARABOAGk\r\n                 AbABKAFgARAB6AEEAUQBPADYAVwBPAHgAZgB1AEEAPQA9AHwAYwA0AG\r\n                 MAZgAyAGMAYQBjAGEAMQBlAGMAMQBhADgAOQAwADAANgBkADgAYgA3A\r\n                 DMANgA4AGUAZABiADUAOAA0AGYANgA3ADYAYgBlAGYAOAA0AGUAOQBl\r\n                 ADIAOAAwADcANQBjADgAYwA1AGUAMQBhAGMANgBhADAAYgBkADIAYgA=\r\nComment        :\r\n```\r\n\r\n### Importing\r\n\r\nAnd when you are ready, you can import the credential using [Import-PSCredentialFromJson](docs/Import-PSCredentialFromJson.md)\r\n\r\n```powershell\r\nPS C:\\\u003e $in = Import-PSCredentialFromJson -Path C:\\scripts\\admin.json -key $skey --Verbose\r\nVERBOSE: [BEGIN  ] Starting: Import-PSCredentialFromJson\r\nVERBOSE: [PROCESS] Processing credential from C:\\scripts\\admin.json\r\nVERBOSE: [PROCESS] Preparing key with a length of 16\r\nVERBOSE: [PROCESS] Converting to System.Security.SecureString\r\nVERBOSE: [PROCESS] Creating credential for company\\administrator\r\nVERBOSE: [END    ] Ending: Import-PSCredentialFromJson\r\nPS C:\\\u003e $in\r\n\r\nUserName                                  Password\r\n--------                                  --------\r\nCompany\\Administrator System.Security.SecureString\r\n\r\n\r\nPS C:\\\u003e $in.GetNetworkCredential().password\r\nP@ssw0rd\r\n```\r\n\r\n## Samples\r\n\r\nYou can find demonstration scripts using the module commands in the [Samples](samples) folder.\r\n\r\n## Is It Safe\r\n\r\nThe commands use the secure string convert cmdlets. The password is encoded with a user-defined key which can be a password or phrase of length 16, 24, or 32. Any password stored on disk is a potential security risk.\r\n\r\nBecause the JSON file is a plain text file, the user and computer name will be visible. You should still take precautions to secure and protect the JSON file.\r\n\r\n### Important\r\n\r\nStoring any credential to disk poses a potential security risk. It is up to you to decide if you wish to use the commands in this module. Some organizations may have security or usage policies in place that forbid the behavior.\r\n\r\n\u003e *__Use with caution and at your own risk.__*\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2FPSJsonCredential","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdhitsolutions%2FPSJsonCredential","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhitsolutions%2FPSJsonCredential/lists"}