How to save the output of sap script to pdf document in sap

hi abapers
how to save the output of sap script in sap so that can retrieve the saved document later.
i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
how to use dms

Hi deepika,
This thread will solve ur problem OTF  -> PDF
Regards,
Pravin

Similar Messages

  • How to save the output  format of Quotation in PDF

    Dear all,
    When i am take a print priew of Quotation it show the quotation format in std sap format but it dosenot allow to save ?
    Is there any std setting for Saving the output format?
    Plz send the some solution for the same.
    Thx & Regards,
    PM
    Edited by: PM on Feb 7, 2008 12:46 PM

    HI
    If the output is sapscript, you can convert it into PDF format . There is one standard report RSTXPDFT2 to convert into PDF .
    Before Execute you will have to create a spool request . when you will execute this report you will have to enter the
    spool no. Then you can send this PDF file as attachment.
    Hope this will helpful.
    Bye
    Ellath

  • How to save the output of sap script in sap so that can be retrieved later

    hi abapers
    how to save the output of sap script in sap so that can retrieve the saved document later.
    i have to save the rcia output from sap script in pdf document in sap so that it can be retrieved later
    how to use dms
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Dec 26, 2008 11:01 AM

    Hi Deepika,
    Look into this link https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/401cca81-b861-2910-ada2-f416dfb3b3fe
    Regards,
    Pravin

  • How to save the output of a concurrent proram automatically

    Hi Friends,
    We have a requirement to save the output of a concurrent program to a specific folder for a reporting purpose. whenever we run that concurrent program it should save the out file in the network folder \\out_files\con_prg like that
    instead of storing it in its default folder in unix.(or I should recoganize which out file is for my concurrent program from the default folder and to move it to windows shared network folder). If it is one time , I can do it manually. But I need to schedule that concurrent program to run every day and transfer the output to the windows folder.
    Our system is Oracle Apps 11i , Data base 9i in Solaris.
    If you have any idea or sugesstion for this , please share it with me here.
    Thanks in advance,
    Vimal...

    Hi
    Thanks for the reply. I can get the name from the fnd_concurrent_requests table, But how can I identify which is the one submitted by me. Because there is possibility of multiple submission by the users with different parameters.
    I can give you more details.
    We are having a BI report (not oracle) for AR Aging Report details. It has a staging table to get the data from Oracle EBS.
    My job is to run Our Customized AR Aging Report with 2 different parameters like sysdate and the same date for last month.
    Get the output file and processs it (for this we are using VB Script) to populate the staging table from where the BI report get the data.
    So far I am doing this manually for more than a month.
    The Users wants to have all the above mentioned process to be combined as a single concurrent program , so that they can submit easily and populate the data any time of the day like other Oracle Standard reports.
    The BI report can be viewed any time of the day by more than 15 users and also AR Aging report can be run so many times in a day by another set of users.
    In this situation how can I get the exact output file of the request submitted by me.
    Thanks,
    Vimal...

  • How to save the output of report program??

    Hello Everbody,
    I want to save the output of a report program(i.e list),how can i do this???which function module should i use to achieve this???
    Thanx in advance.

    <b>data: list like abaplist occurs 0 with header line.
    data: begin of listout occurs 0,   
      line(1024) type c,   
      end of listout.
    do 100 times.
      write:/ sy-index.enddo.
    call function 'SAVE_LIST'
    EXPORTING*
    LIST_INDEX               = '0'
    tables 
      listobject    = list
    exceptions 
    list_index_invalid       = 1  
    others                   = 2          .
    call function 'LIST_TO_ASCI'    
    tables         
    listobject         = list    
    listasci           = listout 
       exceptions      
       empty_list         = 1    
       list_index_invalid = 2    
        others             = 3.
    call function 'GUI_DOWNLOAD' 
       exporting   
          filename = 'C:\Test.txt'  
      tables    
         data_tab = listout.</b>

  • How to generate the output of BSP application in PDF format?

    Hi,
    I need to modify one BSP application, which generates its output in the form of PDF. I have checked all the methods in the bsp pages and its corresponding controller class's. I couldn't find any relevant method, which deals with generating the output in PDF.
    Could you please share your valuable thoughts on this?
    Again it would be helpful, If anyone of you share some knowledge on Interactive Adobe Forms.
    Thanks,
    John

    okay, awesome
    i'd use DOM or some high level API for this (don't write it by hand using plain File IO)
    okay, try this site, it goes through building a document, adding elements, writing to file, etc.
    http://www.roseindia.net/xml/dom/

  • ALV ( How to save the output as Excel file whenever we runs the Report )

    Hi,
          Can any one please let me know , how we can automatically save a ALV Grid Display report in Excel Format in presentation server whenever we execute the Report.
    Regards
    Avi.

    Hi,
    This report demonstrates how to send some ABAP data to an
    EXCEL sheet using OLE automation.
    INCLUDE OLE2INCL.
    handles for OLE objects
    DATA: H_EXCEL TYPE OLE2_OBJECT,        " Excel object
          H_MAPL TYPE OLE2_OBJECT,         " list of workbooks
          H_MAP TYPE OLE2_OBJECT,          " workbook
          H_ZL TYPE OLE2_OBJECT,           " cell
          H_F TYPE OLE2_OBJECT.            " font
    TABLES: SPFLI.
    DATA  H TYPE I.
    table of flights
    DATA: IT_SPFLI LIKE SPFLI OCCURS 10 WITH HEADER LINE.
    *&   Event START-OF-SELECTION
    START-OF-SELECTION.
    read flights
      SELECT * FROM SPFLI INTO TABLE IT_SPFLI UP TO 10 ROWS.
    display header
      ULINE (61).
      WRITE: /     SY-VLINE NO-GAP,
              (3)  'Flg'(001) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (4)  'Nr'(002) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Von'(003) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (20) 'Nach'(004) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP,
              (8)  'Zeit'(005) COLOR COL_HEADING NO-GAP, SY-VLINE NO-GAP.
      ULINE /(61).
    display flights
      LOOP AT IT_SPFLI.
      WRITE: / SY-VLINE NO-GAP,
               IT_SPFLI-CARRID COLOR COL_KEY NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CONNID COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYFROM COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-CITYTO COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP,
               IT_SPFLI-DEPTIME COLOR COL_NORMAL NO-GAP, SY-VLINE NO-GAP.
      ENDLOOP.
      ULINE /(61).
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-007
           EXCEPTIONS
                OTHERS     = 1.
    start Excel
      CREATE OBJECT H_EXCEL 'EXCEL.APPLICATION'.
    PERFORM ERR_HDL.
      SET PROPERTY OF H_EXCEL  'Visible' = 1.
    CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING #1 = 'c:\kis_excel.xls'
    PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-008
           EXCEPTIONS
                OTHERS     = 1.
    get list of workbooks, initially empty
      CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP.
      PERFORM ERR_HDL.
    tell user what is going on
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - start
    CALL METHOD OF H_EXCEL 'Workbooks' = H_MAPL.
      CALL METHOD OF H_EXCEL 'Worksheets' = H_MAPL." EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    add a new workbook
      CALL METHOD OF H_MAPL 'Add' = H_MAP  EXPORTING #1 = 2.
      PERFORM ERR_HDL.
    tell user what is going on
      SET PROPERTY OF H_MAP 'NAME' = 'COPY'.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
              PERCENTAGE = 0
               TEXT       = TEXT-009
           EXCEPTIONS
                OTHERS     = 1.
    output column headings to active Excel sheet
      PERFORM FILL_CELL USING 1 1 1 'Flug'(001).
      PERFORM FILL_CELL USING 1 2 0 'Nr'(002).
      PERFORM FILL_CELL USING 1 3 1 'Von'(003).
      PERFORM FILL_CELL USING 1 4 1 'Nach'(004).
      PERFORM FILL_CELL USING 1 5 1 'Zeit'(005).
      LOOP AT IT_SPFLI.
    copy flights to active EXCEL sheet
        H = SY-TABIX + 1.
        PERFORM FILL_CELL USING H 1 0 IT_SPFLI-CARRID.
        PERFORM FILL_CELL USING H 2 0 IT_SPFLI-CONNID.
        PERFORM FILL_CELL USING H 3 0 IT_SPFLI-CITYFROM.
        PERFORM FILL_CELL USING H 4 0 IT_SPFLI-CITYTO.
        PERFORM FILL_CELL USING H 5 0 IT_SPFLI-DEPTIME.
      ENDLOOP.
    changes by Kishore  - end
    disconnect from Excel
         CALL METHOD OF H_EXCEL 'FILESAVEAS' EXPORTING  #1 = 'C:\SKV.XLS'.
      FREE OBJECT H_EXCEL.
      PERFORM ERR_HDL.
          FORM FILL_CELL                                                *
          sets cell at coordinates i,j to value val boldtype bold       *
    FORM FILL_CELL USING I J BOLD VAL.
      CALL METHOD OF H_EXCEL 'Cells' = H_ZL EXPORTING #1 = I #2 = J.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_ZL 'Value' = VAL .
      PERFORM ERR_HDL.
      GET PROPERTY OF H_ZL 'Font' = H_F.
      PERFORM ERR_HDL.
      SET PROPERTY OF H_F 'Bold' = BOLD .
      PERFORM ERR_HDL.
    ENDFORM.
    *&      Form  ERR_HDL
          outputs OLE error if any                                       *
    -->  p1        text
    <--  p2        text
    FORM ERR_HDL.
    IF SY-SUBRC <> 0.
      WRITE: / 'Fehler bei OLE-Automation:'(010), SY-SUBRC.
      STOP.
    ENDIF.
    ENDFORM.                    " ERR_HDL
    Please note that this example maybe slow at filling the excel table
    (perhaps four fields per second on a 900 MHz machine - almost 30 seconds
    for a short example).
    To get the data on properties and methods - there is a bit of smoke and mirrors
    going on here; they are EXCEL properties and methods, not sap ones - so you need
    to look at excel help to determine how a particular function is structured. then
    build the block in sap, as shown in the example.
    If you only want to transfer the data to Excel like when you transfer the data from
    ALV to Excel simply use the Function Modules:
    XXL_SIMPLE_API
    If you want more modifications when you transfer it to Excel use:
    XXL_FULL_API
    Hope this helps.
    Reward if helpful.
    Regards,
    Sipra

  • How to send the output of a script to a txt or rpt file using T-sql?

    Hi!
    I have some code which we use to record info about a database when we decommission it. I normally click Query > Results to File and then run it to produce a file.  I need to do this via t-sql so I can automate it. Any idea what code I need to make
    this script output to file?
    Thanks,
    Zoe
    SET NOCOUNT ON
    DECLARE @Databasename varchar(50)
    DECLARE @date as char(10)
    DECLARE @session_usr nchar(30);
    SET @Databasename = db_name()
    SET @date = convert(char(10), getdate(), 121)
    SET @session_usr = SYSTEM_USER;
    DECLARE @sqlCommand varchar(1000)
    select current_user
    Print '================================================================================'
    Print '========== SQL Decommission Report for '+ @@SERVERNAME +' ========='
    Print '========== Executed on ' + @date +' by '+ rtrim(@session_usr) +' ========='
    Print '================================================================================'
    Print ' '
    Print 'Database properties'
    Print '----------------------------------'
    select substring(name,1,25) as Name,substring(filename,1,40) as File_Name,cmptlevel as Compatibility_level from master.dbo.sysdatabases
    where name = @databasename
    Print 'Full Text Catalogs'
    Print '----------------------------------'
    select substring(name,1,20)as Name,status,substring(path,1,52) as Path FROM [master].[dbo].[sysfulltextcatalogs]
    Print 'SSIS Packages'
    Print '----------------------------------'
    IF (select cast(@@version as varchar)) like '%2012%' begin
    print 'sql 2012 instance'
    select substring(name,1,20) as Name,substring(description,1,40) as Description,ownersid as Owner from msdb.dbo.sysssispackages
    end else if (select cast(@@version as varchar)) like '%2008%' begin
    print 'sql 2008 instance'
    select substring(name,1,20) as Name,substring(description,1,40) as Description,ownersid as Owner from msdb.dbo.sysssispackages
    select substring(name,1,20) as Name,substring(description,1,40) as Description,substring(owner,1, 18) as Owner from msdb.dbo.sysdtspackages
    end else if (select cast(@@version as varchar)) like '%2005%' begin
    print 'sql 2005 instance'
    select substring(name,1,20) as Name,substring(description,1,40) as Description,suser_sname(ownersid) as Owner from msdb.dbo.sysdtspackages90
    select substring(name,1,20) as Name,substring(description,1,40) as Description,substring(owner,1, 18) as Owner from msdb.dbo.sysdtspackages
    end
    Print 'Linked Servers'
    Print '----------------------------------'
    SELECT substring(srvname,1,35) as LinkedServer_Name,substring(datasource,1,35) as Data_Source FROM master.dbo.sysservers WHERE isremote = 0
    Print 'Replication'
    Print '----------------------------------'
    IF (select count(*) from master.dbo.sysdatabases where name = 'Distribution') > 0
    select substring(publisher_db,1,20) as Published_DB,substring(Description,1,40) as Description from distribution.dbo.MSpublications
    ELSE print 'No replication'
    Print ' '
    Print 'Database Mail'
    Print '----------------------------------'
    SELECT substring(name,1,20) as Name,enabled,substring(email_address,1,35) as Email_address,last_email_date FROM msdb.dbo.sysoperators
    where last_email_date > dateadd(day,-30,getdate())-- detect whether any of the systems have sent an email in the last 30 days
    Print 'CLR Assemblies'
    Print '----------------------------------'
    select substring(Name,1,20) as Name,substring(Type_desc,1,35) as Description,Create_date from sys.objects where object_id in (select object_id from sys.assembly_modules)
    Print 'Logins'
    Print '----------------------------------'
    SET @sqlCommand = 'select substring(name,1,40) as Name,substring(dbname,1,30) as Default_Database from master.dbo.syslogins where sid in (select sid from '+ @databasename +'.dbo.sysusers where issqlrole <> 1 and hasdbaccess <> 0 and name <> ''dbo'')'
    EXEC (@sqlCommand)

    You can use bcp to export from database to flat file.
    It requires xp_cmdshell to work from a stored procedure.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to save the data to sap abap using Adobe Flex

    Hi Everybody......
    I am new to Adobe flex with sap abap.
          How to save the data in sap abap using Adobe Flex coding is Action Script and using RFC web service.
    Please give me any suggisions on that.
    Thank you
    Venkatesh V

    Hi Venkatesh,
    Try with folowing coding...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
         initialize="initApp()">
         <mx:Label x="10" y="23" text="Airline" width="90" id="lblAirline"/>
         <mx:TextInput x="108" y="21" id="txtAirline"/>
         <mx:Button x="10" y="49" label="Get Data" id="btnGetData" enabled="false" click="getData()"/>
         <mx:DataGrid x="10" y="97" id="dgFlightData" dataProvider="">
         </mx:DataGrid>
           <mx:Script>
              <![CDATA[
                   import mx.collections.ArrayCollection;
                   import mx.rpc.AbstractOperation;
                   import mx.rpc.events.FaultEvent;
                   import mx.rpc.soap.LoadEvent;
                   import mx.rpc.events.ResultEvent;
                   import mx.rpc.soap.WebService;
                   [Bindable] public var flightData:ArrayCollection;
        private var flightWS:WebService;
         private function initApp():void{
              flightWS = new WebService();
              flightWS.wsdl = "http://uscib20.wdf.sap.corp:50021/sap/bc/soap/wsdl11?services=ZGTEST&sap-client=000";
            flightWS.addEventListener(FaultEvent.FAULT,onWSError);
              flightWS.addEventListener(LoadEvent.LOAD,onWSDLLoaded);
             flightWS.addEventListener(ResultEvent.RESULT,onFlightWSGotResult);
              flightWS.loadWSDL();
    private function getData():void{
              var operation:AbstractOperation = flightWS.getOperation("ZGTEST");
              var input:Object = new Object();
              input.Airline = txtAirline.text.toUpperCase();
              operation.arguments = input;
              operation.send();
         private function onWSError  (event:FaultEvent):void{
         private function onWSDLLoaded(event:LoadEvent):void{
              btnGetData.enabled = true;
         private function onFlightWSGotResult(event:ResultEvent):void{
              flightData = event.result.SFLIGHT;
              ]]>
         </mx:Script>
    </mx:Application>
    Regards,
    Vinoth

  • How to save the data from alv output

    My ALV output is editable one.I want that user can edit the output and  save the output details into database.How to do it?
    Moderator Message: Basic Question. This site is not an alternative for your Consultancy work. Put some effort of your own before turning to the forums for help. This is your LAST warning. One more violation will lead to Account deletion.
    Edited by: kishan P on Dec 6, 2010 6:45 PM

    Hi
    U need to implement an user_command and manage the functionality SAVE: when the user press SAVE you'll store the data into db.
    There are several programs demo in SAP and many solution in SCN forum: try to search it
    Max
    Moderator message: please think twice before replying. By now you should know which type of questions will be locked, so no point in replying, in a double sense.
    Edited by: Thomas Zloch on Dec 6, 2010 2:49 PM

  • How to save xml output of fm into sap as xml

    how to save xml output of fm into sap as xml
    thank you,
    regards,
    Jagrut bharatkumar shukla

    Hi Jagrut
    The XML document can be stored in an ABAP variable rxml of the type STRING or XSTRING, or in an internal standard table sxml of the elementary line type C. Hence, I believe, your issue with the lenght can be resovled with this types.
    For rxml, you specify an interface reference variable of the type IF_IXML_OSTREAM that points to an IXML output stream.
    For rxml, you specify an interface reference variable of the type IF_IXML_DOCUMENT that points to an IXML document.
    With the stream factory you have several options. Before you call your CALL TRANSFORMATION, you setup your stream factory for these different options.
    1. You want to write the file to the application server file system. You want to create your OSTREAM as a binary string. In this example b_xml is an empty binary string. OSTEAM will be the reference variable of tyep IF_IXML_OSTREAM.
    ostream =
    streamfactory->create_ostream_xstring( b_xml ).
    You get the output lenght with the following:
    ressize = ostream->get_num_written_raw( ).
    You can then send the entire string to the file system with the following:
    transfer b_xml to filename1 length ressize.
    Also refer to this weblog:
    /people/tobias.trapp/blog/2005/05/04/xml-processing-in-abap-part-1
    Regards
    Ravish Garg
    <b>
    *Remember reward points is the best way to say thank you :)</b>

  • How to get the output of my batch file or script file

    Hello,
    I am a beginner in java and I have to run a batch file(in win) or a script(in linux). I want the output of the file in my java program. How to read the output. I used the following code and it always gave me the empty string output
    Runtime r = Runtime.getRuntime();
    Process p = null;
    p = r.exec("./test.bat"); //./test.sh
    int res = p.waitFor();
    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String tempStr = "", str = null;
    while((str=br.readLine()) != null) {
    tempStr += str + "\n";
    System.out.println(tempStr);
    I know this is a simple one but it's taking a lot of time. Can any one there help me quickly.

    hi
    the below function works well for me..
    just make a try with it
    protected String runConsoleCommand(String command) throws IOException {
    Process p = Runtime.getRuntime().exec(command);
    InputStream stdoutStream = new BufferedInputStream(p.getInputStream());
    StringBuffer buffer = new StringBuffer();
    for (; ; ) {
    int c = stdoutStream.read();
    if (c == -1)
    break;
    buffer.append( (char) c);
    String outputText = buffer.toString();
    stdoutStream.close();
    System.out.println("the output to file is:"+outputText);
    return outputText;

  • Sap isu-cic(how to check the output)

    HI to all......
    In isu-cic  how to check the output,i have done all the assign ments like framewrk creation etc...i defined the organizational structure with assign hoder...after that wats the next steps?
    can anybody plz reply....
    Cheers..
    sateesh

    Hello satish
    Step 1:
    Create Framework Id( assign hidden & visible components)
    Step 2: Create CIC profile
    Step 3: create Org unit and assign person
    Step 4: Assign CIC profile to Org. unit (or) person
    Path : Easy access screen
              Logistics>Customer service>Customer Interaction center>Adminstration>CIC structure>Org.Structure(Change,T.code-PPOMW)>select Org. unit
    In this screen on the top i.e menu bar find Go To
    Go To>detail Object>Enchanced object description
    Now u r in Maintain object page(T code-PP01)
    Now in the Active tab page select CIC profile
    Now in menu bar Edit>create infotype
    Again u r in new page(T code-PP01)
    Enter the CIC profile Id which u have created in customizing
    Run T code- CIC0
    I hope u r able to see the screen now
    Rgds
    Madhusudhan

  • How to write code to print and save the output in my GUI?

    I had been searching on code to program print and save commands to print and save the output from the GUI but to no avail. Can someone help me?

    The output will be link from the previous GUI page. Hence the output is a page with Jtable and a button for print to print the information in the JTable.

  • How to make the width of powershell script's output greater than 80 column?

    Hi,
    I am trying to remotely execute a powershell script through ssh, and I found the output of my script is only 80 width, a carriage-return and a line-feed are inserted after 79th column, and continue presenting the 80th value of each row onto another line.
    I want it greater than 80, such as 512.
    The code to print the output in my script is like:
    $allInfo | ConvertTo-Xml -as Stream -NoTypeInformation -Depth 1
    Any help will be really appreciated!

    But when I run the powershell script manually, I get the following error message, I do not know why, but anyway, my problem is resolved.
    Exception setting "BufferSize": "Cannot set the buffer size because the size specified is too large or too small.           
    Parameter name: value                                                                                                       
    Actual value was 512,25."                                                                                                   
    At C:\Users\qzhang\Documents\GetVM.ps1:30 char:16                                                                           
    + $Host.UI.RawUI. <<<< BufferSize = New-Object Management.Automation.Host.Size (512, 25)                                    
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException                                                    
        + FullyQualifiedErrorId : PropertyAssignmentException  
    Yeah, that's a good question.  I get the same thing here.  The longer solution the post covers which I've included below does work interactively, and looking at the differences it appears to be related to the buffer height.  My guess is when
    the existing console window already has more rows in the buffer than the 25 rows in height the command tries to define, this error occurs.
    if( $Host -and $Host.UI -and $Host.UI.RawUI ) {
    $rawUI = $Host.UI.RawUI
    $oldSize = $rawUI.BufferSize
    $typeName = $oldSize.GetType( ).FullName
    $newSize = New-Object $typeName (500, $oldSize.Height)
    $rawUI.BufferSize = $newSize

Maybe you are looking for