Powershell output converting

I have a task to do, but I'm really newbie at Powershell and I don't really think that I can handle is by myself. Sorry for my english btw :p
The task is:
Letter directions and subdirections and:
-sort it growing by extensions and decreasing by nbame
-display the list with only small letters
-show contens of directions and subdirections
-show elements with attributes : directions, archive, not read only
- ask user the question whether would he like to remove all doc files and does what he says
-clean out powershell screen
-after all shows the list of docs files, saves it in .txt file and opens it in the foreground
I am not really sure if I explained it cleary. I've done in before in cmd, it looked like this:
@echo off
dir %1 /L /O-N /OE /4 /S /AD /AA /A-R /-C
echo "Do you want to remove doc files?"
CHOICE /C:TN /N /T:N,30 /M "Press Y to remove doc files, or press N keep it save."
if errorlevel 1  remove
if errorlevel 2  donotremove
:remove
cd %1
del /p *.doc
:donotremove
cls
dir %1 /B
dir %1 /B > result.txt
start result.txt
I would be grateful for your help.

Sorry but this is not something I asked for :/ As far i got something like this:
function Get-ScriptDirectory
    $Invocation = (Get-Variable MyInvocation -Scope 1).Value
    Split-Path $Invocation.MyCommand.Path
    $path = Get-ScriptDirectory
