Category Archives: Powershell

PowerShell and OpenSSH team investments for 2024

This post was originally published on this site

PowerShell 7.5

We continue to follow our yearly release schedule for PowerShell 7 and the next version will align with .NET 9.

Pseudo-terminal support

PowerShell currently has a design limitation that prevents full capture of output from native commands by PowerShell itself.
Native commands (meaning executables you run directly) will write output to STDERR or STDOUT pipes.
However, if the output is not redirected, PowerShell will simply have the native command write directly to the console.
PowerShell can’t just always redirect the output to capture it because:

  • The order of output from STDERR and STDOUT can be non-deterministic because they are on different pipes,
    but the order written to the console has meaning to the user.
  • Native commands can use detection of redirection to determine if the command is being run interactive or non-interactively
    and behave differently such as prompting for input or defaulting to adding text decoration to the output.

To address this, we are working on an experimental feature to leverage pseudoterminals
to enable PowerShell to capture the output of native commands while still allowing the native command to seemingly write directly to the console.

This feature can then further be leveraged to:

  • Ensure complete transcription of native commands
  • Proper rendering of PowerShell progress bars in scripts that call native commands
  • Enable feedback providers to act upon native command output
    • For example, it would be possible to write a feedback provider that looked at the output of git commands
      and provided suggestions for what to do next based on the output.

Once this feature is part of PowerShell 7, there are other interesting scenarios that can be enabled in the future.

Platform support

Operating system versions and distributions are constantly evolving.
We want to ensure that a supported platform is a platform that is tested and validated by the team.

During 2024, the engineering team will focus on:

  • Making our tests reliable so we are only spending manual effort investigating real issues when test fails
  • Simplify how we add new platforms to our test matrix so new distro requests can be fulfilled more quickly
  • More actively track the lifecycle of platforms we support
  • Automate publishing the supported platforms list so that our docs are always up to date

Bug fixes and community PRs

The community has been great at opening issues and pull requests to help improve PowerShell.
For this release, we will focus on addressing issues and PRs that have been opened by the community.
This means less new features from the team, but we hope to make up for that with the community contributions
getting merged into the product. We will also be investing in the Working Group application process to expand the reach of those groups.

Please use reactions in GitHub issues and PRs to help us prioritize what to focus our limited time on.

Artifact management

Fundamentals work

Ensure PowerShell Gallery addresses the latest compliance requirements for security, accessibility, and reliability.

Include new types of repositories for PSResourceGet

We plan to introduce integration with container registries, both public and private, which will
help enterprise customers create a differentiation between trusted and untrusted content.
This change will allow for a Microsoft trusted repository while the PowerShellGallery continues as untrusted by default.
By having more options for private galleries, in addition to a Mirosoft trusted repository and the PowerShell Gallery,
this enables customers to have control over package availability suitable for their environments.

Concurrent installs

To improve performance during long-running installations, we plan to enable parallel operations
so multiple module installations can happen at the same time.
This change will be particularly impactful in modules with many dependencies, such as the Az module,
which currently can take significant time to install.

Local caching of artifact details

Currently the find-psresource cmdlet pulls information about available artifacts from service endpoints
and outputs the list locally. We believe there is opportunity to locally cache the metadata about available
artifacts to reduce network dependency and improve performance when resolving dependency relationships.
This would also help enable implementing a feedback provider to suggest how to install module that is not currently installed.
So if a user tries to run a cmdlet that is not installed, the feedback provider will suggest what module to install to get the cmdlet to work.

Intelligence in the shell

We are obvserving and being thoughtful about what it will mean to integrate the experiences
provided by large language models into shell experience.
Our current outlook is to think beyond natural language chat to deep integration of learning opportunities.

We also believe there are lots of improvements to the interactivity of PowerShell that does not require a large language model.
This includes some more subtle improvements to the interactive experience of PowerShell that would help increase productivity
and efficiency at the command line.

Configuration

Desired State Configuration (DSC) helped to enable configuration as code for Windows.
With v3, we are focusing on enabling cross-platform use, simplifying resource development, improving experience
to integrate with higher level configuration management tools, and improving the experience for end users.
Our goal is to be code complete by end of March and work towards a release candidate by middle of the year.
This is a complete rewrite of DSC and we welcome feedback during the design and development process.

