Client Management Suite

 View Only
  • 1.  Altiris Powershell Tasks and Custom Inventory

    Posted Jun 05, 2012 03:33 PM

    Recently I have tried migrate all my scripts and code to powershell. When we looked to migrate some tasks and Custom Inventory to powershell we had some unexpected issues. These scripts work perfectly on the local machine and even return the custom inventory data back to the server but when run through a task the following errors come back. 

    The string starting:
    At C:\Windows\TEMP\AltirisScript07776FE01A249E11EDA.ps1:95 char:99
    + $members = $Group.psbase.invoke("Members") | {$_.GetType().Invoke
    Member("Name", 'GetProperty <<<< ', $null, $_, $null)}
    is missing the terminator: '.
    At C:\Windows\TEMP\AltirisScript07776FE01A249E11EDA.ps1:135 char:3
    + } <<<<
    + CategoryInfo : ParserError: (, $null, $_, $n... happening"
    }:String) [], ParseException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

     

    I can post the whole code if it would help but the part that it does not like seems to be my expanding of the users in the Administrators group.

     

    $Group = $objComputer.psbase.children.find("Administrators")
        $members = $Group.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}
        ForEach($user in $members)
     
    135 is just the end. 
     
    Any idea if there is some sort of special formatting or "rules" to follow when using Powershell as a script. 


  • 2.  RE: Altiris Powershell Tasks and Custom Inventory

    Posted Jun 07, 2012 12:37 PM

    There are no braces after the foreach at the end. Was that intentional? Can you post the whole thing?



  • 3.  RE: Altiris Powershell Tasks and Custom Inventory

    Posted Jun 20, 2012 01:23 PM

    Sorry for not replying back to this. Was working with Support on this script as it worked locally. Looks like symantec does some weird aliasing stuff when running powershell. 

     

    There were no braces as the code cut off so it was intentional. This is the modified code that symantec gave  back to me. 

     

    Old Code

    $members = $Group.psbase.invoke("Members") | %{$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)}

     

    New Code

    $members = $Group.psbase.invoke("Members") | foreach{$_.GetType().InvokeMember("Name", "GetProperty", $null, $_, $null)}

     

    In case anyone has some issues with powershell scripts in the future. 

     



  • 4.  RE: Altiris Powershell Tasks and Custom Inventory

    Posted Jun 20, 2012 03:40 PM

    I am glad you got it figure out. I don't like using shortcuts, i.e. % rather than foreach, because it makes it harder to read and who knows what external parsers will do with it.