{"id":15192175,"url":"https://github.com/powershell/powershellstandard","last_synced_at":"2025-04-12T18:39:39.784Z","repository":{"id":41322461,"uuid":"119761109","full_name":"PowerShell/PowerShellStandard","owner":"PowerShell","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-14T00:18:16.000Z","size":527,"stargazers_count":161,"open_issues_count":37,"forks_count":25,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-03T20:12:34.129Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/PowerShell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-01T00:28:38.000Z","updated_at":"2025-03-28T22:05:13.000Z","dependencies_parsed_at":"2024-06-21T16:43:18.594Z","dependency_job_id":"130ac058-5616-482f-ae8d-5bfe6a1feca4","html_url":"https://github.com/PowerShell/PowerShellStandard","commit_stats":{"total_commits":63,"total_committers":8,"mean_commits":7.875,"dds":"0.31746031746031744","last_synced_commit":"59998dced0948864a33fe6aed5f0a07bd12a91a6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2FPowerShellStandard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2FPowerShellStandard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2FPowerShellStandard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PowerShell%2FPowerShellStandard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PowerShell","download_url":"https://codeload.github.com/PowerShell/PowerShellStandard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247070928,"owners_count":20878586,"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-09-27T21:05:56.251Z","updated_at":"2025-04-03T20:12:38.268Z","avatar_url":"https://github.com/PowerShell.png","language":"C#","readme":"# ![logo][] PowerShell Standard\n\n## Supports PowerShell Core and Windows PowerShell\n\nPowerShell Core is a cross-platform (Windows, Linux, and macOS) automation and configuration tool/framework that works well with your existing tools and is optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models.\nIt includes a command-line shell, an associated scripting language and a framework for processing cmdlets.\n\nWindows PowerShell is a Windows command-line shell designed especially for system administrators.\nWindows PowerShell includes an interactive prompt and a scripting environment that can be used independently or in combination.\n\nPowerShell Standard is a reference assembly that has been created to assist developers create modules and PowerShell hosts which will run on PowerShell.\nThe reference assembly contains no actual implementation but rather will allow you to use only APIs that exist across different versions of PowerShell. This means that you still need to run within a PowerShell runtime.\n\n\u003e NOTE: You should not use PowerShell Standard for standalone applications that leverage PowerShell.\nFor that, you should use the [PowerShell SDK](https://www.nuget.org/packages/Microsoft.PowerShell.SDK).\nPowerShell Standard's main scenario is for running within a PowerShell session.\n\n## PowerShell Standard Libraries\n\nTwo PowerShell Standard `.nupkg` versions are available:\n\n- PowerShell Standard.Library Version 3\n  - This allows you to create PowerShell modules and PowerShell hosts which will run on PowerShell Version 3 and later including PowerShellCore\n\n- PowerShell Standard.Library Version 5.1\n  - This allows you to create PowerShell modules and PowerShell hosts which will run on PowerShell Version 5.1 and later including PowerShellCore\n\nBoth are available on [NuGet.org](https://www.nuget.org/packages/PowerShellStandard.Library)\n\n[logo]: https://raw.githubusercontent.com/PowerShell/PowerShell/master/assets/Powershell_black_64.png\n\n### Building PowerShell Standard Libraries\n\nThe script `build.ps1` is the tool to build, package, and test the PowerShell Standard Libraries.\nIn to build the PowerShell Standard Libraries simply type:\n\n```powershell\n./build.ps1\n```\n\n### Running tests\n\nThere are some very simple tests which test the validity of the PowerShell Standard Libraries.\nThese tests may be found in the test directory associated with the version of the PowerShell Standard Library\n| Version | Location |\n| 3 | `test/3` |\n| 5 | `test/5` |\n\nto run the tests, simply type:\n\n```powershell\n./build.ps1 -test\n```\n\n### Creating NuGet Packages\n\nIn order to create NuGet packages, simply type:\n\n```powershell\n./build.ps1 -Pack\n```\n\nThis will create 2 NuGet packages; 1 for each version of the PowerShell Standard Library in the root of the repository.\nThese can then be uploaded to https://nuget.org/ if desired.\n\n### Removing Build Artifacts\n\nTo remove all build artifacts (except for the .nuget files in the root of the repository), type the following:\n\n```powershell\n./build.ps1 -Clean\n```\n\n## How to use the PowerShell Standard Library\n\n### Via Visual Studio\n\nUsing the PowerShell Standard Library within Visual Studio is as simple as installing the package into your solution and building the project\n\nCreate a project, and in the Package Manager Console (Tools -\u003e Nuget Package Manager -\u003e Package Manager Console) type:\n\n```powershell\ninstall-package -id PowerShellStandard.Library\n```\n\nThis will add `System.Management.Automation` to your project references.\nAfter this, you must set `Copy Local` to False in the Reference Properties pane.\n\n![Copy Local = False](Images/CopyLocal.png)\n\nThis will keep the PowerShell Standard Library from being copied into your release/publish directories.\nThis is because the PowerShell Standard Library is a _reference_ assembly and doesn't actually contain any implementations and should never be distributed with your module.\nYou may now create and build your module in the usual way.\n\nOnce your module is built, you can see the portability of your module very easily, if you have both Windows PowerShell and PowerShell core on your system.\nThe following demonstrates the portability of using PowerShell Standard.\n\nThe following shows the same assembly being used by both Windows PowerShell, PowerShell Core, and via Docker; PowerShell Core on Linux.\n\n```powershell\nPS\u003e powershell\nWindows PowerShell\nCopyright (C) Microsoft Corporation. All rights reserved.\n\nLoading personal and system profiles took 714ms.\nPS\u003e gci\n\n    Directory: C:\\users\\jimtru\\documents\\visual studio 2017\\Projects\\ClassLibrary2\\ClassLibrary2\\bin\\Debug\n\nMode                LastWriteTime         Length Name\n----                -------------         ------ ----\n-a----         3/7/2019  10:54 AM           4608 ClassLibrary2.dll\n-a----         3/7/2019  10:54 AM          15872 ClassLibrary2.pdb\n\nPS\u003e import-module .\\ClassLibrary2.dll\nPS\u003e \"joe\",\"jane\" | Invoke-Demo\nHello 'joe'\nHello 'jane'\nPS\u003e exit\n\nPS\u003e pwsh-preview\nPowerShell 6.1.0-rc.1\nCopyright (c) Microsoft Corporation. All rights reserved.\n\nhttps://aka.ms/pscore6-docs\nType 'help' to get help.\n\nPS\u003e import-module .\\ClassLibrary2.dll\nPS\u003e \"joe\",\"jane\" | Invoke-Demo\nHello 'joe'\nHello 'jane'\nPS\u003e exit\n\nPS\u003e $m = \"C:\\Users\\jimtru\\DOCUME~1\\VIBB41~1\\Projects\\CLASSL~2\\CLASSL~1\\bin\\Debug\"\nPS\u003e docker run --rm -it -v \"${m}:/module\" mcr.microsoft.com/powershell:preview\nPowerShell 6.2.0-rc.1\nCopyright (c) Microsoft Corporation. All rights reserved.\n\nhttps://aka.ms/pscore6-docs\nType 'help' to get help.\n\nPS /\u003e hostname\nadd7d6ed4818\n\nPS /\u003e select-string pretty /etc/os-release\netc/os-release:5:PRETTY_NAME=\"Ubuntu 18.04.2 LTS\"\n\nPS /\u003e gci /module\n    Directory: /module\nMode                LastWriteTime         Length Name\n----                -------------         ------ ----\n------            3/7/19  6:54 PM           4608 ClassLibrary2.dll\n------            3/7/19  6:54 PM          15872 ClassLibrary2.pdbPS /\u003e import-module /module/ClassLibrary2.dll\n\nPS /\u003e Import-Module /module/ClassLibrary2.dll\nPS /\u003e \"joe\",\"jane\" | Invoke-Demo\nHello 'joe'\nHello 'jane'\n```\n\nAnd that's how you can build a single module used by Windows PowerShell, PowerShell Core on Windows and Linux!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowershell%2Fpowershellstandard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpowershell%2Fpowershellstandard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowershell%2Fpowershellstandard/lists"}