Run PS script of PS5 in PS7 RRS feed

  • Question

  • I try to run script below in PS5 working but get error in PS7. Any suggestion? Thanks

    Line |
       7 |  $Form.Size = '745,1000'
         |  ~~~~~~~~~~~~~~~~~~~~~~~
         | Exception setting "Size": "Cannot convert the "745,1000" value of type "System.String" to type
         | "System.Drawing.Size"."

    $Form        = New-Object System.Windows.Forms.Form
    $DataGridView= New-Object System.Windows.Forms.DataGridView
    $Form.size = New-Object System.Drawing.Size(745,1000)
    $Form.StartPosition = 'Manual'
    $Form.Location = New-Object System.Drawing.Point(0,0)
    $Form.MaximizeBox = $False
    $Form.TopMost = $True
    $DataGridView.Size = New-Object System.Drawing.Size(720,875)
    $DataGridView.Location = New-Object System.Drawing.Point(5, 50)
    $DataGridView.ColumnHeadersHeight = 50
    $DataGridView.RowHeadersVisible = $False
    $DataGridView.BorderStyle = 'Fixed3D'
    $DataGridView.ReadOnly = $True
    $DataGridView.EnableHeadersVisualStyles = $False
    $Form.ShowDialog() | Out-Null

    • Edited by Ian3 Saturday, June 13, 2020 3:33 AM
    Saturday, June 13, 2020 3:30 AM

All replies

  • PS7 does not support that sntax as it is missing some bits from CORE and they affect many things about how PS7 supports previous versions of PS.

    I have registered this issue with the developers and they just get into a fog of "who is responsible".  

    PS 7 is only good for cross-platform scripts but will not allow PS 5.1 or earlier scripts to be ported. PS 7 is not a replacement for Microsoft PowerShell.  It is an OpenSourse solution that is not yet complete.

    You must explicitly create the object t assign it.  String casts cannot be dome for most things in PS7.

    The script you have posted works correctly in PS7.  The exception did not come from the script you posted.  I have run teh script in PS 7 and it runs the same as in PS 5.1 and earlier.


    Saturday, June 13, 2020 4:05 AM
  • Also note that we have no idea what you mean by "PSS".


    Saturday, June 13, 2020 4:06 AM
  • your problem not reproduced on the latest powershell 7.0.2 

    The opinion expressed by me is not an official position of Microsoft

    • Proposed as answer by Vector BCO Friday, July 3, 2020 5:27 AM
    Monday, June 15, 2020 7:38 AM
  • Hi,
    Was your issue resolved? 
    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.
    Best Regards,
    Yang Yang

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, July 3, 2020 5:26 AM