Remoting

Win32_OpenSSH

We hope to continue bringing new versions of OpenSSH to the Windows Server platform. Another goal
is to reduce the complex steps required to install and manage SSH at scale, to enable
partners that create automation tools to use the same mechanism when connecting to Windows servers
as they use for Linux.

SSHDConfig

Monitoring and management of the sshd_config file at scale across platforms can be challenging.
We are working on a DSC v3 resource to enable management of sshd_config using a syntax that is
closer aligned to the command line tools used by modern cloud platforms.
Initially, we’ll be targeting auditing scenarios but we hope to enable full management of the file in the future.

Help system

platyPS is a module that enables you to write PowerShell help
documentation in Markdown and convert it to PowerShell help format.
This tool is used by Microsoft teams and the community of module authors to more easily write and maintain help documentation.
We hope to continue work in this area to address partner feedback.

Other projects

The projects above will already keep the team very busy, but we will continue to maintain other existing projects.
We appreciate the community contributions to these projects and will continue to review issues and PRs:

  • VSCode extension
  • PSScriptAnalyzer module
  • ConsoleGuiTools module
  • TextUtility module
  • PSReadLine module
  • SecretManagement module

Our other projects will continue to be serviced on an as needed basis.

Thanks to the community from Steve Lee and Michael Greene on behalf of our team!

The post PowerShell and OpenSSH team investments for 2024 appeared first on PowerShell Team.

PowerShell 7.4 General Availability

This post was originally published on this site

As we come to towards the end of 2023, we are excited to announce the general availability of PowerShell 7.4!
This release is built on .NET 8 and similarly,
is our latest Long Term Support (LTS) release supported for 3 years.

We want to thank our community and many contributors for their invaluable help identifying issues,
engaging in discussions in our repository, providing fixes and new features,
and helping us ship a high quality release!

How do I get it?

Since PowerShell 7 is supported on Windows, Linux, and macOS, there are a
variety of ways to get it.
If you installed the previous PowerShell 7 stable release (7.3) via the Windows Store or MSI (and opted into
Microsoft Update),
you will be automatically updated to 7.4 GA.

What’s new?

This release continues to focus on enhancing the shell experience and addressing
commonly reported customer and partner issues.

A detailed report of What’s New
is available in our documentation or via the WhatsNew
module.

Here are a few highlights:

PSResourceGet 1.0

This release includes PSResourceGet, which itself
was made generally available earlier this year.
PSResourceGet replaces PowerShellGet (although the two work side-by-side for legacy scripts) and where we will invest future
enhancements to the PowerShell module ecosystem.
This release focuses on a new codebase that is more maintainable and also provides better performance.
In addition, this module uses a different set of cmdlets to allow for breaking changes that provide a more intuitive user experience.

PSReadLine 2.3

This release includes the latest PSReadLine release
that contains a number of enhancements and bug fixes.

New stable features

The PowerShell Committee reviewed the experimental features we’ve had in the preview releases along with
community feedback (issues) and telemetry indicating the feature was used and not disabled and decided that
the following features were ready to be deemed stable for this release:

  • PSConstrainedAuditLogging
    This feature enables PowerShell 7 to adhere to WDAC Audit mode and log events into the Windows Event Log.
    In this mode, PowerShell runs scripts in Full Language Mode, but logs events if there would be
    a difference in behavior in System Lockdown mode.
    This makes it easier for administrators to deploy PowerShell 7 in environments that have System Lockdown mode enabled
    by understanding what scripts would need to be modified to run in that mode.
  • PSCustomTableHeaderLabelDecoration
    A common feedback from users is that with objects rendered as tables, it was not clear when a header
    label was not a property of the object.
    For example, when using Get-Process, you’ll see a column with the header CPU(s) to indicate the
    amount of cpu seconds used by that process.
    However, if you tried to access that property, you would find it’s actually called just CPU and the (s)
    was added to the header to indicate that it was in seconds.
    This new feature allows you to decorate the header label to make it clear that it is not a property of the object.
    The default decoration simply renders the header label in italics.image
  • PSWindowsNativeCommandArgPassing
    This is continuation of a feature we first added in 7.3.
    A major difference between Windows and non-Windows is how arguments are parsed particularly when quotes are involved.
    As more Open Source command-line tools are being used on Windows, we want to make sure that PowerShell
    can pass arguments to those tools in a way that works as expected.
    However, many legacy command-line tools on Windows do not handle arguments in the industry standard way.
    As such, a Windows mode for $PSNativeCommandArgumentPassing special cases some known tools to fallback to how
    it worked with Windows PowerShell while modern tools the new Standard mode.
    A Legacy mode is available for those that need to support legacy tools that do not work with the Windows mode.
  • PSNativeCommandErrorActionPreference
    This is another continuation of a feature we first added in 7.3.
    This feature allows you to treat a non-zero exit code from a native command as an ErrorRecord that would come from a cmdlet.
    This allows you to set $ErrorActionPreference to Stop and have PowerShell stop execution whether a cmdlet had an error
    or a native command had a non-zero exit code.
    This simplifies scripts that previously would have to check $LASTEXITCODE after execution of a native command or wrap it in a helper function.
  • PSNativeCommandPreserveBytePipe
    This feature allows you to preserve the byte stream when piping to or from a native command.
    Previously, all streams were converted to strings when piping to or from a native command and thus lost the original byte stream.
    This is useful for tools that expect binary input such as tar or zip.

