HewlettPackard / POSH-HPEOneView

PowerShell language bindings library for HPE OneView.
http://hewlettpackard.github.io/POSH-HPEOneView/
125 stars 52 forks source link

ConvertTo-OVPowerShellScript creates PS1 file for the last object #632

Closed DungKHoang closed 1 year ago

DungKHoang commented 1 year ago

Expected Behavior

Use the command to generate PowerShelll script for objects returned from the pipeline

Expect the PS1 script has all the network objects from the pipeline

Actual Behavior

The command creates a script for the last object from the pipelin

Correct syntax

To get the full PS1 script, you should do: Get-OVNetwork -ApplianceConnection $session | %{ ConvertTo-OVPowerShellScript -Export c:\net.ps1 -append -InputObject $_}

Steps to reproduce

Get-OVNetwork -applianceconnection $session | ConvertTo-OVPowerShellScript  -export c:\net.ps1

### Version Information
HPE OneView PowerShell Library Version  8.0.3334.2865
HPE OneView Appliance Version: 8.00.00.470555.00
ChrisLynchHPE commented 1 year ago

This is not a bug. You need to use the -Append parameter switch. If you do, the PS1 script will be saved with all of the pipeline output and not overwrite the file contents.

The correct command syntax would be:

Get-OVNetwork -ApplianceConnection $session | ConvertTo-OVPowerShellScript -Export c:\net.ps1 -Append

DungKHoang commented 1 year ago

Thanks! Would it be nice to have this example in the help file /DHK