{"id":18036291,"url":"https://github.com/nightroman/farnet.fsharp.powershell","last_synced_at":"2025-09-12T22:41:16.278Z","repository":{"id":142683454,"uuid":"270903194","full_name":"nightroman/FarNet.FSharp.PowerShell","owner":"nightroman","description":"F# friendly PowerShell Core helper","archived":false,"fork":false,"pushed_at":"2025-01-25T20:56:12.000Z","size":74,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-23T10:51:08.115Z","etag":null,"topics":["fsharp","powershell"],"latest_commit_sha":null,"homepage":"","language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nightroman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2020-06-09T04:33:52.000Z","updated_at":"2025-01-25T20:56:15.000Z","dependencies_parsed_at":"2024-10-30T12:12:29.422Z","dependency_job_id":"20b3637f-48f5-453d-ba89-de1077599dbb","html_url":"https://github.com/nightroman/FarNet.FSharp.PowerShell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FFarNet.FSharp.PowerShell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FFarNet.FSharp.PowerShell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FFarNet.FSharp.PowerShell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nightroman%2FFarNet.FSharp.PowerShell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nightroman","download_url":"https://codeload.github.com/nightroman/FarNet.FSharp.PowerShell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245809591,"owners_count":20676014,"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":["fsharp","powershell"],"created_at":"2024-10-30T12:12:21.356Z","updated_at":"2025-03-27T08:30:39.442Z","avatar_url":"https://github.com/nightroman.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[NuGet]: https://www.nuget.org/packages/FarNet.FSharp.PowerShell\r\n[GitHub]: https://github.com/nightroman/FarNet.FSharp.PowerShell\r\n[FarNet.FSharpFar]: https://github.com/nightroman/FarNet/tree/main/FSharpFar#readme\r\n[FarNet.PowerShellFar]: https://github.com/nightroman/FarNet/tree/main/PowerShellFar#readme\r\n[PowerShell]: https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.powershell?view=powershellsdk-7.4.0\r\n\r\n# FarNet.FSharp.PowerShell\r\n\r\nF# friendly PowerShell Core helper\r\n\r\n## Package (two in one)\r\n\r\n(1)\r\nThe NuGet package [FarNet.FSharp.PowerShell][NuGet] may be used as usual in F# projects.\r\nIn this case PowerShell Core comes with its dependency `Microsoft.PowerShell.SDK`\r\n(batteries included because Windows PowerShell cannot be used).\r\n\r\n(2)\r\nThe package is also used by [FarNet.FSharpFar] in Far Manager and its satellite `fsx.exe`.\r\nIn this case PowerShell Core comes with another package [FarNet.PowerShellFar].\r\nTo install FarNet packages, follow [these steps](https://github.com/nightroman/FarNet#readme).\r\nThus, you need these packages in Far Manager:\r\n\r\n1. `FarNet` - Far Manager .NET host and API for modules\r\n2. `FarNet.FSharpFar` - F# compiler service host and tools\r\n3. `FarNet.PowerShellFar` - PowerShell Core, host and tools\r\n4. `FarNet.FSharp.PowerShell` - this package connects 2. and 3. in 1.\r\n\r\nIt looks like a lot but includes all the batteries and the power plant.\r\nThis setup is portable with Far Manager, with caveats about prerequisites.\r\n\r\n## Overview\r\n\r\n**F# code**\r\n\r\nThe `PS` type wraps the [PowerShell] class and exposes somewhat similar members.\r\n\r\nUse `PS.Create()` instead of `PowerShell.Create()`.\r\n\r\nUse `Script()` and `Command()` instead of `AddScript` and `AddCommand()`.\r\n`PS` does not directly support command chains. But it is fine to invoke\r\nseveral scripts and commands using the same `PS` instance.\r\n\r\nUse the type safe generic `InvokeAs()` in addition to `Invoke()`.\r\nResult objects must be compatible with the specified type.\r\n\r\nUse F# asynchronous `InvokeAsync()` and `InvokeAsyncAs()`.\r\nFor parallel scenarios use different `PS` instances.\r\n\r\nUse the operator `?` for getting `PSObject` properties.\r\nNote, it also works for `Hashtable` wrapped by `PSObject`.\r\n\r\n**PowerShell code**\r\n\r\nThe default `$ErrorActionPreference` is `Stop`, safe for non-interactive.\r\n\r\nUse `Get-Type` to get a type defined in the calling F# assembly or script.\r\n\r\n## Example\r\n\r\n\"Hello, world!\" example:\r\n\r\n```fsharp\r\nopen FarNet.FSharp.PowerShell\r\n\r\nPS.Create().Script(\"Write-Output 'Hello, world!'\").Invoke()\r\n|\u003e printfn \"%A\"\r\n```\r\n\r\n## See also\r\n\r\n- [Samples](https://github.com/nightroman/FarNet.FSharp.PowerShell/tree/main/samples)\r\n- [Release Notes](https://github.com/nightroman/FarNet.FSharp.PowerShell/blob/main/Release-Notes.md)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightroman%2Ffarnet.fsharp.powershell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnightroman%2Ffarnet.fsharp.powershell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnightroman%2Ffarnet.fsharp.powershell/lists"}