There are still a number of experimental featues in this release pending additional user feedback before we can promote them to stable.
For example, we continue to iterate on the Feedback Provider
model as we get more feedback from users and partners who implement it.

Breaking changes

There are a few Breaking Changes
in this release that you should be aware of although we expect them to be rare.

One that could affect some users is the new -ProgressAction common parameter.
Similar to other common parameters, the new -ProgressAction parameter is automatically available to cmdlets and advanced functions.
This parameter allows you to control how progress is reported for a cmdlet or advanced function call.
Previously, you would have to set $ProgressPreference to SilentlyContinue to suppress progress and then restore it to its previous value.

What’s Next?

We will continue to focus on making PowerShell a great shell environment next year with PowerShell 7.5.
As usual, we’ll continue to address issues and bugs reported by our community and partners as well as adopt the latest .NET 9 preview releases.
Specific team investments will be discussed in a separate blog post early next year.

Thanks again to our community and partners for their continued support and feedback!

The post PowerShell 7.4 General Availability appeared first on PowerShell Team.

PowerShell 7.4 Release Candidate 1

This post was originally published on this site

PowerShell 7.4 RC-1 is now available

We’re proud to announce the availability of PowerShell 7.4.0-rc.1!
This is the first release candidate version of PowerShell 7.4 and is considered a “go-live” release
meaning that it is a supported release in production.
Now is the time to test out PowerShell 7.4 in your environment.
PowerShell 7.4 is built on top of .NET 8 and as a LTS (Long Term Support) release will be supported for 3 years.

How do I get it?

Since PowerShell 7 is supported on Windows, Linux, and macOS, there are a variety of ways to get it.
If you had installed the previous PowerShell 7.4 preview release (7.4.0-preview.6) via the Windows Store or MSI (and opted into Microsoft Update),
you will be automatically updated to 7.4.0-rc.1.

Note that after releases there are some delays in all release channels getting the latest bits.
If this version is not available on your release channel of choice expect it to be available
within 2 weeks.

What’s new in this release?

  • PSResourceGet is now GA and has reached a 1.0.0 version in this release– for more info on this module release check out this blog post
  • PSReadLine has been incremented to a new feature version 2.3.4– for more info on this module release check out this blog post
  • This release also contained a number of bug fixes– for the full list of changes please refer to the changelog

For more info on what’s changed in PowerShell 7.4, check out this page of the documentation.

Experimental Features which were made stable for 7.4

The following features were developed and released as experimental during the PowerShell 7.4
previews. Through telemetry and user feedback we determined that they should
be available as non-experimental features in the 7.4 release.

What’s next?

PowerShell 7.4 will be our next LTS release and expected to ship once an RC is determined to be ready.
We’ll have a separate blog post when the GA release of 7.4 becomes available.
We appreciate all the efforts of the community, both individuals and working group members,
and look forward to your continued feedback and contributions!

Sydney
PowerShell Team

The post PowerShell 7.4 Release Candidate 1 appeared first on PowerShell Team.

PowerShell Extension for Visual Studio Code Fall 2023 Update

This post was originally published on this site