Get-ChildItem $path -Recurse -Include *doc, *.docx | Sort-Object Name -Descending | Sort Extension
function GetInfo {
    Write-Host "Press Y and hit enter to remove .docx files or press N and hit enter to keep it save."
    $a = Read-Host
    IF ($a -eq "Y")
     Remove-Item $path\*.docx
     Remove-Item $path\*.doc
     Write-Host "Removed"
     cls
    ELSEIF ($a -eq "N")
     Write-Host "Not removed"
     cls
    ELSE
    Write-Host "Wrong button"
    GetInfo
GetInfo
Get-Childitem $path | Out-File $path\Result.txt
but I don't really know how to make it show directions, archive files and *.doc at once :/ + how to use lowercase on that list.
in order to demonstate you issue
You are asking for us to design a whoe solution for you by asking a shopping list of quesiions.  That is not the purpose of this forum.  Please ask a single quesition and provide a simple example to illustrate your issue.
By simplifying your issues you will aslo find it will make understanding your problem much easier.
¯\_(ツ)_/¯

Similar Messages

  • ALV output converted into PDF format and send that PDF to user through mail

    Hi Experts,
    I have report earlier its output was in alv grid.
    Now i want that ALV output converted into PDF format.And that PDF output send to user through mail.
    Can u please tell how to do?
    My code is here(output is displaying in ALV grid).
    INCLUDE <icon>.
    TYPE-POOLS: slis, kkblo.
    TABLES : zmsd_freight_hdr, zmsd_freight_det, zmsd_blinfo, zmsd_diheader.
    TABLES : lfa1.
    DATA : t_hdr   LIKE   zmsd_freight_hdr   OCCURS 0 WITH HEADER LINE,
           T_DET   LIKE   ZMSD_FREIGHT_DET   OCCURS 0 WITH HEADER LINE,
           t_bl    LIKE   zmsd_blinfo        OCCURS 0 WITH HEADER LINE,
           t_di    LIKE   zmsd_diheader      OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF t_det OCCURS 0.
            INCLUDE STRUCTURE zmsd_freight_det.
    DATA    type(30).
    DATA: END OF t_det.
    DATA: v_target2(30),
          v_zsammg LIKE t_det-zsammg,
          v_gsttotal LIKE t_det-zamount.
    DATA : BEGIN OF t_data OCCURS 0,
             zsammg       LIKE  zmsd_freight_hdr-zsammg,
             zdidbl       LIKE  zmsd_freight_hdr-zdidbl,
             zvkorg       LIKE  zmsd_freight_hdr-zvkorg,
             zinvno       LIKE  zmsd_freight_hdr-zinvno,
             zttlamt      LIKE  zmsd_freight_hdr-zttlamt,
             zstatus      LIKE  zmsd_freight_hdr-zstatus,
             ztype        LIKE  zmsd_freight_hdr-ztype,
             zconfirm     LIKE  zmsd_freight_hdr-zconfirm,
             zconfirmdate LIKE  zmsd_freight_hdr-zconfirmdate,
             erdat        LIKE  zmsd_freight_hdr-erdat,
             ernam        LIKE  zmsd_freight_hdr-ernam,
             erzet        LIKE  zmsd_freight_hdr-erzet,
             aedat(10),
             aenam        LIKE  zmsd_freight_hdr-aenam,
             aezet        LIKE  zmsd_freight_hdr-aezet,
             zline        LIKE  zmsd_freight_det-zline,
             zfptype      LIKE  zmsd_freight_det-zfptype,
             zchrcode     LIKE  zmsd_freight_det-zchrcode,
             zcurcode     LIKE  zmsd_freight_det-zcurcode,
             zqty         LIKE  zmsd_freight_det-zqty,
             zuom         LIKE  zmsd_freight_det-zuom,
             zrate        LIKE  zmsd_freight_det-zrate,
             zamount      LIKE  zmsd_freight_det-zamount,
             zexrate      LIKE  zmsd_freight_det-zexrate,
           zccode       LIKE  zmsd_blinfo-zccode,      "MADK991565
             zccode       like  ZMSD_FREIGHT_HDR-zfcode, "MADK991565
             zbldate(10),
             zbl          LIKE  zmsd_blinfo-zbl,
             type(3),
             waerk        LIKE  zmsd_freight_det-zcurcode,
             zamountl     LIKE  zmsd_freight_det-zamount,
           END OF t_data.
    DATA : w_layout      TYPE   slis_layout_alv,
           w_catalog     TYPE   slis_fieldcat_alv,
           t_catalog     TYPE   slis_t_fieldcat_alv,
           w_sort        TYPE   slis_sortinfo_alv,
           t_sort        TYPE   slis_t_sortinfo_alv.
    DATA   V_ZINVNO    like   T_HDR-ZINVNO.                   "MADK991565
    DATA : v_count  TYPE  i.
    SELECTION-SCREEN BEGIN OF BLOCK a0 WITH FRAME TITLE text-001.
    PARAMETERS     :  p_zvkorg LIKE zmsd_freight_hdr-zvkorg  OBLIGATORY .
    SELECT-OPTIONS :  s_zdidbl FOR  zmsd_freight_hdr-zdidbl             ,
                      s_zccode FOR  lfa1-lifnr                          ,
                      s_status FOR  zmsd_freight_hdr-zstatus            ,
                      s_ztype  FOR  zmsd_freight_hdr-ztype              ,
                      s_erdat  FOR  zmsd_freight_hdr-erdat              ,
                      s_ernam  FOR  zmsd_freight_hdr-ernam              ,
                      s_zconfd FOR  zmsd_freight_hdr-zconfirmdate       .
    PARAMETERS     :  p_zconf  AS   CHECKBOX                            .
    SELECTION-SCREEN END OF BLOCK a0.
    SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-002.
    PARAMETERS     :  p_hdr    RADIOBUTTON GROUP rad DEFAULT 'X'        ,
                      p_det    RADIOBUTTON GROUP rad                    .
    SELECTION-SCREEN END OF BLOCK a1.
    INITIALIZATION.
    AT SELECTION-SCREEN.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM process.
      PERFORM display.
    END-OF-SELECTION.
      PERFORM fm_get_num_pages.
    AT USER-COMMAND.
    AT LINE-SELECTION.
    TOP-OF-PAGE.
      PERFORM fm_top_of_page USING '7010' sy-title space.
    FORM get_data.
      SELECT   *
        FROM   zmsd_freight_hdr
        INTO   TABLE t_hdr
       WHERE   zvkorg        EQ  p_zvkorg
         AND   zdidbl        IN  s_zdidbl
         AND   zstatus       IN  s_status
         AND   ztype         IN  s_ztype
         AND   erdat         IN  s_erdat
         AND   ernam         IN  s_ernam
         AND   zconfirmdate  IN  s_zconfd
         AND   ZFCODE        IN  S_ZCCODE.                      "MADK991565
      IF p_zconf = 'X'.
        DELETE t_hdr WHERE zconfirm NE 'C'.
      ENDIF.
      CHECK NOT t_hdr[] IS INITIAL.
      SELECT   *
        FROM   zmsd_blinfo
        INTO   TABLE t_bl
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg = t_hdr-zsammg.
      SORT t_bl BY zsammg.
      SELECT   *
        FROM   zmsd_diheader
        INTO   TABLE t_di
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg = t_hdr-zsammg.
      SORT t_di BY zsammg.
    IF P_DET = 'X'. "MADK933361
      SELECT   *
        FROM   zmsd_freight_det
        INTO   TABLE t_det
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg  =  t_hdr-zsammg
       AND ZINVNO =  T_HDR-ZINVNO .                           "MADK991565
    SORT t_det BY zsammg zline.                            "MADK991565
       SORT T_DET BY ZSAMMG ZINVNO ZLINE.                     "MADK991565
    ENDIF. "MADK933361
    ENDFORM.
    FORM process.
      REFRESH t_data.
      CLEAR v_gsttotal.                                         "MADK933361
      LOOP AT t_hdr.
    Start of MADK933361
        CLEAR: v_target2.
        v_zsammg = t_hdr-zsammg.
        V_ZINVNO = T_HDR-ZINVNO.                                "MADK991565
       AT NEW zsammg.                                         "MADK991565
         AT NEW ZINVNO.                                         "MADK991565
          PERFORM get_gst_value.
        ENDAT.
    End of MADK933361
        PERFORM move_header.
        CHECK t_data-zccode IN s_zccode.
        IF p_det = 'X'.
    CSF Project Changes Starts   DEV34    MADK985782
        LOOP AT T_DET WHERE ZSAMMG = T_HDR-ZSAMMG..
          LOOP AT t_det WHERE zsammg = t_hdr-zsammg AND
                              zinvno = t_hdr-zinvno.
    CSF Project Changes Ends     DEV34    MADK985782
            PERFORM move_header.
            CHECK t_data-zccode IN s_zccode.
            MOVE-CORRESPONDING t_det TO t_data.
            t_data-zamountl = t_data-zamount * t_data-zexrate.
            APPEND t_data.
            CLEAR t_data.
          ENDLOOP.
        ELSE.
          APPEND t_data.
          CLEAR t_data.
        ENDIF.
        AT END OF zsammg.
          CLEAR v_gsttotal.
        ENDAT.
    *Start of changes for  IS090901289-PIA MADK991565
        AT END OF ZINVNO.
          CLEAR V_GSTTOTAL.
        ENDAT.
    *End of changes for  IS090901289-PIA MADK991565
      ENDLOOP.
    ENDFORM.
    FORM move_header.
      MOVE-CORRESPONDING t_hdr TO t_data.
      t_data-zttlamt = t_data-zttlamt + v_gsttotal.             "MADK933361
      t_data-waerk = 'SGD'.
      IF NOT t_hdr-aedat IS INITIAL.
        WRITE: t_hdr-aedat TO t_data-aedat.
      ELSE.
        CLEAR : t_data-aedat.
      ENDIF.
      READ TABLE t_bl WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
      IF sy-subrc EQ 0.
      t_data-zccode  = t_bl-zccode.   "MADK991565
        T_DATA-ZCCODE = T_HDR-ZFCODE.   "MADK991565     
        IF NOT t_bl-zbldate IS INITIAL.
          WRITE: t_bl-zbldate TO t_data-zbldate.
        ENDIF.
        t_data-zbl     = t_bl-zbl.
        t_data-type    = 'DBL'.
      ELSE.
        READ TABLE t_di WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
        IF sy-subrc EQ 0.
        t_data-zccode  = t_di-zdiforcode.     "MADK991565
          T_DATA-ZCCODE = T_HDR-ZFCODE.         "MADK991565
          t_data-type    = 'DI'.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM display.
      IF t_data[] IS INITIAL.
        MESSAGE s398(00) WITH 'No Data Selected'.
        EXIT.
      ENDIF.
      DATA : l_repid LIKE sy-repid.
      l_repid = sy-repid.
      REFRESH t_catalog.
      CLEAR   t_catalog.
      w_layout-cell_merge = 'X'.
      PERFORM map_fields.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = l_repid
                i_callback_user_command = 'ALV_USER_COMMAND'
                is_layout               = w_layout
                it_fieldcat             = t_catalog[]
                i_grid_title            = sy-title
                i_save                  = 'A'
                it_sort                 = t_sort[]
           TABLES
                t_outtab                = t_data
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.
    FORM map_fields.
    Sort Order
      CLEAR v_count.
      PERFORM sf USING 'ZDIDBL'   'X'  'X'.
    Fields to be displayed
      CLEAR v_count.
      IF p_hdr = 'X'.
        PERFORM af USING :
       DESCRIPTION       FIELD        LEN   RTABLE             RFIELD
        'DI/DBL         ' 'ZDIDBL'     '14' '                ' '        ',
        'Type           ' 'TYPE'       '04' '                ' '        ',
        'Forwarder Code ' 'ZCCODE'     '14' '                ' '        ',
        'BL Number      ' 'ZBL'        '14' '                ' '        ',
        'BL Date        ' 'ZBLDATE'    '10' '                ' '        ',
        'Invoice Number ' 'ZINVNO'     '15' '                ' '        ',
        'Extraction     ' 'ZSTATUS'    '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
        'Freight Type   ' 'ZTYPE'      '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE   ',
        'Confirmation   ' 'ZCONFIRM'   '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
        'Confirm Date   ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
    'ZCONFIRMDATE',
        'Total Amount   ' 'ZTTLAMT'    '18' '                ' '        ',
        'Created On     ' 'ERDAT'      '10' '                ' '        ',
        'Created By     ' 'ERNAM'      '10' '                ' '        ',
        'Changed On     ' 'AEDAT'      '10' '                ' '        ',
        'Changed By     ' 'AENAM'      '10' '                ' '        '.
      ELSE.
        PERFORM af USING :
       DESCRIPTION         FIELD     LEN   RTABLE             RFIELD
        'DI/DBL           ' 'ZDIDBL'   '14' '                ' '        ',
        'Type             ' 'TYPE'     '04' '                ' '        ',
        'Forwarder Code   ' 'ZCCODE'   '14' '                ' '        ',
        'BL Number        ' 'ZBL'      '14' '                ' '        ',
        'BL Date          ' 'ZBLDATE'  '10' '                ' '        ',
        'Invoice Number   ' 'ZINVNO'   '15' '                ' '        ',
        'Extraction       ' 'ZSTATUS'  '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
        'Freight Type     ' 'ZTYPE'    '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE   ',
        'Confirmation     ' 'ZCONFIRM' '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
        'Confirm Date     ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
    'ZCONFIRMDATE',
        'Total Amount     ' 'ZTTLAMT'  '18' '                ' '        ',
        'Freight Payment  ' 'ZFPTYPE'  '14' '                ' '        ',
        'Charge Code      ' 'ZCHRCODE' '10' '                ' '        ',
        'Currency         ' 'ZCURCODE' '08' '                ' '        ',
        'Quantity         ' 'ZQTY'     '13' '                ' '        ',
        'UoM              ' 'ZUOM'     '04' '                ' '        ',
        'Rate             ' 'ZRATE'    '15' '                ' '        ',
        'Amt(Foreign Curr)' 'ZAMOUNT'  '16' '                ' '        ',
        'Exchange Rate    ' 'ZEXRATE'  '13' '                ' '        ',
        'Amt(Local Curr)  ' 'ZAMOUNTL' '16' '                ' '        ',
        'Created On       ' 'ERDAT'    '10' '                ' '        ',
        'Created By       ' 'ERNAM'    '10' '                ' '        ',
        'Changed On       ' 'AEDAT'    '10' '                ' '        ',
        'Changed By       ' 'AENAM'    '10' '                ' '        '.
      ENDIF.
    ENDFORM.
    FORM af USING text
                  field
                  len
                  table
                  reffield.
      v_count = v_count + 1.
      w_catalog-col_pos       = v_count.
      w_catalog-fieldname     = field.
      w_catalog-ref_tabname   = table.
      w_catalog-ref_fieldname = reffield.
      w_catalog-seltext_s     = text.
      w_catalog-seltext_m     = text.
      w_catalog-seltext_l     = text.
      w_catalog-outputlen     = len.
      IF field = 'ZTTLAMT' OR field = 'ZAMOUNTL'.
        w_catalog-no_zero     = 'X'.
        w_catalog-cfieldname  = 'WAERK'.
        w_catalog-datatype    = 'CURR'.
      ENDIF.
    IF FIELD = 'ZRATE' OR FIELD = 'ZAMOUNT'.
      IF field = 'ZAMOUNT'.
        w_catalog-no_zero     = 'X'.
        w_catalog-cfieldname  = 'ZCURCODE'.
        w_catalog-datatype    = 'CURR'.
      ENDIF.
      IF field = 'ZQTY' OR field = 'ZRATE'.
        w_catalog-no_zero     = 'X'.
        w_catalog-datatype  =  'DEC'.
      ENDIF.
      APPEND w_catalog TO t_catalog.
      CLEAR  w_catalog.
    ENDFORM.
    FORM sf    USING   fieldname  sortup  group.
      v_count = v_count + 1.
      CLEAR w_sort.
      w_sort-fieldname = fieldname.
      w_sort-spos      = v_count.
      w_sort-up        = sortup.
      w_sort-group     = group.
      APPEND w_sort TO t_sort.
    ENDFORM.
    FORM alv_user_command USING  in_ucomm    LIKE sy-ucomm
                                 in_selfield TYPE slis_selfield.
      DATA: lfs_data LIKE t_data.
      IF in_ucomm = '&IC1'.
        READ TABLE t_data INDEX in_selfield-tabindex INTO lfs_data.
        CHECK NOT lfs_data-zdidbl IS INITIAL.
        IF lfs_data-type = 'DBL'.
          DATA: l_zdbl LIKE zmsd_diheader-zdinum.
          l_zdbl = in_selfield-value.
          EXPORT l_zdbl TO MEMORY ID 'VBL'.
          CALL TRANSACTION 'ZMSD_BL01'.
        ENDIF.
        IF lfs_data-type = 'DI'.
          DATA: v_dinum LIKE zmsd_diheader-zdinum.
          v_dinum = in_selfield-value.
          EXPORT v_dinum TO MEMORY ID 'VDI'.
          CALL TRANSACTION 'ZMSD_DI01'.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM get_gst_value.
      LOOP AT t_det WHERE zsammg = v_zsammg
         AND ZINVNO = V_ZINVNO.                              "MADK991565
        CHECK t_data-zccode IN s_zccode.
        t_det-zamount  = t_det-zamount * t_det-zexrate.
        SELECT SINGLE  y0mmtarget2
                INTO   v_target2
                FROM   y0mmipstranslate
                WHERE  y0mmdatatype = '70' AND
                       y0mmsource = t_det-zchrcode.
        SELECT SINGLE y0mmtarget1
               INTO   t_det-type
               FROM   y0mmipstranslate
               WHERE  y0mmdatatype = '76' AND
                      y0mmsource = v_target2.
        IF t_det-type NE '3Z'.
          v_gsttotal    = v_gsttotal +
                               ( t_det-zamount * 5 / 100 ).
        ENDIF.
      ENDLOOP.
    Regards,
    Raj.

    Hello,
    Following is the procedure to convert alv output to spool and then it to PDF Format.
    After we display the ALV, we can check whether it is running in the background using system field u2018sy-batchu2018. Then,we call an function module named u2018GET_JOB_RUNTIME_INFOu2019 to get the current job information. Then go to spool request table tbtcp to get the spool id.
    Get current job details
      CALL FUNCTION u2018GET_JOB_RUNTIME_INFOu2019
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                               AND jobcount = gd_jobcount
                               AND stepcount = gd_stepcount
                               AND listident <> u20180000000000u2032
                               ORDER BY   jobname
                                                   jobcount
                                                   stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
    Finally, we can call function module u2018CONVERT_ABAPSPOOLJOB_2_PDFu2018 to convert spool reqeust(which is stored in OTF format) to PDF format. Then we can call either function module u2018SO_DOCUMENT_SEND_API1u2032 or SAP BCS (Business Communication Service) to send the pdf as an email attachment.
    CALL FUNCTION u2018CONVERT_ABAPSPOOLJOB_2_PDFu2019
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount = gd_bytecount
           TABLES
                pdf = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
    Regards,
    Sayali
    Edited by: Sayali Paradkar on Apr 20, 2010 12:51 PM

  • [Forum FAQ] How to format and combine PowerShell outputs

    Format the output with “Format-Table” and “Format-list”
    Sometimes when we query Powershell cmdlet, we would get ellipses in the result, which is not desirable.
    In this scenario, we can use the cmdlet “Format-Table” and “Format-list” to view the entire output:
    Get-Service | where{$_.name -like "BrokerInfrastr*"}
    Get-Service | where{$_.name -like "BrokerInfrastr*"}|Format-Table –AutoSize
    Get-Service | where{$_.name -like "BrokerInfrastr*"}|Format-list
    Figure 1:  format powershell output
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thanks, this has been helpful. I have been trying to figure out how the PSObjects work.
    I created a function that takes an object and creates a function to create PSObjects
    Function Get-ObjectPropertiesFunction
    [CmdletBinding()]
    [OutputType([string])]
    param
    [Parameter(Mandatory=$true,
    ValueFromPipeline=$false,
    ValueFromPipelineByPropertyName=$false,
    ValueFromRemainingArguments=$false,
    Position=0,
    ParameterSetName='Object')]
    [ValidateNotNull()]
    [ValidateNotNullOrEmpty()]
    [Object]$Object
    Begin
    $Members=Get-Member -InputObject $Object
    $ValidPropertyType = @{"{get;set;}"=$True;"{get;}"=$True;}
    $ValidReturnType = @{"bool"=$True;"byte"=$True;"string"=$True;"string[]"=$True;
    "int"=$True;"int16"=$True;"int32"=$True;"int64"=$True;
    "uint"=$True;"uint16"=$True;"uint32"=$True;"uint64"=$True;
    [string]$String=""
    $String=$String+"Function Get-PSObjectPropertiesFromObject `n"
    $String=$String+"{ `n"
    $String=$String+" [CmdletBinding()] `n"
    $String=$String+" [OutputType([PSObject[]])] `n"
    $String=$String+" param `n"
    $String=$String+" ( `n"
    $String=$String+" [Parameter(Mandatory="+"$"+"true, `n"
    $String=$String+" ValueFromPipeline="+"$"+"false, `n"
    $String=$String+" ValueFromPipelineByPropertyName="+"$"+"false, `n"
    $String=$String+" ValueFromRemainingArguments="+"$"+"false, `n"
    $String=$String+" Position=0, `n"
    $String=$String+" ParameterSetName='Object')] `n"
    $String=$String+" [ValidateNotNull()] `n"
    $String=$String+" [ValidateNotNullOrEmpty()] `n"
    $String=$String+" [Object]"+"$"+"Object `n"
    $String=$String+" ) `n"
    $String=$String+" Begin `n"
    $String=$String+" { `n"
    $String=$String+" $"+"Output = New-Object PSObject -Property ([Ordered]@{ `n"
    ForEach ($Member in $Members)
    IF ($Member.MemberType -EQ "Property")
    [string]$Name=$Member.Name
    IF ($Name.Substring(1,1) -NE "_")
    [String[]]$Definition=$Member.Definition.Split(" ")
    [string]$PropertyType=$Definition[2]
    IF ($ValidPropertyType[$PropertyType])
    $ReturnType=$Definition[0]
    if ($ValidReturnType[$ReturnType])
    $String=$String+" $Name="+"$"+"Object.$Name `n"
    $String=$String+" }) `n"
    $String=$String+" $"+"Output `n"
    $String=$String+" } `n"
    $String=$String+"} `n"
    $String
    Here is the output from the above function for the WIN32_BootConfiguration class (Small Class)
    $Class="Win32_BootConfiguration"
    $Function=Get-ObjectPropertiesFunction (Get-WMIObject -Class $Class)
    PS C:\>> $Function
    Function Get-PSObjectPropertiesFromObject
    [CmdletBinding()]
    [OutputType([PSObject[]])]
    param
    [Parameter(Mandatory=$true,
    ValueFromPipeline=$false,
    ValueFromPipelineByPropertyName=$false,
    ValueFromRemainingArguments=$false,
    Position=0,
    ParameterSetName='Object')]
    [ValidateNotNull()]
    [ValidateNotNullOrEmpty()]
    [Object]$Object
    Begin
    $Output = New-Object PSObject -Property ([Ordered]@{
    BootDirectory=$Object.BootDirectory
    Caption=$Object.Caption
    ConfigurationPath=$Object.ConfigurationPath
    Description=$Object.Description
    LastDrive=$Object.LastDrive
    Name=$Object.Name
    ScratchDirectory=$Object.ScratchDirectory
    SettingID=$Object.SettingID
    TempDirectory=$Object.TempDirectory
    $Output
    PS C:\>>
    The function also works for other and more interesting classes like SQL Server.
    PS C:\>>
    $srv = New-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
    $db = New-Object Microsoft.SqlServer.Management.Smo.Database($srv, "AdventureWorks2012")
    $Function=Get-ObjectPropertiesFunction $db
    $Function
    Function Get-PSObjectPropertiesFromObject
    [CmdletBinding()]
    [OutputType([PSObject[]])]
    param
    [Parameter(Mandatory=$true,
    ValueFromPipeline=$false,
    ValueFromPipelineByPropertyName=$false,
    ValueFromRemainingArguments=$false,
    Position=0,
    ParameterSetName='Object')]
    [ValidateNotNull()]
    [ValidateNotNullOrEmpty()]
    [Object]$Object
    Begin
    $Output = New-Object PSObject -Property ([Ordered]@{
    ActiveConnections=$Object.ActiveConnections
    AnsiNullDefault=$Object.AnsiNullDefault
    AnsiNullsEnabled=$Object.AnsiNullsEnabled
    AnsiPaddingEnabled=$Object.AnsiPaddingEnabled
    AnsiWarningsEnabled=$Object.AnsiWarningsEnabled
    ArithmeticAbortEnabled=$Object.ArithmeticAbortEnabled
    AutoClose=$Object.AutoClose
    AutoCreateStatisticsEnabled=$Object.AutoCreateStatisticsEnabled
    AutoShrink=$Object.AutoShrink
    AutoUpdateStatisticsAsync=$Object.AutoUpdateStatisticsAsync
    AutoUpdateStatisticsEnabled=$Object.AutoUpdateStatisticsEnabled
    AvailabilityGroupName=$Object.AvailabilityGroupName
    BrokerEnabled=$Object.BrokerEnabled
    CaseSensitive=$Object.CaseSensitive
    ChangeTrackingAutoCleanUp=$Object.ChangeTrackingAutoCleanUp
    ChangeTrackingEnabled=$Object.ChangeTrackingEnabled
    ChangeTrackingRetentionPeriod=$Object.ChangeTrackingRetentionPeriod
    CloseCursorsOnCommitEnabled=$Object.CloseCursorsOnCommitEnabled
    Collation=$Object.Collation
    ConcatenateNullYieldsNull=$Object.ConcatenateNullYieldsNull
    DatabaseOwnershipChaining=$Object.DatabaseOwnershipChaining
    DatabaseSnapshotBaseName=$Object.DatabaseSnapshotBaseName
    DateCorrelationOptimization=$Object.DateCorrelationOptimization
    DboLogin=$Object.DboLogin
    DefaultFileGroup=$Object.DefaultFileGroup
    DefaultFileStreamFileGroup=$Object.DefaultFileStreamFileGroup
    DefaultFullTextCatalog=$Object.DefaultFullTextCatalog
    DefaultSchema=$Object.DefaultSchema
    EncryptionEnabled=$Object.EncryptionEnabled
    FilestreamDirectoryName=$Object.FilestreamDirectoryName
    HonorBrokerPriority=$Object.HonorBrokerPriority
    ID=$Object.ID
    IsAccessible=$Object.IsAccessible
    IsDatabaseSnapshot=$Object.IsDatabaseSnapshot
    IsDatabaseSnapshotBase=$Object.IsDatabaseSnapshotBase
    IsDbAccessAdmin=$Object.IsDbAccessAdmin
    IsDbBackupOperator=$Object.IsDbBackupOperator
    IsDbDatareader=$Object.IsDbDatareader
    IsDbDatawriter=$Object.IsDbDatawriter
    IsDbDdlAdmin=$Object.IsDbDdlAdmin
    IsDbDenyDatareader=$Object.IsDbDenyDatareader
    IsDbDenyDatawriter=$Object.IsDbDenyDatawriter
    IsDbManager=$Object.IsDbManager
    IsDbOwner=$Object.IsDbOwner
    IsDbSecurityAdmin=$Object.IsDbSecurityAdmin
    IsDesignMode=$Object.IsDesignMode
    IsFederationMember=$Object.IsFederationMember
    IsFullTextEnabled=$Object.IsFullTextEnabled
    IsLoginManager=$Object.IsLoginManager
    IsMailHost=$Object.IsMailHost
    IsManagementDataWarehouse=$Object.IsManagementDataWarehouse
    IsMirroringEnabled=$Object.IsMirroringEnabled
    IsParameterizationForced=$Object.IsParameterizationForced
    IsReadCommittedSnapshotOn=$Object.IsReadCommittedSnapshotOn
    IsSystemObject=$Object.IsSystemObject
    IsUpdateable=$Object.IsUpdateable
    IsVarDecimalStorageFormatEnabled=$Object.IsVarDecimalStorageFormatEnabled
    LocalCursorsDefault=$Object.LocalCursorsDefault
    MirroringPartner=$Object.MirroringPartner
    MirroringPartnerInstance=$Object.MirroringPartnerInstance
    MirroringRedoQueueMaxSize=$Object.MirroringRedoQueueMaxSize
    MirroringRoleSequence=$Object.MirroringRoleSequence
    MirroringSafetySequence=$Object.MirroringSafetySequence
    MirroringTimeout=$Object.MirroringTimeout
    MirroringWitness=$Object.MirroringWitness
    Name=$Object.Name
    NestedTriggersEnabled=$Object.NestedTriggersEnabled
    NumericRoundAbortEnabled=$Object.NumericRoundAbortEnabled
    Owner=$Object.Owner
    PrimaryFilePath=$Object.PrimaryFilePath
    QuotedIdentifiersEnabled=$Object.QuotedIdentifiersEnabled
    ReadOnly=$Object.ReadOnly
    RecursiveTriggersEnabled=$Object.RecursiveTriggersEnabled
    TargetRecoveryTime=$Object.TargetRecoveryTime
    TransformNoiseWords=$Object.TransformNoiseWords
    Trustworthy=$Object.Trustworthy
    TwoDigitYearCutoff=$Object.TwoDigitYearCutoff
    UserName=$Object.UserName
    Version=$Object.Version
    $Output
    PS C:\>>

  • Powershell output format

    Hi
    I'm looking for the best way to output data from my powershell.
    Basically im running a ForEach loop and want to print different data
    foreach ($line in $data){
    Eg.
    get-mailbox | select-object identity,emailaddresses
    get-mailbox | format-table identity,emailaddresses
    get-mailbox | format-table identity,emailaddresses -Autosize
    The emailaddresses value is to long to display in my powershell window (eventhoug I have set the Width extremely long)
    The output is displayed as
    {smtp:jel@XXX, SMTP:jel@xxx, SIP:jel@xxx, smtp:Jere_Lain...
    I would like to get the hole string
    cannot get select-object or format-table to Work for me
    Format-table is not good to use in my ForEach loop
    is there any best practise how to output data in the powershell window in a foreach loop ?
    Any input is apreciated.

A: Powershell output format

Hi again
I will try to explain a bit more about what i'm trying to achieve.
I have a list of users
"usr01","usr2",usr3"
For each user I woul like to print to the console (or csv if not possible)
Display Name,WindowsEmailAddress,ExternalEmailAddress,EmailAddresses
User01,[email protected],usr01ext.maildomain.com,STMP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
User02,[email protected],usr02ext.maildomain.com,SMTP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
User03,[email protected],usr03ext.maildomain.com,SMTP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
Maby more or other object attribute i the future
The format above is a wish scenario, I don't have a fixed size on any attribute, they can vary much in length.
also the last part of the UPN can be different.
What is the best way to output the result
When using Array, I seem to get too much info out it adds @{attributename=attribute;attributename=attribute}
I can't get Write-host to output the result even using "`t" because I don´t have a fixed length.
Normally I would use | Select-Object attribute01,attribute02
But this prints the header each time it is run, and when using it in a foreach loop gives me a lot for headers.
should I go for Export-csv instead ?
Or is there a magig powershell comand I don't know about.

Hi again
I will try to explain a bit more about what i'm trying to achieve.
I have a list of users
"usr01","usr2",usr3"
For each user I woul like to print to the console (or csv if not possible)
Display Name,WindowsEmailAddress,ExternalEmailAddress,EmailAddresses
User01,[email protected],usr01ext.maildomain.com,STMP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
User02,[email protected],usr02ext.maildomain.com,SMTP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
User03,[email protected],usr03ext.maildomain.com,SMTP:[email protected];sip:[email protected]:smtp:[email protected];smtp:[email protected]
Maby more or other object attribute i the future
The format above is a wish scenario, I don't have a fixed size on any attribute, they can vary much in length.
also the last part of the UPN can be different.
What is the best way to output the result
When using Array, I seem to get too much info out it adds @{attributename=attribute;attributename=attribute}
I can't get Write-host to output the result even using "`t" because I don´t have a fixed length.
Normally I would use | Select-Object attribute01,attribute02
But this prints the header each time it is run, and when using it in a foreach loop gives me a lot for headers.
should I go for Export-csv instead ?
Or is there a magig powershell comand I don't know about.

  • Powershell Script - Convert Managed Metadata column Value to string

    HI,
    I have written a small PowerShell Script to pull records from a SP List and put them in a csv file. Here is the script:
    $MyWeb = Get-SPWeb "http://dev-apps:8800/applications/PA"
    $MyList = $MyWeb.Lists["Alist"]
    $exportlist = @()
    $Mylist.Items | foreach {
    $obj = New-Object PSObject -Property @{
    “PName” = $_["Port Name"]
    "AName" = $_["Agent Name"]
    "Address 1" = $_["Address 1"]
    "Address 2" = $_["Address 1"]
    "Address 3" = $_["Address 3"]
    "Address 4" = $_["Address 4"]
    $exportlist += $obj
    $exportlist | Export-Csv -path 'C:\Filename.csv'
    The script is running all right, the output file is also created, data is also correct for all columns but 1. This PName is a
    Managed metadata type column and the output values I am getting for this column are like this:
    "ERICA|a6d1e8fd-1f6b-4e09-9830-d21e35950881"
    "CLIVE|24dff17f-a1b5-4abe-ae86-57299e1e098b"
    viz. the ["Actual Value"|"its GUID"] (seems so). I do not want this GUID to be included in the result csv. Is there a way to remove it.
    P.S. Choice column values are being fetched just file.

    Try this (you'll need to add in your other properties)
    $items = New-Object psobject
    $items | Add-Member -MemberType NoteProperty -Name "AName" -value "" ;
    $items | Add-Member -MemberType NoteProperty -Name "PName" -value "" ;
    $items | Add-Member -MemberType NoteProperty -Name "Address1" -value "" ;
    $items | Add-Member -MemberType NoteProperty -Name "Address2" -value "" ;
    $items | Add-Member -MemberType NoteProperty -Name "Address3" -value "";
    $exportlist = @();
    $Mylist.Items | foreach {
    $pname = $_["PName"] -as [Microsoft.SharePoint.Taxonomy.TaxonomyFieldValue];
    $obj = $items | Select-Object *;
    $obj.AName = $_["AName"];
    $obj.PName = $pname.Label;
    $obj.Address1 = $_["Address 1"];
    $obj.Address2 = $_["Address 2"];
    $obj.Address3 = $_["Address 3"];
    $exportlist += $obj
    $exportlist | Export-Csv -path 'C:\AData.csv'
    Regards, Matthew
    MCPD | MCITP
    My Blog
    View
    Matthew Yarlett's profile
    See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here:
    Upload and Crop User Profile Photos

  • - Sapscript output convert to XML -

    Hi Gurus,
    I need to convert sapscript output with values - not template - to an XML File or txt.
    i tried RSTXSCRP program and FB_CONVERT_FORM_TO_XML function module but doesn't help me.
    Please help me with the solution.
    Regards
    Emre.
    Edited by: emre karakurum on May 21, 2010 11:38 AM

    In my opinion, SAPScript form is something quite unstructured - the layout of it can be very complicated and as well containing graphic and so on. XML is, on the other side, something pretty structured. I don't think that you can find something standard for simple conversion SAPScript to XML. SAPScript is simply not like IDOC - it's human readable layout rather than strucutre of data. You will have to write your own print-program which will create your own XML file instead of printing SAPScript form. The logic how to structure the XML file (which tags will be there and which values) will be coded in this print-program.

  • Powershell output results log

    Hi guys.
    I have a question and do not know if you can
    help me.
    I do not know much about Powershell,
    but I created a script that disables,
    moves and changes the description of dismissed
    enterprise users through the registration number
    (POBOX in my case).
    The question is would you like to generate a log
    each time this script was executed,
    stating whether or not the actions were
    performed successfully.
    Tested
    with some examples I found on Technet
    but did not work.
    Does anyone havea hint howcan I includethis functionalityin my script?
    $csvFile = ".\list.csv"
    $disabledUsersOU = "<OU DESTINATION>"
    Import-Csv $csvFile | ForEach {
     $f = $_.POBox;
     Get-ADUser -Filter {POBox -eq $f} | Disable-ADAccount
     Get-ADUser -Filter {POBox -eq $f} | Set-ADUser -Description "Disable User Script v4"
     Get-ADUser -Filter {POBox -eq $f} | Move-ADObject -TargetPath $disabledUsersOU
     $user = Get-ADUser -Filter {POBox -eq $f} -Properties MemberOf
     foreach ($group in ($user | Select-Object -ExpandProperty MemberOf))
      Remove-ADGroupMember -Identity $group -Members $user -Confirm:$false
    Thanks a lot.
    David Soares MCTS:MBS - MCTS - MCITP

    You could try something like this:
    $csvFile = ".\list.csv"
    $disabledUsersOU = "<OU DESTINATION>"
    $Results = Import-Csv $csvFile | ForEach {
    $f = $_.POBox;
    Get-ADUser -Filter {POBox -eq $f} | Disable-ADAccount
    Get-ADUser -Filter {POBox -eq $f} | Set-ADUser -Description "Disable User Script v4"
    Get-ADUser -Filter {POBox -eq $f} | Move-ADObject -TargetPath $disabledUsersOU
    $user = Get-ADUser -Filter {POBox -eq $f} -Properties MemberOf,Description,Enabled
    foreach ($group in ($user | Select-Object -ExpandProperty MemberOf))
    Remove-ADGroupMember -Identity $group -Members $user -Confirm:$false
    $user = Get-ADUser $user -properties MemberOf,POBox,Description
    New-Object PSObject -property @{User=$user.samaccountname;POBox=$user.POBox;Description=$user.Description;MemberOf=(($user | select -expand MemberOf) -join ",");Enabled=$user.Enabled;DN=$user.DistinguishedName}
    $Results | Select User,POBox,Description,MemberOf,Enabled | Export-CSV ".\results.csv" -NoType
    All I really added was to create New-Object for each user and each one gets included in $Results, which gets piped to a csv file.  This way you can see what may or may not have succeeded.  The alternative is to evaluate each of the values and compare
    it to what you expect - if any of them are not what you would expect, then User = fail and instead of the new-object line and having all of the output go to $Results you could do:
    Out-File ".\results.log" -InputObject "$($User.sAMAccountName) = FAIL" -append
    (or PASS, or SUCCESS, or whatever works).  The reason I provided the approach above is that you have a complete picture of the results.
    The select in the last line orders the columns in the CSV, otherwise Powershell chooses the order and it isn't usually what you would like.
    I hope this post has helped!

  • Utl_file output converted from database characterset

    I have a developer that is sending output to a file using utl_file. Here is a snippet of his code:
    fileHand UTL_FILE.file_type;
    buffer VARCHAR2(1000);
    UTL_FILE.put_raw(fileHand, UTL_RAW.cast_to_raw(buffer), TRUE);
    In the database there is data such as:
    Stéphanie Chéry
    but in the output file it is written as:
    Stéphanie Chéry
    basically it is being converted to WE characterset.
    This is RDBMS 11.2.0.2 64bit running on RHE 5. The linux user account executing the proc that generates the output file has NLS_LANG=AMERICAN_AMERICA.AL32UTF8 in it's environment. We don't understand why the characterset is being converted. he has tried using the NCHAR functions of UTL_FILE and still gets the same results.
    Any idea what our issue is?
    Below is SELECT * FROM NLS_DATABASE_PARAMETERS from the database
    "PARAMETER","VALUE"
    "NLS_LANGUAGE","AMERICAN"
    "NLS_TERRITORY","AMERICA"
    "NLS_CURRENCY","$"
    "NLS_ISO_CURRENCY","AMERICA"
    "NLS_NUMERIC_CHARACTERS",".,"
    "NLS_CHARACTERSET","AL32UTF8"
    "NLS_CALENDAR","GREGORIAN"
    "NLS_DATE_FORMAT","DD-MON-RR"
    "NLS_DATE_LANGUAGE","AMERICAN"
    "NLS_SORT","BINARY"
    "NLS_TIME_FORMAT","HH.MI.SSXFF AM"
    "NLS_TIMESTAMP_FORMAT","DD-MON-RR HH.MI.SSXFF AM"
    "NLS_TIME_TZ_FORMAT","HH.MI.SSXFF AM TZR"
    "NLS_TIMESTAMP_TZ_FORMAT","DD-MON-RR HH.MI.SSXFF AM TZR"
    "NLS_DUAL_CURRENCY","$"
    "NLS_NCHAR_CHARACTERSET","AL16UTF16"
    "NLS_COMP","BINARY"
    "NLS_LENGTH_SEMANTICS","CHAR"
    "NLS_NCHAR_CONV_EXCP","FALSE"
    "NLS_RDBMS_VERSION","11.2.0.2.0"

    1076:jobsub@elver:/home/jobsub> env
    _=*8512*/bin/env
    CLASSPATH=
    COBDIR=/opt/FJSVcbl64
    COBPATH=/home/jobsub:/app/sct/banner_du/links:/app/sct/banner_du/general/exe
    COBPREF=perl /app/sct/banner_du/links/banfjsv.pl
    COBSUFX=
    DATAFILE_HOME=
    DATA_HOME=/app/sct/dataload/DUSIMS
    DISPLAY=localhost:10.0
    G_BROKEN_FILENAMES=1
    HISTSIZE=1000
    HOME=/home/jobsub
    INPUTRC=/etc/inputrc
    LANG=en_US.UTF-8
    LC_ALL=en_US.UTF-8
    LC_COLLATE=en_US.UTF-8
    LC_CTYPE=en_US.UTF-8
    LC_MESSAGES=en_US.UTF-8
    LC_MONETARY=en_US.UTF-8
    LC_NUMERIC=en_US.UTF-8
    LC_TIME=en_US.UTF-8
    LD_LIBRARY_PATH=/app/oracle11/product/11.2/lib:/app/oracle11/product/11.2/lib32:/opt/FJSVcbl64/lib:/opt/FJSVXbsrt/lib:/opt/FJSVXmeft/lib:/app/sct/banner_du/general/exe:/usr/local/lib
    LESSOPEN=|/usr/bin/lesspipe.sh %s
    LOGNAME=jobsub
    LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=01;32:*.cmd=01;32:*.exe=01;32:*.com=01;32:*.btm=01;32:*.bat=01;32:*.sh=01;32:*.csh=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tz=01;31:*.rpm=01;31:*.cpio=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.png=01;35:*.tif=01;35:
    MAIL=/var/spool/mail/jobsub
    NLS_LANG=AMERICAN_AMERICA.AL32UTF8
    ORACLE_HOME=/app/oracle11/product/11.2
    ORACLE_LPARGS=-Plp
    ORACLE_LPPROG=lpr
    ORACLE_PATH=.:/home/jobsub:/app/sct/banner_du/links:/app/sct/banner_du/admin
    ORACLE_SID=DUSIMS
    ORA_NLS10=/app/oracle11/product/11.2/nls/data
    ORA_NLS11=/app/oracle11/product/11.2/nls/data
    ORA_NLS33=/app/oracle11/product/11.2/ocommon/nls/admin/data
    PATH=:/app/sct/banner_du/fixes_DUSIMS:/opt/FJSVcbl64/bin:/opt/FJSVXbsrt/lib:/opt/FJSVXmeft/lib::/app/sct/banner_du/general/exe:/app/sct/banner_du/admin:.:/app/sct/jobsub:/app/sct/dlp:/app/sct/jobsub/scripts:/usr/java/jdk1.6.0_25/bin:/bin:/usr/bin:/usr/local/bin:/usr/openv/netbackup/bin:/opt/sct/bin:/app/oracle11/product/11.2/bin:/app/sct/banner_du/links
    PS1=!:$LOGNAME@$HOSTNAME:$PWD>
    PWD=/home/jobsub
    SHELL=/bin/ksh
    SHLVL=1
    SQLPATH=.:/home/jobsub:/app/sct/banner_du/links:/app/sct/banner_du/admin
    SRCE_LINK=
    TERM=vt100
    USER=jobsub
    ASTFEATURES=UNIVERSE - ucb
    A__z="*SHLVL

  • Powershell output as boolean

    Hello Scripting guys
    Please prompt me. How i can get output as true or false, assume from Get-ADUser "j.maxi" or another cmdlet which outputs string, int, array?

    This is very eash in PowerShell.
    if(Get-ADUser "j.maxi" -ea 0){
        'user found'
    }else{
        'user ot found'
    The result of a get is always true or false by design.  the same is tru if you want to save the result.
    If($user=ADUser "j.maxi" -ea 0){
         # process user
    }else{
        'user not found'
    No need for any fancy stuff.  This is builtin.  It is a carryover from standard programming practices.  We do this in C and C# all of the time.  The makers of PowerShell liked it so they used it.
    ¯\_(ツ)_/¯

  • Output convertions to PDF

    Dear Experts, Can any bady let me know
    how to identify the existing outputs whether the PDF convertions logis is incorporated or not.
    we have n number of output types for shipment, in that very fery few is sending through PDF format.... now i want identify those output types.
    can you please share your views on the same soon....
    thanks
    raju

    Hi,
    As you said i searched all the shipment output types and releated programes , no one is having the Convert_otf
    but
    we have CALL FUNCTION 'CONVERT_COMM_TYPE_DATA' in the all programes.
    can you please let me know what exactly this
    thanks
    Raju.

  • Convert spool output of ABAP list into excel and send email

    Hello All,
      I have a requirement where we need to
    1. schedule a background job programtically
    2. moniter backround job (if complete or not)
    3. once its complete take spool output ,convert into excel and email.
    I have following difficulties.
      1. i have reached upto stage 3. However, i am not getting proper ouput of excel via mail. it contains junk characters. I searched SDN and tried various option but not successful.
    2. AT last i have submited report and collected output in memory rather than submiting back ground job. Now excel out put is coming somewhat as required but while sending mail , i am getting limitation of 255 chars . My excel row has more than 255 line size.
    Please suggest.
    Thanks in advance,
    jigs.
    <<text removed>>
    Edited by: Matt on Jul 1, 2009 3:52 PM - removed point offer

    I've edited your post.  Please take the time to read the Rules of Engagement of these forums.  Offering points is not permitted for reasons outline in the Rules of Engagement.
    matt

  • Powershell scripts not writing it to output file

    Hi,
    Below is my script which loops through all sites and web in a site collection and if the particular web part is added in a page, it will give the page URL and it should be written to a output file.
    function enumerateWebParts($Url)
    $webApp = Get-SPWebApplication $Url #Get WebApplication URL
    foreach($web in $webApp | Get-SPSite -Limit All | Get-SPWeb -Limit All) #foreach loop to iterate through all sites and webs of WebApplication
    if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) #Check if site is a publishing site
    $pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
    $pages = $pWeb.PagesList
    foreach ($item in $pages.Items)
    $fileUrl = $webUrl + "/" + $item.File.Url
    $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
    $wps = $manager.webparts
    foreach ($type in $wps) #loop through each type found $wps
    #Write-Host " type searching";
    Write-Host $type.GetType().Name;
    if ($type.GetType().Name -eq "RightMenu") #if webpart $type -like KWizCom select webpart object
    Write-Host "found";
    $wps | select-object @{Expression={$pWeb.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"},DisplayTitle, IsVisible, @{Expression={$type};Label="Type"}
    Write-Host $fileUrl;
    $page=$pweb.Url+$fileUrl;
    Write-Output $page;
    else #if web is not a publishing site
    $pages = $null
    $pages = $web.Lists["Site Pages"]
    if ($pages)
    foreach ($item in $pages.Items)
    $fileUrl = $webUrl + "/" + $item.File.Url
    $manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
    $wps = $manager.webparts
    foreach ($type in $wps)
    if ($type.GetType().Name -eq "RightMenu")
    $wps | select-object @{Expression={$Web.Url};Label="Web URL"},@{Expression={$fileUrl};Label="Page URL"},DisplayTitle, IsVisible, @{Expression={$type};Label="Type"}
    Write-Host $fileUrl;
    $page=$pweb.Url+$fileUrl;
    Write-Output $page;
    else
    # Write-Host “… completed processing” $web
    $row = enumerateWebParts(‘http://sptest.danfoss.net’) #call the enumerateWebParts function pass it the URL for the web application
    I run the command through D:\RightMenu.ps1 | Out-File D:\RightMenu.txt
    Aruna

    Try 
    http://stackoverflow.com/questions/10340007/exporting-powershell-output-to-text-file
    You can always redirect the output an exe to a file like so (even from cmd.exe):
    powershell c:\test.ps1 > c:\test.log
    Within PowerShell, you can also redirect individual commands to file
    but in those cases you probably want to append to the log file rather
    than overwrite it e.g.:
    $logFile = 'c:\temp\test.log'
    "Executing script $($MyInvocation.MyCommand.Path)" > $logFile
    foreach ($proc in Get-Process) {
    $proc.Name >> $logFile
    "Another log message here" >> $logFile
    If this helped you resolve your issue, please mark it Answered

  • Logo not printing properly in Invoice converted to PDF and emailed

    Hello,
    I am having a problem with a programming issue and have searched lots of forums but have found no solutions.  We are on 4.7 and are not likely to upgrade any time soon.  Therefore, I don't think any of the newer solutions are gonna work for me.  I believe that I'm stuck using a couple of function modules to get t he job done.  I am attempting to modify our Invoice Print program (uses SAPscript, not SmartForms) to have the output converted into a PDF file and then attached to an email that is then sent to the customer.  Everything is working fine except for the company logo.  It has been uploaded via SE78.  It is a 24-bit bitmap file.  I have played around with the DPI to have it appear correctly on the form.  I added a FM GUI_DOWNLOAD step to verify that it is saved to my hard drive correctly.  The PDF file saved t o my hard drive appears normally in Adobe Acrobat and Adobe Reader.  So the problem occurs sometime after that.  I have a routine wherein I convert is from 132 to 255 bytes.  I then use FM SO_DOCUMENT_SEND_API1 to send it.  When I swap the customer's email address to my own personal external emal address, the resultant email has an attached PDF file but the company logo is garbage. The top portion of the logo looks good and then at some point in the lower portion is appears as squiggly lines.  This is not acceptable, of course.  I have included the relevent code below:
    DATA: ITAB_OTFDATA   TYPE TABLE OF ITCOO WITH HEADER LINE.
    DATA: ITAB_PDFDATA   TYPE TABLE OF TLINE WITH HEADER LINE.
    DATA: ITAB_DOCTAB_ARCHIVE TYPE STANDARD TABLE OF DOCS.
    DATA: ITAB_OBJPACK   LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE.
    DATA: ITAB_RECORD    LIKE SOLISTI1   OCCURS 0 WITH HEADER LINE.
    DATA: ITAB_OBJTXT    LIKE SOLISTI1   OCCURS 0 WITH HEADER LINE.
    DATA: ITAB_OBJBIN    LIKE SOLISTI1   OCCURS 0 WITH HEADER LINE.
    DATA: ITAB_RECLIST   LIKE SOMLRECI1  OCCURS 0 WITH HEADER LINE.
    DATA: BINFILESIZE    TYPE I,
          G_LINES_TXT    TYPE I,
          G_LINES_BIN    TYPE I,
          DOCDATA        TYPE SODOCCHGI1,
          WA_RESULT      TYPE ITCPP,
          WA_BUFFER      TYPE STRING,
          WA_OBJHEAD     TYPE SOLI_TAB,
          G_INVOICE(10)  TYPE C.
    CLEAR: BINFILESIZE.
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
        EXPORTING
          USE_OTF_MC_CMD               = 'X'
    *     ARCHIVE_INDEX                =
        IMPORTING
          BIN_FILESIZE                 = BINFILESIZE
        TABLES
          OTF                          = ITAB_OTFDATA
          DOCTAB_ARCHIVE               = ITAB_DOCTAB_ARCHIVE
          LINES                        = ITAB_PDFDATA
        EXCEPTIONS
          ERR_CONV_NOT_POSSIBLE        = 1
          ERR_OTF_MC_NOENDMARKER       = 2
          OTHERS                       = 3
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = 'C:\TEMP\TEST.PDF'
          FILETYPE                        = 'BIN'
        tables
          data_tab                        = ITAB_PDFDATA.
      IF sy-subrc <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *-- Convert PDF from 132 to 255
      LOOP AT ITAB_PDFDATA.
    *   Replacing space by ~
        TRANSLATE ITAB_PDFDATA USING ' ~'.
        CONCATENATE WA_BUFFER ITAB_PDFDATA INTO WA_BUFFER.
      ENDLOOP.
    * Replacing ~ by space
      TRANSLATE WA_BUFFER USING '~ '.
      DO.
        ITAB_RECORD = WA_BUFFER.
    *   Appending 155 characters as a record
        APPEND ITAB_RECORD.
        SHIFT WA_BUFFER LEFT BY 255 PLACES.
        IF WA_BUFFER IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
      REFRESH: ITAB_RECLIST,
               ITAB_OBJTXT,
               ITAB_OBJBIN,
               ITAB_OBJPACK.
      CLEAR: WA_OBJHEAD.
      ITAB_OBJBIN[] = ITAB_RECORD[].
      G_INVOICE = VBRK-VBELN.
      SHIFT G_INVOICE LEFT DELETING LEADING '0'.
    *-- Create Message Body Title and Document
      CLEAR: ITAB_OBJTXT-LINE.
      CONCATENATE 'Invoice'
                 G_INVOICE
                  'for Purchase Order'
                  PO_NUM
                  'is attached to this email.'
          INTO ITAB_OBJTXT-LINE SEPARATED BY SPACE.
      APPEND ITAB_OBJTXT.
      CLEAR: ITAB_OBJTXT-LINE.
      APPEND ITAB_OBJTXT.
      CLEAR: ITAB_OBJTXT-LINE.
      CONCATENATE 'Please see attached invoice.'
                  'Thank you for your business!'
          INTO ITAB_OBJTXT-LINE SEPARATED BY SPACE.
      APPEND ITAB_OBJTXT.
      DESCRIBE TABLE ITAB_OBJTXT LINES G_LINES_TXT.
      READ TABLE ITAB_OBJTXT INDEX G_LINES_TXT.
      CONCATENATE 'Invoice' G_INVOICE
          INTO DOCDATA-OBJ_NAME SEPARATED BY SPACE.
      DOCDATA-EXPIRY_DAT = SY-DATUM + 10.
      CONCATENATE 'Invoice for P.O.'
                   PO_NUM
                   VBDKR-NAME1_WE
          INTO DOCDATA-OBJ_DESCR SEPARATED BY SPACE.
      DOCDATA-SENSITIVTY = 'F'.
      DOCDATA-DOC_SIZE = ( G_LINES_TXT - 1 ) * 255 + STRLEN( ITAB_OBJTXT ).
    *-- Main Text
      CLEAR: ITAB_OBJPACK-TRANSF_BIN.
      ITAB_OBJPACK-HEAD_START = 1.
      ITAB_OBJPACK-HEAD_NUM = 0.
      ITAB_OBJPACK-BODY_START = 1.
      ITAB_OBJPACK-BODY_NUM = G_LINES_TXT.
      ITAB_OBJPACK-DOC_TYPE = 'RAW'.
      APPEND ITAB_OBJPACK.
    *-- Attachment (pdf-Attachment)
      ITAB_OBJPACK-TRANSF_BIN = 'X'.
      ITAB_OBJPACK-HEAD_START = 1.
      ITAB_OBJPACK-HEAD_NUM = 0.
      ITAB_OBJPACK-BODY_START = 1.
      DESCRIBE TABLE ITAB_OBJBIN LINES G_LINES_BIN.
      READ TABLE ITAB_OBJBIN INDEX G_LINES_BIN.
      ITAB_OBJPACK-DOC_SIZE = ( G_LINES_BIN - 1 ) * 255 + STRLEN( ITAB_OBJBIN ).
      ITAB_OBJPACK-BODY_NUM = G_LINES_BIN.
      ITAB_OBJPACK-DOC_TYPE = 'PDF'.
      CONCATENATE 'Invoice' G_INVOICE
          INTO ITAB_OBJPACK-OBJ_NAME SEPARATED BY SPACE.
      CONCATENATE G_INVOICE '.pdf'
          INTO ITAB_OBJPACK-OBJ_DESCR.
      APPEND ITAB_OBJPACK.
    *-- Create Table of email recipients
      CLEAR ITAB_RECLIST.
      ITAB_RECLIST-RECEIVER = KNB1-INTAD.
      ITAB_RECLIST-REC_TYPE = 'U'.
      ITAB_RECLIST-COM_TYPE = 'INT'.
      APPEND ITAB_RECLIST.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA                    = DOCDATA
          PUT_IN_OUTBOX                    = ' '
          SENDER_ADDRESS                   = 'arcredit @ companyname.com'  <-- modified to comply with forum rules
          SENDER_ADDRESS_TYPE              = 'SMTP'
          COMMIT_WORK                      = 'X'
    *   IMPORTING
    *     SENT_TO_ALL                      =
    *     NEW_OBJECT_ID                    =
    *     SENDER_ID                        =
        TABLES
          PACKING_LIST                     = ITAB_OBJPACK
          OBJECT_HEADER                    = WA_OBJHEAD
          CONTENTS_BIN                     = ITAB_OBJBIN
          CONTENTS_TXT                     = ITAB_OBJTXT
    *     CONTENTS_HEX                     =
    *     OBJECT_PARA                      =
    *     OBJECT_PARB                      =
          RECEIVERS                        = ITAB_RECLIST
        EXCEPTIONS
          TOO_MANY_RECEIVERS               = 1
          DOCUMENT_NOT_SENT                = 2
          DOCUMENT_TYPE_NOT_EXIST          = 3
          OPERATION_NO_AUTHORIZATION       = 4
          PARAMETER_ERROR                  = 5
          X_ERROR                          = 6
          ENQUEUE_ERROR                    = 7
          OTHERS                           = 8.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *-- Send the email immediately
      WAIT UP TO 3 SECONDS.
      SUBMIT RSCONN01 WITH MODE = 'INT'
                      WITH OUTPUT = 'X'
                      AND RETURN.
    Thanks in advance for any and all advice.
    Best Regards,
    Nik von Ruden
    Edited by: Nik Von Ruden on Nov 3, 2009 6:48 PM
    Edited by: Nik Von Ruden on Nov 3, 2009 6:49 PM

    Hi Friend ,
    I hav gone through your code ...  I have one Question why you are  changing from 132 to 255.inside your program
    if there is a purpose then , please can you change your company logo Image size accordingly  and uploaded it into SAP mime repository using se78.then your program let it convert from 132 to 255. definely you will see some change's in the Logo,then keep on adjusting you can acheive you result.
    sometime the Image size also plays major role ,which we need to modify the sizes of image.
    I am giving you an link which is already there  but still from myside  , just compare the code  .
    Link: [http://www.scribd.com/doc/454814/SAPSCRIPT-to-PDF]
    Regards,

  • How to convert VHDX to VHD file format on windows 8 / Windows server 2012?

    Here is an article to describe how to convert virtual hard disk VHDX file format to VHD 
    http://anuraggawande.blogspot.in/2012/10/vhdx-to-vhd-conversion.html

    Hi,
    Thanks for sharing the web link!
    You help other community members who facing similar problems.
    Thanks for your contribution to Windows Server Forum!
    To convert VHD format, you can also use Convert-VHD comlet. The Convert-VHD cmdlet converts a virtual hard disk file by copying the data from a source virtual hard disk file to a new virtual hard disk file of a specified format and version type. The format
    is determined by the file extension of the specified files, either .vhdx or .vhd. Conversion is an offline operation; the virtual hard disk must not be attached when the operation is started.
    For more information please refer to following MS articles:
    Convert-VHD
    http://technet.microsoft.com/en-us/library/hh848454.aspx
    Windows Server 2012: Convert VHD to VHDX using Hyper-V Manager
    http://blogs.technet.com/b/aviraj/archive/2012/05/06/windows-server-2012-convert-vhd-to-vhdx-using-hyper-v-manager.aspx
    Using PowerShell to Convert a VHD to a VHDX
    http://blogs.msdn.com/b/virtual_pc_guy/archive/2012/10/03/using-powershell-to-convert-a-vhd-to-a-vhdx.aspx
    PS - Convert VHD
    http://gallery.technet.microsoft.com/scriptcenter/1dd3c524-e4e6-44cd-9573-406151237139
    TechNet Subscriber Support
    If you are
    TechNet Subscription user and have any feedback on our support quality, please send your feedback
    here.
    Lawrence
    TechNet Community Support

  • Mpeg output

    Hi,
    I'm looking for a way to export directly from FCP into mpeg format (and I mean original mpeg format). SInce FCP takes output from Quicktime, I guess the question is, is there some sort of plugin or software that would give me this as an option to output/convert video in QT?
    I need this b/c I need to quickly output video for Office 2003/7 Powerpoint for Windows.
    I use Flip4Mac to convert video to wmv in QT/FCP but also need mpeg format.
    Any suggested software?
    Thanks!

    As you are using flip4Mac just continue ti use WMV files for Powerpoint
    There is no reason to use MPEG if you can supply WMV
    The quality of WMV is far superior and there are no compatability issues.

  • Maybe you are looking for

    • 8600 pro printer and windows 8.1 can't scan and more

       8600 pro wireless connection to HP all in one desktop computer. HP software installed on computer with 8. Only used printer function until today. Tried to scan from printer to computer. Desktop did not show up on printer display. Discovered on compu

    • Charm in implementation project

      Hi All, Iam currently configuring charm in implementation project. We do not have QA and PRD systems build yet. I have created transport routes DEV>VQA>VPR ie with QA and PRD as virtual systems. Now how do I add this as virtual systems in logical com

    • How to insert a file in a table field

      hi there i want to insert file into table field i am using plain JSP and oracle 9i is my backend what i would required to do the file may be of any format most probably PDF,WORD, or an Image which datatype is preferable for field regards sweety

    • MacBook Pro freezes for awhile then resumes

      I am running on a MacBook Pro 2.4GHz Inter Core 2 Duo with 4GB 1067 MHz DDR3 memory, and my OS version is 10.8.2. The MBP always will stop responding for half a minute and this occurs very frequently. When that happens, the rainbow wheel will appear.

    • Do You Need QT To View YouTube HD Videos??

      When viewing a regular youtube video, the file plays as a flash (.flv) native to the browser. Meaning, you do NOT need QuickTime, or any QT codec to view it. Youtube HD functions differently, that file is a QT (.mp4). My Question is .... when viewing