Altiris Software Dev Kit (ASDK)

 View Only
Expand all | Collapse all

PowerShell Module for the ASDK

Migration User

Migration UserJul 27, 2016 09:21 PM

  • 1.  PowerShell Module for the ASDK

    Posted Jul 24, 2016 11:38 PM

    Hey all,

    Wanted to see if anyone wants to join me on my quest to make a PowerShell module for the ASDK. I have automatically converted all of the existing web service methods into PowerShell functions.

    My task now is to change the functions to meet PowerShell naming standards and add help to each of the functions. Hit me up on GitHub, here or Twitter if you want to lend a hand.

    https://github.com/Tiberriver256/PowerShellSymantecAltirisASDK

     



  • 2.  RE: PowerShell Module for the ASDK

    Posted Jul 24, 2016 11:40 PM

    Check out the AutoGeneratedPS.ps1 file to see the rough but functional(should be) code.



  • 3.  RE: PowerShell Module for the ASDK

    Posted Jul 25, 2016 10:03 AM

    Nice idea, have you thought about adding ResourceModel too

    • http://localhost/altiris/nswebservice/resourcemodel.asmx


  • 4.  RE: PowerShell Module for the ASDK

    Posted Jul 25, 2016 01:27 PM

    Cool. It looks like the webservice doesn't support HTTP GET or POST methods directly so I might have to connect it as a webservice proxy instead but yeah it would be doable.

    It doesn't look like it's officially part of the ASDK. Is there some documentation for the web service anywhere?

     



  • 5.  RE: PowerShell Module for the ASDK

    Posted Jul 25, 2016 11:54 PM

    *Update: I converted the ASDK .chm file into help for all the cmdlets. Now we have the parameter explanations built right into PowerShell!

    PS C:\users\wmrm\Desktop\GitHub\PowerShellSymantecAltirisASDK> help CreateCommandLine -Full
    
    NAME
        CreateCommandLine
        
    SYNOPSIS
        Create new command line item
        
    SYNTAX
        CreateCommandLine [-Name] <String> [-Description] <String> [-SoftwarePackageGuid] <Guid> [-SoftwareComponentGuid] <Guid> [-InstallationFileType] <String> [-CommandType] 
        <String> [-Default] <Boolean> [-CommandLine] <String> [-SuccessCodes] <String> [-ErrorCodes] <String> [-Server] <String> [[-Credential] <PSCredential>] [<CommonParameters>]
        
        
    DESCRIPTION
        
    
    PARAMETERS
        -Name <String>
            Name
            
            Required?                    true
            Position?                    1
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -Description <String>
            Description (can be empty)
            
            Required?                    true
            Position?                    2
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -SoftwarePackageGuid <Guid>
            GUID of package if command line requires package (you can use the empty guid {00000000-0000-0000-0000-000000000000} if SoftwareComponentGuid is specified)
            
            Required?                    true
            Position?                    3
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -SoftwareComponentGuid <Guid>
            GUID of software component which will be associated with command line (you can use the empty guid {00000000-0000-0000-0000-000000000000} if the Package guid is specified)
            
            Required?                    true
            Position?                    4
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -InstallationFileType <String>
            Name of installation file type. Different installation file types have different types of command line. For example "MSI Software Installation File" has command line types 
            Install, Uninstall, Repair, Custom. "EXE Software Installation File" has types Install, Uninstall, Custom, and so forth. If you don't want to specify the installation file 
            type method just pass an empty string. The empty string will be considered as general 'other' type of installation file. Such type of installation file has three command 
            line types: Custom, Install, Uninstall NOTE: Because the list of types can change there are no hardcoded list of available installation file types. To see which type are 
            registered just open Command Line editor dialog in Notification Server console or call GetRegisterInstallationFileTypes method.
            
            Required?                    true
            Position?                    5
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -CommandType <String>
            Command line type. Typical values are: Install Uninstall Repair Upgrade Custom NOTE: The list of available command line types is specific to the specified installation file 
            type. If a command line type is unsupported by the specified installation file type, the method cause an exception. To see the exact command line types which are available 
            for certain installation file types please open Command Line editor dialog in Notification Console or call GetCommandLineTypesByInstallationFileType method.
            
            Required?                    true
            Position?                    6
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -Default <Boolean>
            Set command line as default. Only command line with type different from "Custom" can be set as default.
            
            Required?                    true
            Position?                    7
            Default value                False
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -CommandLine <String>
            Command line itself.
            
            Required?                    true
            Position?                    8
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -SuccessCodes <String>
            Comma separated list of success codes.
            
            Required?                    true
            Position?                    9
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -ErrorCodes <String>
            Comma separated list of error codes.
            
            Required?                    true
            Position?                    10
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -Server <String>
            
            Required?                    true
            Position?                    11
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        -Credential <PSCredential>
            
            Required?                    false
            Position?                    12
            Default value                
            Accept pipeline input?       false
            Accept wildcard characters?  false
            
        <CommonParameters>
            This cmdlet supports the common parameters: Verbose, Debug,
            ErrorAction, ErrorVariable, WarningAction, WarningVariable,
            OutBuffer, PipelineVariable, and OutVariable. For more information, see 
            about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 
        
    INPUTS
        
    OUTPUTS
        
        -------------------------- EXAMPLE 1 --------------------------
        
        PS C:\>Create a new command line named "Install Orca 3.0"
        
        
        CopyC#
        SoftwareCommandLineManagementLib managementLib = new SoftwareCommandLineManagementLib();
        SoftwareCommandLineDetails details = managementLib.CreateCommandLine("Install Orca 3.0", "This command line installs Orca 3.0",
        Guid.Empty, guidSoftwareComponent,
        "MSI Software Installation File", "Custom",
        true, "msiexec -i Orca30.msi",
        "0", "1,2,3" );
        CopyVBScript
        set managementLib = CreateObject("Altiris.ASDK.SMF.SoftwareCommandLineManagement")
        set cmdlineDetails = managementLib.CreateCommandLine("Install Orca 3.0", "This command line installs Orca 3.0", _
        "{00000000-0000-0000-0000-000000000000}", "{D321F91A-50FF-4832-930D-F0849ED75605}", _
        "MSI Software Installation File", "Custom", _
        true, "msiexec -i Orca30.msi", _
        "0", "1,2,3" )
        Copy 
        set SMF=AltirisASDKSMF.exe
        set CMDLINE_NAME=Install Orca 3.0
        set CMDLINE_DESC=This command line installs Orca 3.0
        set PACKAGE_GUID={00000000-0000-0000-0000-000000000000}
        set SOFTWARE_GUID={D321F91A-50FF-4832-930D-F0849ED75605}
        set SIF_TYPE=MSI Software Installation File
        set CMDLINE_TYPE=Custom
        set IS_DEFAULT=true
        set COMMAND_LINE=msiexec -i Orca30.msi
        set SUCCESS_CODES="0"
        set ERROR_CODES="1,2,3"
        %SMF% cmd:CreateCommandLine "Name:%CMDLINE_NAME%" "Description:%CMDLINE_DESC%" "SoftwarePackageGuid:%PACKAGE_GUID%" "SoftwareComponentGuid:%SOFTWARE_GUID%" 
        "InstallationFileType:%SIF_TYPE%" "CommandType:%CMDLINE_TYPE%" "Default:%IS_DEFAULT%" "CommandLine:%COMMAND_LINE%" "SuccessCodes:%SUCCESS_CODES%" "ErrorCodes:%ERROR_CODES%"
        echo Created Command Line
        Remarks
        The CLI is being deprecated. Please see the CLI Programming Guide.
        
        
        
        
        
        
    RELATED LINKS
    

    Now I just need to convert the naming convention to PowerShell standards and the examples to PowerShell and I would call it good enough :)



  • 6.  RE: PowerShell Module for the ASDK

    Posted Jul 26, 2016 05:14 AM

    I'm not sure if it is documented but would be very useful.
    It's what WF uses to interact with the SMP:

    Editing Assets with the NS Resource Model and Workflow
    https://www.symantec.com/connect/videos/editing-assets-ns-resource-model-and-workflow

    Software Management Resource Schema 7.5-7.6
    https://www.symantec.com/connect/articles/software-management-resource-schema-75-76

     



  • 7.  RE: PowerShell Module for the ASDK

    Posted Jul 26, 2016 08:30 AM

    Beautiful, I'll read through the resources and we can add them in. I'm sure we might end up with a few utility functions as well for common tasks performed in Altiris that utilize the asdk but simplify tasks for those who are less familiar with the development framework.



  • 8.  RE: PowerShell Module for the ASDK

    Posted Jul 26, 2016 08:39 AM

    Added this as an enhancement request here:

    https://github.com/Tiberriver256/PowerShellSymantecAltirisASDK/issues/1



  • 9.  RE: PowerShell Module for the ASDK

    Posted Jul 26, 2016 09:06 AM

    Sounds good to me, great addition with the help too :)



  • 10.  RE: PowerShell Module for the ASDK

    Posted Jul 26, 2016 10:14 PM

    I added in a better readme to make getting started easier.

    https://github.com/Tiberriver256/PowerShellSymantecAltirisASDK



  • 11.  RE: PowerShell Module for the ASDK

    Posted Jul 27, 2016 03:00 AM

    Man, I was literally just working on something similar, although I was using New-WebServiceProxy and it was going to take me waaaay longer to get anything like full coverage as I was coding by hand. Oh well, this is awesome and I learned something new with your ConvertTo-Function function :)

    I went ahead and used your ConvertTo-Function and added the patch methods from /Altiris/PatchManagementCore/PatchWorkflowSvc.asmx. 

    Hopefully I sent in the pull request successfully, it's my first time doing a pull request, so let me know if I messed something up!

    Thanks for this btw, this is a huge help!

     



  • 12.  RE: PowerShell Module for the ASDK

    Posted Jul 27, 2016 09:01 AM

    Hi Rob!

    Thank you for the idea and the PR! Great stuff!

    You did it right but something goofed with the code. I put a comment on your PR.



  • 13.  RE: PowerShell Module for the ASDK

    Posted Jul 27, 2016 10:07 AM
    • http://localhost/altiris/nswebservice/itemmodel.asmx
    • http://localhost/altiris/nswebservice/taskservermodel.asmx


  • 14.  RE: PowerShell Module for the ASDK

    Posted Jul 27, 2016 09:21 PM

    Added as enhancement issue #5 and #6