PowerShell Extension for Visual Studio Code Fall 2023 Update

We are excited to announce that the fall update to the PowerShell Extension for Visual Studio Code
is now available on the extension marketplace.

In this update, thanks to efforts across the team, we are shipping the extension with the latest and greatest PSReadLine, v2.3.4! In addition this release contains a number of bug fixes and community contributions.

Thanks to all the many community contributors whose efforts make releases such as these possible!

Updates in the Fall Release

Note that these updates all shipped in our preview channel
for VS Code before shipping in our stable channel.

Some highlights of the fall release:

  • Stop hiding Activity Bar in ISE Mode.
  • Fix race condition with displaying PowerShell name on icon.
  • Support ~, ./ and named workspace folders in cwd.
  • Enhance additionalPowerShellExes setting.
  • Add startLocation setting for Extension Terminal. (Thanks @krishankanumuri!)
  • Upgrade bundled PSReadLine module to v2.3.4.
  • Add None to PsesLogLevel enum.
  • Fix debugging script blocks that aren’t in files.
  • Fix shell integration for PowerShell 5.1 with strict mode.

For the full list of changes please refer to our changelog.

In this release we also updated our versioning schema. The middle version number no longer corresponds to the month, but is simply incremented. Even versions are stable, and odd versions are pre-release, with the latter purposefully being versioned higher than the former in order to keep both channels (pre-release and stable) available in the Visual Studio Code marketplace.

Getting Support and Giving Feedback

While we hope the new release provides a better user experience, there are bound to be issues.
Please let us know if you run into anything.

If you encounter any issues with the PowerShell Extension in Visual Studio Code or have feature requests, the best place to get support is through our GitHub repository.

Sydney Smith
PowerShell Team

The post PowerShell Extension for Visual Studio Code Fall 2023 Update appeared first on PowerShell Team.

PSReadLine 2.3.4 GA Release

This post was originally published on this site

We are excited to announce the general availability of PSReadLine 2.3.4! After three preview
releases we are ready to release the GA version of PSReadLine 2.3.4. There are no new features in
this release from the previous preview but wanted to highlight some of the key changes since the
previous stable version, 2.2.6.

Installing PSReadLine 2.3.4

As usual, here are the instructions for installing the latest PSReadLine module. PSReadLine is
available from the PowerShell Gallery.

Use the following command to install PSReadLine using PowerShellGet v2.x:

Install-Module -Name PSReadLine -Force

If you are using the new PSResourceGet, you can use the following command:

Install-PSResource -Name PSReadLine

You may you need ot use the Force parameter to install this version side by side with any
previous preview releases installed.

Note


You must restart your PowerShell session to use the new version of
PSReadLine.

Highlights

Improvements to Predictors

Some of the biggest changes We have improved the user experience for ListView for PowerShell
Predictive IntelliSense. This includes allowing more than 10 responses, and adding a scrollable list
view. To help with navigation, we have also included a metadata line that informs users of their
position in the scroll.

Another addition are tooltips for plugin predictors. Tooltips are descriptions of prediction
results to help provide more details about what is being predicted. For example, the
Az.Tools.Predictor module provides details about what the suggested cmdlet does.

 

Image psrlga resized1

Additional Changes and fixes

Here are a few other changes and fixes that were made since the previous stable release:

  • Fix the menu completion to better handle the backspace key
  • Fix some typos in this repository (Thanks @spaette!)
  • Change default color for inline prediction to dim
  • Make tab completion show results whose ListItemText are different by case only (Thanks @dkaszews!)
  • Fix to use the default member color for members
  • Add support for upcasing, downcasing, and capitalizing word (Thanks @3N4N!)
  • Fix wrong cursor position in menu completion
  • Fix parameter dynamic help when the help content is specified in ParameterAttribute
  • Append reset VT sequence before rendering the inline prediction
  • Fix the broken doc link about PowerShellGet (Thanks @vimode!)
  • Add a sample for transforming Unicode code point to Unicode char by Alt+x
  • Improve the sensitive history scrubbing to allow retrieving token from az, gcloud, and kubectl
  • Improve the default sensitive history scrubbing to allow safe property access
  • Work around InvalidOperationException from Console API (Thanks @jazzdelightsme!)
  • Add the TerminateOrphanedConsoleApps option on Windows to kill orphaned console-attached process
    that may mess up reading from Console input (Thanks @jazzdelightsme)
  • Supports the text-object command diw in the VI edit mode (Thanks @springcomp!)

