Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Import Deploy Packages from csv export

Is there a way to export the Application list and their Uninstall codes to individual packages (for later nesting)?

I know I can export to .csv, and edit the columns down. But Can I import them?

0

Comments

3 comments
Date Votes
  • There's no built in way to do that. It would probably be possible with some PowerShell, but not simple.

    0
  • For the uninstallation, you can allways put the uninstall commands with in a batch file and deploy that.

    0
  • I was able to put together a script that does what I think you were asking for. It's a bit rough, but seems to work well enough. It creates XML files that you can import into Deploy.

    Build-UninstallPackages.ps1

    # Written by Colby Bouma
    # This script generates packages from the uninstall strings found in your PDQ Inventory database
    # Inspired by this post: https://support.adminarsenal.com/hc/en-us/community/posts/114095482692
    #
    # v 001

    [xml]$Uninstall_Template = Get-Content '.\Uninstall Template.xml'

    $SQLite_EXE = "C:\Program Files (x86)\Admin Arsenal\PDQ Inventory\sqlite3.exe"
    $Inv_DB = "C:\ProgramData\Admin Arsenal\PDQ Inventory\Database.db"

    # This is where your packages will be created
    $Packages_Path = "C:\Packages"

    # Grab the list of applications
    $Application_List = ( & $SQLite_EXE $Inv_DB -csv "SELECT Name FROM [~Applications] GROUP BY Name ORDER BY Name;" )

    # Grab the uninstall strings and build the packages
    Foreach ( $Application_Item in $Application_List ) {

    # Prepare the string to be used in another query
    $Application_Item_Strip_Single = $Application_Item -replace ("'")
    $Application_Item_Strip_Double = $Application_Item_Strip_Single -replace ('"')
    $Application_Item_Quoted = "`'$Application_Item_Strip_Double`'"

    # Grab the uninstall strings
    $SQL_Query = "`"SELECT Uninstall FROM [~Applications] WHERE Name LIKE $Application_Item_Quoted GROUP BY Uninstall ORDER BY Uninstall;`""
    $Uninstall_Strings = ( & $SQLite_EXE $Inv_DB $SQL_Query | Out-String )

    if ( $Uninstall_Strings -ne "" ) {

    # Clone the XML template
    $Uninstall_Package = $Uninstall_Template.Clone()

    # Set the package name and title
    $Uninstall_Package."AdminArsenal.Export".Package.Name = "Uninstall $Application_Item_Strip_Double"
    $Uninstall_Package."AdminArsenal.Export".Package.PackageDefinition.Steps.CommandStep.Title = "Uninstall $Application_Item_Strip_Double"

    # Set the command steps
    $Uninstall_Package."AdminArsenal.Export".Package.PackageDefinition.Steps.CommandStep.Command = "$Uninstall_Strings"

    # Write the XML file
    $Application_Item_Filename = $Application_Item_Strip_Double -replace ('/',"")
    $Uninstall_Package.Save("$Packages_Path\Uninstall $Application_Item_Filename.xml")

    }

    }

    Uninstall Template.xml

    <?xml version="1.0" encoding="utf-8"?>
    <AdminArsenal.Export Code="PDQDeploy" Name="PDQ Deploy" Version="12.1.0.0" MinimumVersion="3.1">
    <Package>
    <PackageDefinition name="Definition">
    <CopyMode>Default</CopyMode>
    <InventoryScanProfileId value="null" />
    <RunAs value="null" />
    <ScanAfterDeployment value="null" />
    <Steps type="list">
    <CommandStep>
    <Command></Command>
    <Files></Files>
    <SuccessCodes>0</SuccessCodes>
    <RunAs value="null" />
    <Conditions type="list">
    <PackageStepCondition>
    <Architecture>Both</Architecture>
    <Version>All</Version>
    <TypeName>OperatingSystem</TypeName>
    </PackageStepCondition>
    <PackageStepCondition>
    <IsUserLoggedOn>AlwaysRun</IsUserLoggedOn>
    <TypeName>LoggedOnUser</TypeName>
    </PackageStepCondition>
    </Conditions>
    <ErrorMode>StopDeploymentFail</ErrorMode>
    <IsEnabled value="true" />
    <Title></Title>
    <TypeName>Command</TypeName>
    </CommandStep>
    </Steps>
    <Timeout value="60" />
    <UseCustomTimeout value="false" />
    </PackageDefinition>
    <Description></Description>
    <FolderId value="2" />
    <Name></Name>
    <Path></Path>
    <Version></Version>
    <PackageDisplaySettings name="DisplaySettings">
    <DisplayType>Normal</DisplayType>
    <IconKey></IconKey>
    <SortOrder value="7" />
    </PackageDisplaySettings>
    </Package>
    </AdminArsenal.Export>

     

    0