Skip to Content

5 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member

    Hi Stefan,

    I am getting following error when I run the automated login script. I have placed the COM.ps1 in same directory as SAP_Auto_login.ps1 script. Please help as I am new to Powershell scripting.

     

    C:\windows\system32> C:\Basis\PowerShell Scripting\SAP_Auto_Login.ps1
    . : The term ‘COM.ps1’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\Basis\PowerShell Scripting\SAP_Auto_Login.ps1:4 char:6
    + .”COM.ps1″
    + ~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (COM.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    (0) 
  2. Former Member

    Hello,

    I am getting following error when trying to run the above Powershell script for automated login. The COM.ps1 file is in same directory.

     

    S C:\windows\system32> C:\Basis\PowerShell Scripting\SAP_Auto_Login.ps1
    . : The term ‘COM.ps1’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
    spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\Basis\PowerShell Scripting\SAP_Auto_Login.ps1:4 char:6
    + .”COM.ps1″
    + ~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (COM.ps1:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

     

    Thanks,

    Dnyandev

    (0) 
  3. Stefan Schnell
    Post author

    Hello,

    try this to solve your problem:

    #-Begin-----------------------------------------------------------------
    
      #-Includes------------------------------------------------------------
        ."$PSScriptRoot\COM.ps1"
    
      $hWSH = Create-Object "Wscript.Shell"
    
      $hWSH.Popup("testmessage", 2, "goto", 1)
      
      Free-Object $hWSH
        
    #-End-------------------------------------------------------------------

    On this way it is possible to run the script from every path.

    Cheers
    Stefan

    (0) 
  4. Anurag Das

    Hello Stefan,

     

    Apologies for such a late reply. Understand that my comment is coming almost 1 year later.

    There is a line from the code- Detecting the Availability of the session.

     

    #-Set the path to the SAP GUI directory——————————-

    $SAPGUIPath = “C:\Program Files (x86)\SAP\FrontEnd\SAPgui\”

     

    So in our scenario, we have a nfs path from where the SID information is there.  \\vf0013.gha.kfplc.com\shared\Group\NWBC_Config\XXXX.xml

    So can you kindly suggest how I can modify it please ?

    Do I have to add any lines extra or can alter it.

     

    Thanks and Regards
    Anurag Das

    (1) 
    1. Stefan Schnell
      Post author

      Hello Anurag,

      thanks for your reply.

      I am not really sure that I understand you correctly. It is not necessary with this approach to modify the path of the XML file.

      If you need the content of the XML file, you can try this to get it:

      #-Begin-----------------------------------------------------------------
      
        #-Sub Main------------------------------------------------------------
        Function Main() {
      
          [XML]$NFS = Get-Content "\\YourServer\YourPath$\saplogon\SAPUILandscape.xml";
          $StringWriter = [System.IO.StringWriter]::new();
          $XmlWriter = [System.Xml.XmlTextWriter]::new($StringWriter);
          $XmlWriter.Formatting = [System.xml.formatting]::Indented;
          $NFS.WriteContentTo($XmlWriter);
          $SAPUILandscape = $StringWriter.ToString();
      
          Write-Host $SAPUILandscape;
      
        }
      
        #-Main----------------------------------------------------------------
        Main;
      
      #-End-------------------------------------------------------------------

      Let us know your results.

      Cheers
      Stefan

      (0) 

Leave a Reply