You can find the full list of changes on our PSReadLine release page, Big thank you to the
community members who have helped contributed to this release! Thank you @spaette,
@dkaszews, @vimode, @springcomp, @jazzdelightsme and @3N4N for your
contributions!

Previous Blogs

Here are links to all the previous blogs for the PSReadLine releases that highlight the feature
changes more closely.

Feedback

As per usual we love getting your feedback! Please submit bugs, feature requests, or questions to
the repository. Your feedback is always welcomed and appreciated!

Thanks! Give the new version a try and let us know what you think!

Steven Bucher and Dongbo Wang

PSReadLine Maintainers

The post PSReadLine 2.3.4 GA Release appeared first on PowerShell Team.

PowerShellGet 3.0.22-beta22 is now available

This post was originally published on this site

The latest preview of PowerShellGet is now available on the PowerShell Gallery. In this new preview version of PowerShellGet, PowerShellGet is a compatibility module that allows use of PowerShellGet 2.x (and below) cmdlet syntax with PSResourceGet functionality by making a best effort mapping between the cmdlet interfaces of both versions of the module. This module is a continuation of the CompatPowerShellGet project, but will now be shipping under the PowerShellGet module name.

How to install the module

To install from PSResourceGet (which is included in PowerShell 7.4 Preview 5)

Install-PSResource PowerShellGet -Prerelease

To install from PowerShellGet 2.2.5

Install-Module -Name PowerShellGet -AllowPrerelease -Force -AllowClobber

Note that Microsoft.PowerShell.PSResourceGet is also required to use this module,but it is not listed as a dependency as it is still in prerelease.

Expectations for the module

PowerShellGet is a compatibility module that allows use of PowerShellGet 2.x (and below) cmdlet syntax with PowerShellGet 3.0 (and newer) functionality by making a best effort mapping between the cmdlet interfaces of both versions of the module. For example, if a user has the PowerShellGet module installed and runs the command Install-Module PowerShellGet -AllowPrerelease PowerShellGet module will get auto loaded into the PowerShell Session and will map the command to PSResourceGet syntax Install-PSResource PowerShellGet -Prerelease The command will then be executed by the PowerShellGet 3.0 implementation.

This module is designed so that users will not need to immediately update their scripts in order to update to the latest version of PowerShellGet or to begin taking advantage of the performance improvements already available in PSResourceGet. We still do recommend that authors begin making the changes required to update their scripts to the new cmdlet interface if they would like to take advantage of the new features available in PSResourceGet (described in other blogs).

This compatibility module is designed so that it takes precedence over legacy versions of PowerShellGet. If you have this compatibility module installed and would not like it to be used, you can remove it from the PowerShell session using the Remove-Module command.

Please note that this flow is only possible if the user has both the PowerShellGet module installed and the Microsoft.PowerShell.PSResourceGet module installed. Once PSResourceGet is generally available it will be a dependency of future versions of PowerShellGet.

Timeline

This module is expected to ship in PowerShell 7.5. We expect this module to reach GA in the early PowerShell 7.5 timeframe to maximize opportunity for quality feedback. We do not expect to introduce new features to this module, all new features will be designed in Microsoft.PowerShell.PSResourceGet. Some new features may work in this module as a side effect.

Going forward we do not plan to do any future releases of the CompatPowerShellGet module, all releases will be under the PowerShellGet name.

How to give feedback or get support

This version of the module is still in preview, meaning that bugs are expected. We really appreciate any feedback on the module. If you have any bug reports, questions, or suggestions for features please open up a bug report in the PowerShellGet repository.

Sydney

PowerShell team

The post PowerShellGet 3.0.22-beta22 is now available appeared first on PowerShell Team.

Announcing PowerShell Crescendo 1.1.0 General Availability (GA)

This post was originally published on this site

We’re pleased to announce the availability of PowerShell Crescendo 1.1.0. Crescendo is a
framework to rapidly develop PowerShell cmdlets for common command line tools, regardless of
platform.

The release is now available for download on the
PowerShell Gallery.

Making Cmdlets with PowerShell Crescendo

