Jump to content

DarrenWhite99

Administrator
  • Posts

    1302
  • Joined

  • Last visited

  • Days Won

    250

Files posted by DarrenWhite99

  1. PowerShell Embedding in Batch

    You can't directly run .ps1 files in remote monitors like you can .vbs and .bat files. But this applies beyond just remote monitors, .ps1 doesn't run universally like .vbs or .bat. A way to get PowerShell portable is to use a .vbs or .bat file to carry the PowerShell script.
    Here are a couple of ways you can do this: The first is a generic way to embed text files inside a batch script. The embedded files are extracted and saved apart from the script. This example has two simple text files included. (See BATCH-WITH-EMBEDDED-FILEs.bat)
    The second script method is a way to include PowerShell code directly inside a batch file. This can run anywhere like a batch and the PowerShell is interpreted directly without creating any secondary files. There is a trade-off, the output will not report the correct line number for any failures, and a script crash can result in no useful output. (Output is buffered. Write-Host will be output immediately. Write-Output will buffer until the script completes.) For this reason it is harder to develop and debug PowerShell wrapped in a batch file. So this method works best when you develop and test a PowerShell script as a separate file, and then simply dump the contents to the end of the Batch framework script. (See BATCH-WITH-EMBEDDED-POWERSHELL.bat)
    I use method 1 when I need to include standalone files and want to move them all with one file. (An example is a batch script that imports a trusted publisher certificate. The certificate is carried inside the batch, but needs to be its own file for importing by certutil.) I use method 2 anytime I want a batch to run PowerShell. Several of my remote monitors in LabTech are .bat wrapped PowerShell scripts. I don't like creating a batch file that only turns around to create a separate PowerShell file. You have two files to clean up, etc.
    Aside from the starter scripts, I included examples of how I have used both methods in real life.

    172 downloads

       (0 reviews)

    0 comments

    Submitted

  2. Add Agent DNS Servers field to Dataviews

    The attached SQL will modify all dataviews that include the computer's local IP (Agent IP Address) to also include the DNS server information as "Agent DNS Servers". I started out planning to create a specific dataview, but I think it is better to make this column available in any dataview.  I suggest copying one or a few of the stock Dataviews, and then running this. While it will update all dataviews, many will be flagged as having changes the next time Solution Center is ran and may be reset to original. The copied Dataviews should preserve the additional column.
    Save the file and import into Control Center using Tools -> Import -> SQL File. It will ask if you want to "Import 1 Statement into the database". If it says there are many statements choose "No", you have an older (buggy) Control Center and you will need to import using SQLYog or some other tool.

    450 downloads

       (4 reviews)

    1 comment

    Submitted

  3. PowerShell Deployment Scripts

    I used the stock PowerShell 2.0 update script, and modified it for PowerShell 3, 4, and 5. I attempted to cover pre-requisites checks to prevent installing on systems with incompatible applications or operating systems. The scripts will check if the KB is reported as installed after the update completes to determine status. This means that the script will report the update was successful even if a reboot is still needed.
    The attached .ZIP has 3 scripts, one for each version, in a single XML bundle. To import the Scripts, select Tools -> Import -> XML Expansion. After import the scripts should appear in the "__Examples" folder. This pairs nicely with the PowerShell Version Roles at https://www.labtechgeek.com/files/file/13-powershell-version-roles/

    605 downloads

       (2 reviews)

    7 comments

    Updated

  4. GetFile Downloader Function Script

    The function Script "GetFile" is a simple way to always follow best practices for file downloads as well as enabling advanced functionality. A sample script showing how to use it is included, plus two Scriptlets to insert the script steps needed to use this in two clicks. Previously this script was known as GetLTFile.
    At its minimum, you can use this by defining two variables (the source and destination for the download) and calling the script. The script will test if the file already exists and skip downloading automatically. It will verify the target folder exists before attempting to download, and create it if needed. If a download fails it will try again by default, and will automatically enable verbose logging after two failures from the same script. Compressed file contents are automatically extracted (.ZIP under Windows, OSX, Linux if unzip is installed. .TGZ under OSX, Linux). By defining additional variables you can require that the file meets Minimum or Maximum size limits or verify the MD5 Checksum is valid (all three options supported under Windows, OSX, and Linux). You can require the file to always be re-downloaded, specify the number of retries allowed, and can even support automatic failover by specifying multiple sources.
    Supported download protocols are ones supported by the "File Download" function (LTShare\Transfer\*) and "File Download URL" function (HTTP, HTTPS for all agents plus UNC paths for Windows Agents). With the optional WINSCP binary, SFTP:// is also a supported protocol (Windows only).
    To import the Scripts, select Tools -> Import -> XML Expansion. After import the scripts should appear in the root Scripts folder.
    To import the Scriptlets, select Tools -> Import -> SQL File. The Scriptlets should be imported AFTER the scripts have already been added. For more instructions on Scriptlets see https://docs.connectwise.com/ConnectWise_Automate/ConnectWise_Automate_Documentation/070/240/050/020#Use_Scriptlets

    370 downloads

       (0 reviews)

    0 comments

    Updated

  5. Perform Computer Restart and Related Scripts

    This bundle contains the three following scripts:
    FUNCTION - Check For Pending Reboot Checks to determine if a Reboot is needed. Sets "@RebootPending@=1" if a restart is required. "@RebootReason@" will contain the reasons a reboot was required, if any were found. If @RebootReason@ includes "!", the reboot is required. Process PendingFileRenameOperations This script will attempt to process pending file operations that would otherwise require a restart to complete. This may allow a reboot to be avoided. Perform Computer Restart* This script will execute a restart and sleep until the computer has restarted successfully. The script will wait 30 minutes before exiting with an error. Variable "@RebootPending@" used to return Reboot Status.
    @RebootPending@ = 0 if reboot successful
    @RebootPending@ = 255 if reboot failed  

    524 downloads

       (0 reviews)

    0 comments

    Updated

  6. PowerShell Version Roles

    This bundle will add the following Role Definition:
    PowerShell
    And the following Sub-Definitions:
    PowerShell 1
    PowerShell 2
    PowerShell 3
    PowerShell 4
    PowerShell 5
    PowerShell 6
    To import these Role Definitions, in the ConnectWise Automate main screen, go to Tools > Import -> SQL File. Browse to the relevant file, and OK the message about inserting 7 rows.
     

    396 downloads

       (0 reviews)

    0 comments

    Updated

  7. Dell Server Roles

    This bundle will create the following Role:
    Dell Server
    And the following sub-roles:
    Dell Server - 3G
    Dell Server - 4G
    Dell Server - 5G
    Dell Server - 6G
    Dell Server - 7G
    Dell Server - 8G
    Dell Server - 9G
    Dell Server - 10G
    Dell Server - 11G
    Dell Server - 12G
    Dell Server - 13G
    Dell Server - 14G
    Let me know if you find anything incorrectly detected, there are some odd ones prior to Gen10/11, and Gen14 is brand new so I have nothing in production to test against yet.
    To import these Role Definitions, in the ConnectWise Automate main screen, go to Tools > Import -> SQL File. Browse to the relevant file, and OK the message about inserting 13 rows.

    114 downloads

       (0 reviews)

    2 comments

    Updated

  8. HP Proliant Server Roles

    This bundle will create the following Role:
    HP Server
    And the following sub-roles:
    HP Server - Gen6
    HP Server - Gen7
    HP Server - Gen8
    HP Server - Gen9
    HP Server - Gen10
    I don't do a lot with HP servers, so these roles are not heavily tested. If you see anything detected incorrectly, please let me know so that I can update the role detection definition.
    To import these Role Definitions, in the ConnectWise Automate main screen, go to Tools > Import -> SQL File. Browse to the relevant file, and OK the message about inserting 6 rows.

    118 downloads

       (0 reviews)

    3 comments

    Updated

  9. Analyze ExecuteScript Function

    This function script should be called right before and after the "Execute Script" function. It will catch the temporary script as it is written to the agent, preserve a copy, and check for Non-ASCII characters that can break script execution. When called a second time, it will retrieve the information gathered. The saved file and analysis log file are also left on the agent for additional investigation if needed.

    36 downloads

       (0 reviews)

    0 comments

    Updated

×
×
  • Create New...