Crescendo is a development accelerator enabling you to rapidly build PowerShell cmdlets that
leverage existing command-line tools. Crescendo amplifies the command-line experience of the
original tool to include object output for the PowerShell pipeline, privilege elevation, and
integrated help information. A Crescendo module replaces cumbersome command-line tools with
PowerShell cmdlets that are easier to use in automation and packaged to share with team members.

The 1.1 GA release includes the following features and benefits:

  • Updated schema to support additional features for this release.
  • Prevent overwrite of the module manifest and allow for module manifest adaptations.
  • Ability to bypass the output handler when the output of the native command doesn’t need to be
    transformed.
  • Improved error stream and error handling with Pop-CrescendoNativeError.
  • Added ability for parameter values to be translated via key/value pair with ArgumentTransform
    and ArgumentTransformType.
  • Improved code generation to reduce PSScriptAnalyzer output.
  • Improved error handling by setting $PSNativeCommandUseErrorActionPreference = $false.
  • Improved module metadata and added current Crescendo version to the module.

For more information about these changes, see What’s new in Crescendo 1.1.

Installing Crescendo

Requirements:

  • Microsoft.PowerShell.Crescendo requires PowerShell 7.2 or higher
  • Crescendo generated cmdlets require PowerShell 5.1 or higher

To install Microsoft.PowerShell.Crescendo:

Install-Module -Name Microsoft.PowerShell.Crescendo

To install Microsoft.PowerShell.Crescendo using the new PSResourceGet:

Install-PSResource -Name Microsoft.PowerShell.Crescendo

More information

To get started using Crescendo, check out the documentation.

Future plans

We value your ideas and feedback and hope you give Crescendo a try. Stop by our
GitHub repository and let us know of any issues you find or features you would like added.

The post Announcing PowerShell Crescendo 1.1.0 General Availability (GA) appeared first on PowerShell Team.

PSResourceGet Release Candidate is Now Available

This post was originally published on this site

Microsoft.PowerShell.PSResourceGet is a continuation of the PowerShellGet 3.0 project. The release candidate of this module under the new name is now available on the PowerShell Gallery. This release contains a number of bug fixes. This release is considered “go live” meaning that it is a fully supported release and expected to be of GA quality. After this release we don’t expect to make any changes before we make the module “Generally Available (GA)”. Please test out this module and report any issues so that we can resolve any blocking scenarios before this module becomes GA. Once this module becomes GA we will continue work with both bug patches and new feature releases.

How to install the module

To install from PSResourceGet (which is included in PowerShell 7.4 Preview 5)

Install-PSResource Microsoft.PowerShell.PSResourceGet -Prerelease

To install from PowerShellGet 2.2.5

Install-Module -Name Microsoft.PowerShell.PSResourceGet -AllowPrerelease

What is included in this preview

This release was focused on bug fixes, and did not introduce any new features

Bug Fixes

  • Bug fix for using Import-PSGetRepository in Windows PowerShell
  • Add error handling when searching for unlisted package versions
  • Bug fix for deduplicating dependencies found from Find-PSResource
  • Added support for non-PowerShell Gallery v2 repositories
  • Bug fix for setting ‘unknown’ repository APIVersion
  • Bug fix for saving a script with -IncludeXML parameter
  • Bug fix to write warning instead of error when package is already installed

For a full list of changes please refer to the changelog.

Documentation Updates

As a part of our efforts with this module we have also been updating the documentation for this module. Please check out the documentation and give us feedback in this repository so we can make improvements.

How to give feedback and Get Support

We cannot overstate how useful user feedback has been in the development of this module.

In order to give feedback or get support please open issues in our GitHub repository.

Sydney

PowerShell Team

The post PSResourceGet Release Candidate is Now Available appeared first on PowerShell Team.

PowerShell Adapter Feedback Provider

This post was originally published on this site

PowerShell Adapter Feedback Provider

We’ve renamed the JSON Adapter Feedback Provider to PowerShell Adapter Feedback Provider! We
heard some good feedback that the name wasn’t as descriptive to what the feedback provider does so
we’ve changed it to be more consistent with its functionality.

The Microsoft.PowerShell.PSAdapter is a module that identifies scripts and tools on the user
machine that can help users more convert native command output into PowerShell objects. We designed
this as a tool to help you discover what tools and scripts are available to help you convert native
output to PowerShell objects.

Note


Feedback Providers are an experimental feature of 7.4-preview3+ and so you will be required to use one of the 7.4 previews for JSON Adapters to work and have `PSFeedbackProvider` experimental feature enabled .

Installing PowerShell Adapter Feedback Provider

The release is available from the PowerShell Gallery.

Use the following command to install using PowerShellGet v2.x:

Install-Module -Name Microsoft.PowerShell.PSAdapter -AllowPrerelease

If you are using PSResourceGet, you can use the following command:

Install-PSResource -Name Microsoft.PowerShell.PSAdapter -AllowPrerelease

To use it you must import the module into your session:

Import-Module Microsoft.PowerShell.PSAdapter

We encourage you to include this command in your $PROFILE so that it’s loaded in every PowerShell
session you start.

What are PowerShell Adapters?

A PowerShell Adapter is a script that converts the text output of a native executable and converts
it to PowerShell objects. The PowerShell Adapter module is a feedback provider that identifies these
scripts and provides suggestions when you run the native command without any adapter script. You can
read more about feedback providers in our blog post, What are feedback providers?.

You can make PowerShell Adapters for any command. Just use the exact name of the command as the
prefix to the script so that the module can identify the script and suggest it. For example, you
must name the script <name of command>-adapter.ps1 so that the PowerShell Adapter can identify it
as a adapter script. This script’s file location must included in your $env:PATH variable to be
found.

Creating an Adapter

For example, you want to use the macOS command vm_stat like a PowerShell object. Create a file
called vm_stat-adapter.ps1 and add the location of this file to your $env:PATH variable. The
PowerShell Adapter Feedback Provider will identify it as a possible suggestion for vm_stat.

Here is an example PowerShell Adapter for vm_stat:

[CmdletBinding()]
param ( [Parameter(ValueFromPipeline=$true)][string]$inputObject )
BEGIN {
    $h = @{}
}

PROCESS {
    if ( $inputObject -match "^Mach Virtual") {
        if ($inputObject -match "page size of (d+) ") {
            $h['PageSize'] = [int]$matches[1]
        }
    }
    else {
        $k,$v = $inputObject -split ":"
        $AdjustedK = ($k -replace "[ -]","_").trim() -replace '"'
        $AdjustedV = "$v".Trim() -replace ".$"
        $h[$AdjustedK] = [int64]$AdjustedV
    }
}

END {
    [pscustomobject]$h
}

The following shows the suggestion from the Feedback Provider when you run vm_stat without the
adapter script:

Screenshot showing vm_stat suggestions.

For another example, we can create a PowerShell Adapter for the df utility using the TextUtility
PowerShell module. We just need to create a df-adapter.ps1 script and include the following:

$input | ConvertFrom-TextTable -ConvertPropertyValue

DF utility adapter

Support for jc

The JSON Converter, jc, is a command line utility that converts text output to JSON for variety of
command line tools. The PowerShell Adapter module can suggest using jc as an adapter if the user
has it installed. When you use a command supported by jc, the PowerShell Adapter Feedback Provider
suggests using jc piped to ConvertFrom-JSON.

You can find instructions on how to install jc and more details about the tool in their
source code repository. When jc supports the native command, this can be the simplest way
to convert the output without needing to write a PowerShell Adapter. You can see this suggestion in
the previous screenshot for the df example.

The jc command supports many native commands, however, the Feedback Provider only provides jc
suggestions for the following commands:

"arp", "cksum", "crontab", "date", "df", "dig", "dir", "du", "file", "finger",
"free", "hash", "id", "ifconfig", "iostat", "jobs", "lsof", "mount", "mpstat",
"netstat", "route", "stat", "sysctl", "traceroute", "uname", "uptime", "w", "wc",
"who", "zipinfo"

Also, you need to use the appropriate parameters with your native command for jc to work properly.
For example, if you want to use jc with uname, you need to use uname -a because that produces
the output that jc expect to convert to JSON.

Predictive IntelliSense Support

We’ve also added Predictive IntelliSense support for the PowerShell Adapter feedback provider. With
Predictive IntelliSense enabled, the PowerShell Adapter Feedback Provider provides suggestions that
Predictive IntelliSense will show you on the command line. This makes it easy to try immediately,
rather than manually running the suggestion.

Screenshot showing predictive intellisense support

Feedback

We really appreciated the feedback we got on the first announcement of this tool and would love to
continue getting great feedback! The GitHub repository for this tool is still named
JSONAdapters, however the module name is Microsoft.PowerShell.PSAdapter and any reference to
this tool will be PowerShell Adapters going forward. You can submit any feedback to the
JsonAdapter repository.

Thank you so much!

Steven Bucher

PowerShell Team

The post PowerShell Adapter Feedback Provider appeared first on PowerShell Team.

PSResourceGet Preview 24 is Now Available

This post was originally published on this site

Microsoft.PowerShell.PSResourceGet is a continuation of the PowerShellGet 3.0 project. The latest preview release of this module under the new name is now available on the PowerShell Gallery. This release contains improved publish support, new aliases and many bug fixes. This is the last planned preview release before we release a “Release Candidate (RC)” of the module. From there we don’t expect to make any changes before we make the module “Generally Available (GA)”.

How to install the module

To install from PSResourceGet previews (which is included in PowerShell 7.4 Preview 4)

Install-PSResource Microsoft.PowerShell.PSResourceGet -Prerelease

To install from PowerShellGet 2.2.5

Install-Module -Name Microsoft.PowerShell.PSResourceGet -AllowPrerelease

What is included in this preview

For the purposes of this blog post, this list includes changes from both beta23 and beta24.

New Features

  • *-PSResourceRepository -Uri now accepting PSPaths
  • Add aliases for Install-PSResource, Find-PSResource, Update-PSResource, Publish-PSResource (‘isres’,’fdres’,’udres’,’pbres’)
  • Add support for NuGet.Server application hosted feeds
  • Add Import-PSGetRepository function to import existing v2 PSRepositories into PSResourceRepositories
  • Add ‘Get-PSResource’ alias to ‘Get-InstalledPSResource’
  • Add -ApiVersion parameter to Set-PSResourceRepository
  • Add support for FindNameGlobbing scenarios (i.e -Name az*) for MyGet server repository (V3)
  • Support Credential Persistence for Publish-PSResource
  • Support publishing with a prerelease dependency

Bug Fixes

  • Better error handling for scenario where repo ApiVersion is unknown and allow for PSPaths as URI for registered repositories
  • Bug fix for Uninstall to remove older versions of a package that are not a dependency
  • Bug fix for Publish finding prerelease dependency versions
  • Fix pagination for V3 search with globbing scenarios
  • Bug fix for publishing with ExternalModuleDependencies
  • Update Save-PSResource -Path param so it defaults to the current working directory
  • Allow environment variables in module manifests (Thanks @ThomasNieto!)
  • Updating prerelease version should update to latest prerelease version
  • Enable UNC Paths for local repositories, source directories and destination directories (Thanks @FriedrichWeinmann!)
  • Bug fix for version parsing in Publish-PSResource
  • Bug fix for Get-InstalledPSResource returning type of scripts as module
  • Bug fix for finding all versions of a package returning correct results and incorrect “package not found” error
  • Bug fix for saving module dependencies
  • Add parameters to Install-PSResource verbose message
  • Bug fix for parsing required modules when publishing
  • Bug fix for saving dependency modules in version range format
  • Bug fix for updating to a new version of a prerelease module
  • Set-PSResourceRepository run without -ApiVersion paramater no longer resets the property for the repository
  • Many error handling updates

Breaking Change

  • Update to Find-PSResource to return packages from all criteria matching repositories, in priority order, by default.

For a full list of changes please refer to the changelog.

Documentation Updates

As a part of our efforts with this module we have also been updating the documentation for this module. We recently updated the documentation on supported repositories to include more information on how to publish. Please check out the documentation and give us feedback in this repository so we can make improvements.

We also recently added an examples folder to our repository with examples for the expected behavior of Find and Install.

How to give feedback and Get Support

We cannot overstate how critical user feedback is at this stage in the development of the module. Feedback from preview releases help inform design decisions without incurring a breaking change once generally available and used in production.

In order to help us to make key decisions around the behavior of the module please give us feedback by opening issues in our GitHub repository.

Sydney

PowerShell Team

The post PSResourceGet Preview 24 is Now Available appeared first on PowerShell Team.