# Overview

The shared script library is a repository of RMM agnostic scripts that can be used by MSPs to automate tasks and manage client devices.

{% hint style="info" %}
**Disclaimer:** While scripts in this library are designed to be RMM agnostic, they are only tested locally and from my current RMM platform.
{% endhint %}

This library is a repository of PowerShell scripts designed for use by my fellow **IT Managed Service Providers** (MSPs), primarily geared towards smaller MSPs (including one-person shops). Internal IT teams may also find the scripts useful.

**Each script page includes:**

* An overview of the script.
* Prerequisites to running the script.
* Examples for executing the script.
* Documentation for all script parameters.

**Notes:**

PowerShell scripts included in this library are built for and tested against **Windows 10 or later**, which includes **PowerShell 5.1**. Earlier versions of Windows / PowerShell will be missing cmdlets or cmdlet parameters that were introduced in later versions.

Scripts shared with :heart: by **Aaron J. Stevenson**.

{% hint style="info" %}
Banner image created by **Olivia Xu** at [Microsoft Design](https://microsoft.design/).
{% endhint %}


# Installers

PowerShell scripts to install various software products silently.


# Bluebeam Revu

PowerShell script to silently install Bluebeam Revu (v21+).

## Overview

{% hint style="info" %}
**Dev Insight:** While this script is intended for new installs of Bluebeam Revu, it can also be used to update existing Bluebeam Revu installations to the latest version.
{% endhint %}

This script downloads and installs the latest version of Bluebeam Revu.&#x20;

{% embed url="<https://www.bluebeam.com/>" %}

**Prerequisites:** This script has no prerequisites.&#x20;

**Notes:**

* This script will not license Bluebeam. A licensed user will need to login after installation.
* Script will abort if a perpetually licensed (legacy) version of Bluebeam Revu is detected.
* Script will abort if Bluebeam Revu is currently running to avoid potential data loss.

***

## Script

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/InstallBluebeamRevu.ps1>" %}

## Examples

```powershell
.\InstallBluebeamRevu.ps1
```

This example downloads and installs the latest version of Bluebeam Revu.

***

## Parameters

This script has no parameters.


# Browser Extension

PowerShell script to silently install a browser extension by ID.

## Overview

{% hint style="info" %}
**Dev Insight:** While group policy and Intune configuration profiles are the ideal way to distribute browser extensions, I needed a way to easily distribute extensions in environments without Active Directory / Intune.&#x20;
{% endhint %}

This script creates the necessary registry entries for Microsoft Edge or Google Chrome to install the provided extension globally for all users of a device. \
\
By default, the extension installation is not "forced". Each user will be able to disable or uninstall the extension for their browser profile. To prevent this, the `-Force` parameter can be used.

{% embed url="<https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/developer-guide/alternate-distribution-options>" %}

{% embed url="<https://developer.chrome.com/docs/extensions/how-to/distribute/install-extensions#registry>" %}

**Prerequisites:** This script has no prerequisites.&#x20;

***

## Script

{% hint style="info" %}
**Note:** Browser specific versions of this script can be found in the [GitHub repo](https://github.com/wise-io/scripts/tree/main/scripts).
{% endhint %}

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/InstallBrowserExtension.ps1>" %}

## Examples

### Example 1

```powershell
.\InstallBrowserExtension.ps1 -ID 'hokifickgkhplphjiodbggjmoafhignh' -Edge 
```

This example installs the [Microsoft Editor: Spelling & Grammar Checker](https://microsoftedge.microsoft.com/addons/detail/microsoft-editor-spellin/hokifickgkhplphjiodbggjmoafhignh) extension in Microsoft Edge for all users. When installed, users will be prompted to enable the extension.

### Example 2

```powershell
.\InstallBrowserExtension.ps1 -ID 'ghbmnnjooekpmoecnnnilnnbdlolhkhi' -Chrome -Force 
```

This example force installs the [Google Docs Offline](https://chromewebstore.google.com/detail/google-docs-offline/ghbmnnjooekpmoecnnnilnnbdlolhkhi) extension in Google Chrome for all users. Users will not be able to disable or uninstall the extension.

***

## Parameters

### Required Parameters

`-ID`

The ID of the browser extension to be installed.

`-Chrome`

Used to specify that the extension ID provided is a Google Chrome browser extension. Either this or the `-Edge` parameter must be used.&#x20;

`-Edge`

Used to specify that the extension ID provided is a Microsoft Edge browser extension. Either this or the `-Chrome` parameter must be used.

### Optional Parameters

`-Force`

When used, the provided extension will be added to the force installed extension list for the designated browser. Users will not be able to disable or uninstall the extension.


# Google Chrome

PowerShell script to silently install the latest version of Google Chrome.

## Overview

{% hint style="info" %}
**Dev Insight:** This script can be used as a template for performing basic download and installation of other simple msi installers.
{% endhint %}

This script downloads and installs the latest version of Google Chrome.

{% embed url="<https://chromeenterprise.google/browser/download/>" %}

**Prerequisites:** This script has no prerequisites.&#x20;

***

## Script

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/InstallGoogleChrome.ps1>" %}

## Examples

```powershell
.\InstallGoogleChrome.ps1
```

This example downloads and installs the latest version of Google Chrome.

***

## Parameters

This script has no parameters.


# Microsoft Defender for Endpoint

PowerShell script to silently install Microsoft Defender for Endpoint (MDE).

## Overview

{% hint style="info" %}
**Dev Insight:** This script can be used to deploy Microsoft Defender for Endpoint to domain joined devices seamlessly from your RMM of choice while you plan your migrations from Active Directory to Entra joined devices.
{% endhint %}

This script utilizes the onboarding package script provided by Microsoft to install Microsoft Defender for Endpoint (MDE) on Windows devices, including Windows 10 - 11 and Windows Server 2012 R2 - 2025.

{% embed url="<https://learn.microsoft.com/en-us/defender-endpoint/mde-planning-guide>" %}

**Prerequisites:**

* Microsoft user licenses that include MDE (such as Microsoft 365 Business Premium)
* Microsoft Defender for Endpoint server licenses (such as Microsoft Defender for Business servers)
* The MDE Onboarding Package for the M365 tenant being onboarded

***

## Setup

{% hint style="warning" %}
**Note:** Each M365 tenant will have a different onboarding package. **You should not use the same onboarding package for multiple organizations.**
{% endhint %}

To retrieve the necessary onboarding package:

1. Login to the M365 tenant&#x20;
2. Navigate to the Security portal
3. Click Settings > Endpoints > Onboarding
4. Select Windows 10 / 11 as OS type
5. Download the Onboarding Package and save at a location accessible to the script

***

## Script

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/InstallMicrosoftDefenderForEndpoint.ps1>" %}

***

## Parameters

`-OnboardingPackage`

Path to the onboarding package. File extension should be `.zip`.


# Microsoft Office

PowerShell script to cleanly install Microsoft Office.

## Overview

This script uses the Office Deployment Tool (ODT) to perform a clean install of Microsoft Office with a configuration xml file. For convenience, it includes a built-in xml file that will install **Microsoft Office 365 Business Retail** if a configuration file is not specified.

{% embed url="<https://learn.microsoft.com/en-us/deployoffice/overview-office-deployment-tool>" %}

**Prerequisites:**

1. If necessary, create a configuration xml at <https://config.office.com>.
2. Store the configuration xml in a location that will be accessible to the script at runtime (either file path or url).
3. Notate the path / url of the configuration xml. If using GitHub to host the file, be sure to get the raw URL.

**Notes:**

* When using the built-in configuration xml, the 64-bit version of Microsoft Office 365 will be installed, unless a 32-bit OS is detected or the `-x86` switch is used.
* This script will uninstall the Microsoft Office Hub Microsoft Store application.

***

## Script

{% hint style="danger" %}
Script will remove existing installations of Microsoft Office when used with the default configuration file.
{% endhint %}

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/InstallOffice.ps1>" %}

## Examples

### Example 1

```powershell
.\InstallOffice.ps1
```

This example installs Microsoft Office 365 Apps for Business using the built-in XML configuration file. All existing versions of Microsoft Office will be removed, including the Microsoft Office Hub Microsoft Store application.

### Example 2

```powershell
.\InstallOffice.ps1 -x86
```

This example installs the 32-bit version of Microsoft Office 365 Apps for Business using the built-in XML configuration file. All existing versions of Microsoft Office will be removed, including the Microsoft Office Hub Microsoft Store application.

### Example 3

```powershell
.\InstallOffice.ps1 -Config "C:\temp\office-config.xml"
```

This example utilizes the provided XML configuration file to install Microsoft Office.

### Example 4

```powershell
.\InstallOffice.ps1 -Config "https://raw.githubusercontent.com/wise-io/scripts/office-xmls/config.xml"
```

This example downloads the XML configuration file from the provided URL and installs Microsoft Office.

***

## Parameters

`-Config`

Optional string parameter that allows you to provide a file path or URL to an office configuration xml. This XML will be used to determine what Microsoft Office products to install or remove.

`-x86`

**Aliases:** `-32`, `-32bit`

Optional switch parameter that allows the installation of the 32-bit version of Microsoft Office 365, even on 64-bit systems.&#x20;

**Note:** This parameter cannot be used with `-Config`.


# Microsoft Teams

PowerShell script to silently install the new Microsoft Teams client machine wide.

## Overview

This script downloads and installs the latest Microsoft Teams (New) machine wide. If the Teams (Classic) Machine-Wide installer is present, it will be uninstalled. With its removal, Teams (Classic) will also be removed from all user profiles on their next login.

{% embed url="<https://learn.microsoft.com/en-us/microsoftteams/new-teams-bulk-install-client>" %}

**Prerequisites:** None

***

## Script

{% hint style="warning" %}
**Note:** This script will attempt to remove Teams (Classic) versions if they were deployed with the machine-wide installer package.
{% endhint %}

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/InstallTeams.ps1>" %}

***

## Parameters

`-Force`

Optional switch parameter - attempts install even if an existing installation is detected.


# QuickBooks Desktop

PowerShell script to silently install multiple versions of QuickBooks desktop.

## Overview

{% hint style="info" %}
**Dev Insight:** After tediously installing 6 versions of QuickBooks back-to-back on a single device, I wrote this script. It quickly paid for itself in the amount of labor saved. If only QuickBooks updates could be scripted as easily!
{% endhint %}

This script uses the provided Product Numbers to download and install multiple versions of QuickBooks desktop in a single pass. It is most useful for deployment of new devices for accountants, who often have requirements to maintain multiple versions of QuickBooks desktop.

{% embed url="<https://downloads.quickbooks.com/app/qbdt/products>" %}
Download QuickBooks Desktop
{% endembed %}

**Prerequisites:**

1. Collect the Product & License Numbers for the versions of QuickBooks you will be installing.
2. Ensure the script supports the desired versions. *If the script does not support your desired versions, you will need to add them ahead of time.*
3. **Optional:** Download the installers and place them in a directory that will be accessible to the script at runtime.

**Notes:**

* Script will abort if run as SYSTEM; it must be run as an administrative user.
* While this script can install multiple versions of QuickBooks Desktop in a single pass, installed versions will use a single license key. If you need to install various QuickBooks versions with different license keys side-by-side, you will need to run the script for each key.
* The required PDF components (Microsoft XPS Document Writer) will be enabled, if not already.
* View uncommented lines in the `$QBVersions` array in the script for currently supported versions.

***

## Script

{% hint style="danger" %}
Script will abort if run as SYSTEM; it must be run as an administrative user.
{% endhint %}

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/InstallQuickBooks.ps1>" %}

## Examples

### Example 1

```powershell
.\InstallQuickBooks.ps1 -ID 401228,917681
```

This example uses only the required parameter, `ProductNumbers` (alias `ID`) to download and install QuickBooks Pro 2022 & QuickBooks Pro 2023. Notably, it uses a default license key of '0000-0000-0000-000'. The correct license key will need to be manually added before QuickBooks is used.

### Example 2

```powershell
.\InstallQuickBooks.ps1 -Cache '\\SERVER\QuickBooks Installers' -License 1234-5678-9101-234 -ID 401-228,917-681 -ToolHub
```

This example, in addition to the required `ProductNumbers` (alias `ID`) parameter, uses the available optional parameters to install QuickBooks Pro 2022 & QuickBooks Pro 2023.

The `Cache` parameter is used to provide a path to pre-downloaded QuickBooks Desktop installers.

The `LicenseNumber` (alias `License`) parameter is used to supply the correct License Number for QuickBooks. The same license number will be used for all supplied Product Numbers. If multiple license numbers are required, the script will need to be run for each License Number.

The `ToolHub` parameter is used to install [QuickBooks ToolHub](https://quickbooks.intuit.com/learn-support/en-us/help-article/login-password/fix-common-problems-errors-quickbooks-desktop-tool/L3Yab5gNN_US_en_US) alongside the selected versions of QuickBooks Desktop.

***

## Parameters

### Required Parameters

`-ProductNumbers`

**Aliases:** `-ID`, `-Product`, `-Products`, `-ProductNumber`

Array parameter that accepts multiple QuickBooks Product Numbers with or without dashes. Supplied Product Numbers will be compared with the `$QBVersions` array to determine which versions of QuickBooks to install.

### Optional Parameters

`-Cache`

String parameter that allows you to provide a directory file path to pre-downloaded QuickBooks installers. If this parameter is not used or the path is invalid/inaccessible, the QuickBooks installers will be downloaded directly from Intuit.&#x20;

**Note:** This parameter assumes that the file names in the cache directory match the file names for the installers downloaded from Intuit.

`-LicenseNumber`

**Aliases:** `-License`

String parameter that allows you to supply the QuickBooks License Number (with or without dashes) for the versions of QuickBooks the script is installing. If this parameter is not used, a license number of 0000-0000-0000-000 will be used. The correct license can be added to QuickBooks after installation via **Help < Manage My License < Change My License** in QuickBooks Desktop.

`-ToolHub`

Switch parameter that can be used to install the [QuickBooks Tool Hub](https://quickbooks.intuit.com/learn-support/en-us/help-article/login-password/fix-common-problems-errors-quickbooks-desktop-tool/L3Yab5gNN_US_en_US) application alongside QuickBooks.


# Uninstallers


# Browser Extension

PowerShell script to silently remove a browser extension by ID.

## Overview

{% hint style="info" %}
**Dev Insight:** This script was created in tandem with the [browser extension installation script](https://scripts.aaronjstevenson.com/software/installers/browser-extension).
{% endhint %}

This script removes a Microsoft Edge or Google Chrome extension for all user / browser profiles on a device.&#x20;

{% embed url="<https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/developer-guide/alternate-distribution-options>" %}

{% embed url="<https://developer.chrome.com/docs/extensions/how-to/distribute/install-extensions#registry>" %}

**Prerequisites:** This script has no prerequisites.&#x20;

***

## Script

{% hint style="info" %}
**Note:** This script will throw a warning if force install extension policies are detected. The associated registry entries created by those policies will be removed by the script but may be automatically recreated by group policy / Intune. The warning is intended to prompt the technician to check group policy / Intune.
{% endhint %}

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/RemoveExt.ps1>" %}

## Examples

### Example 1

```powershell
.\RemoveExt.ps1 -ID 'hokifickgkhplphjiodbggjmoafhignh' 
```

This example removes the [Microsoft Editor: Spelling & Grammar Checker](https://microsoftedge.microsoft.com/addons/detail/microsoft-editor-spellin/hokifickgkhplphjiodbggjmoafhignh) extension in Microsoft Edge for all users and browser profiles.&#x20;

***

## Parameters

### Required Parameters

`-ID`

The ID of the browser extension to be removed.


# Backups

PowerShell scripts to backup / snapshot various components.


# SQL Databases

PowerShell script to create backups of all SQL databases on a device.

## Overview

{% hint style="info" %}
**Dev Insight:** This script was written to provide SQL backups to clients using [**SQL Express**](https://www.microsoft.com/en-us/sql-server/sql-server-downloads) with a backup solution that doesn't natively support SQL. **It is designed to be used on a schedule in tandem with a file/image-based backup solution.**
{% endhint %}

This script uses the [SqlServer](https://www.powershellgallery.com/packages/SqlServer) module to automate the creation of SQL database backups.

{% embed url="<https://www.powershellgallery.com/packages/SqlServer>" %}

**Prerequisites:**&#x20;

For this script to run successfully, the user running the script will need to have permission to perform SQL database backups on all databases, including system databases. It is recommended to run the script as `SYSTEM` and set permissions on each database using the process below.

{% embed url="<https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15>" %}

**Granting backup database permissions to `SYSTEM`:**

1. Install & login to [**Microsoft SQL Server Management Studio (SSMS)**](https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-ssms?view=sql-server-ver15) on the SQL Server
2. Navigate to Server\Instance > Security > Logins
3. Right-click `NT AUTHORITY\SYSTEM` and choose **Properties**
4. Under **Server Roles**, make sure `public` is checked
5. Under **User Mapping**, check each database and select the following database role memberships for each:
   1. `public`
   2. `db_backupoperator`

![](https://content.gitbook.com/content/DwT3zCFJCgmarBv0s7n8/blobs/hi3dz9XmafCgk1AJthMS/object-explorer.png) ![](https://content.gitbook.com/content/DwT3zCFJCgmarBv0s7n8/blobs/4hHctzhTgg9uoJQ5dzyQ/server-roles.png) ![](https://content.gitbook.com/content/DwT3zCFJCgmarBv0s7n8/blobs/mz1brRgYCF1poGrjijZx/user-mappings.png)

After database permissions are set, you can deploy the script via your RMM.

**Notes:**

* Unless changed manually, the default SQL backup location is `C:\Program Files\Microsoft SQL Server\MSSQL.[INSTANCENAME]\MSSQL\Backup`

***

## Script

{% hint style="danger" %}
Backups are not performed on databases named `tempdb.`
{% endhint %}

{% @github-files/github-code-block %}

## Examples

### Example 1

```powershell
.\BackupSQL.ps1

Checking for necessary PowerShell modules...
Modules installed successfully.

Databases in localhost\SQLEXPRESS:

Name                 Status           Size Owner   
                                                    
----                 ------           ---- -----   
master               Normal        6.00 MB sa      
model                Normal       16.00 MB sa      
msdb                 Normal      149.56 MB sa      

Performing backup of [master]...
Performing backup of [model]...
Performing backup of [msdb]...

Backup jobs complete.
```

This example creates a backup of all SQL databases on every detected instance, excluding temp databases.

### Example 2

```powershell
.\BackupSQL.ps1 -AuditOnly

Checking for necessary PowerShell modules...
Modules installed successfully.

Backup history for localhost\SQLEXPRESS (past month):

DatabaseName BackupSetType BackupStartDate      BackupFinishDate     Compressed
                                                                     BackupSize
------------ ------------- ---------------      ----------------     ----------
master            Database 2/1/2022 12:15:26 PM 2/1/2022 12:15:26 PM    3825664
master            Database 2/1/2022 1:11:16 PM  2/1/2022 1:11:16 PM     3821568
master            Database 2/1/2022 1:51:43 PM  2/1/2022 1:51:43 PM     3821568
master            Database 2/1/2022 2:07:29 PM  2/1/2022 2:07:29 PM     3821568
model             Database 2/1/2022 12:15:26 PM 2/1/2022 12:15:26 PM    2578432
model             Database 2/1/2022 1:11:16 PM  2/1/2022 1:11:16 PM     2574336
model             Database 2/1/2022 1:51:43 PM  2/1/2022 1:51:43 PM     2574336
model             Database 2/1/2022 2:07:29 PM  2/1/2022 2:07:29 PM     2574336
msdb              Database 2/1/2022 12:15:27 PM 2/1/2022 12:15:29 PM  126077952
msdb              Database 2/1/2022 1:11:16 PM  2/1/2022 1:11:19 PM   126073856
msdb              Database 2/1/2022 1:51:43 PM  2/1/2022 1:51:48 PM   126073856
msdb              Database 2/1/2022 2:07:29 PM  2/1/2022 2:07:32 PM   126073856

No new backups were performed.
```

This example displays database backups performed in the last month. It does not perform new backups.

***

## Parameters

`-AuditOnly`

Optional switch parameter that outputs a history of all database backups for the last month. No additional backups are performed when using this parameter.


# Synology Active Backup

PowerShell script to silently install the latest Synology Active Backup for Business agent.

## Overview

{% hint style="info" %}
**Dev Insight:** This script can also be used to update or reconfigure the Synology Active Backup for business agent.
{% endhint %}

The software applications available for Synology devices can be pretty powerful. One of my favorites, especially for internal IT, is Active Backup for Business (ABB).

<figure><img src="https://3518905989-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDwT3zCFJCgmarBv0s7n8%2Fuploads%2F3Yd6PKVyNauGMokjU49i%2Factivebackup_1607392921_1.png?alt=media&amp;token=e97bab34-8cb7-4027-b269-8500f3e4fff0" alt=""><figcaption></figcaption></figure>

**From their** [**Administrator's Guide**](https://global.synologydownload.com/download/Document/Software/AdminGuide/Package/ActiveBackup/All/enu/Synology_ABB_admin_guide_Windows_PC_PS_enu.pdf)**:**

> ABB centralizes data protection across a variety of IT environments, including virtual machines, physical servers, file servers, and personal computers. Administrators can deploy their preferred protection plan single-handedly through ABB's centralized admin console.&#x20;
>
> ABB also offers a wide range of backup options and restoration tools, as well as a number of optional technical and safety features.

{% embed url="<https://www.synology.com/en-us/dsm/feature/active-backup-business/overview>" fullWidth="false" %}

This script eases the deployment of the backup agent for Windows devices by silently downloading, installing, and configuring the agent on a device.

**Prerequisites:**

1. Setup Active Backup for Business on your Synology NAS.
2. Create a user account to authenticate the agent.
3. Configure your default backup tasks.

***

## Script

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/InstallSynologyActiveBackup.ps1>" %}

## Examples

```powershell
.\InstallSynologyActiveBackup.ps1 -Address "localhost" -Username "Backups" -Pass "Da ba dee da ba di"
```

This example downloads, installs, and configures the latest version of Synology Active Backup for Business agent.&#x20;

***

## Parameters

`-Address`

**Aliases:** `-Host`, `-Hostname`, `-IP`

Required string paramter that allows passing the hostname or IP address of the Synology device.

`-Username`

**Aliases:** `-User`

Required string parameter that allows you to pass the username required to authenticate with the Synology device.

`-Pass`

**Aliases:** `-Password`

Required string parameter that allows you to pass the password required to authenticate with the Synology device.

{% hint style="warning" %}
**Note:**&#x20;
{% endhint %}


# Windows Restore Point

PowerShell script to silently create a System Restore Point of the system drive.

## Overview

{% hint style="info" %}
**Dev Insight:** As of Windows 8, the default settings will not allow the creation of more than one system restore point in 24 hours. This script works around this limitation by temporarily modifying this setting.
{% endhint %}

This script can be used to automate the creation of System Restore Points on client machines, or to create a one-off checkpoint before applying changes to a machine.

**Prerequisites:** This script has no prerequisites.&#x20;

***

## Script

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/CreateRestorePoint.ps1>" %}

## Examples

### Example 1

```powershell
.\CreateRestorePoint.ps1
```

This example creates a checkpoint with the default description of "Scripted Checkpoint".

### Example 2

```powershell
.\CreateRestorePoint.ps1 -Description 'Installed QuickBooks'
```

This example creates a restore point with the description "Installed QuickBooks".

***

## Parameters

`-Description`

Optional string parameter that allows you to set a description for the restore point. If not provided, a default description of "Scripted Checkpoint" will be used.


# Updates

PowerShell scripts to update various software / OS components.


# Dell Command Update

PowerShell script to silently install and run Dell Command Update (DCU).

## Overview

{% hint style="info" %}
**Dev Insight:** This script was originally written to make sure devices deployed during our MDT process had the latest drivers/firmware from Dell, but it can also be used to update Dell devices already deployed via your RMM of choice.
{% endhint %}

This script downloads and installs the latest version of Dell Command Update (DCU) if not already installed. It will then use `dcu-cli.exe` to download and install all Dell driver/firmware updates, ignoring reboots.

{% embed url="<https://www.dell.com/support/kbdoc/en-us/000177325/dell-command-update>" %}

{% embed url="<https://www.dell.com/support/product-details/en-us/product/command-update/resources/manuals>" %}

**Prerequisites:** This script has no prerequisites.&#x20;

**Notes:**

* Script will abort if a PC manufacturer other than Dell is detected.
* Dell Update, which is incompatible with Dell Command Update, will be removed if detected.
* .NET Desktop Runtime, a prerequisite to Dell Command Update 5.5+, will be updated / installed to the latest LTS release if not already installed.&#x20;
* Dell Command Update is not intended for use with server hardware. Use Dell System Update instead.

***

## Script

{% hint style="info" %}
Script will abort if a system manufacturer other than Dell is detected.
{% endhint %}

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/DellCommandUpdate.ps1>" %}

## Examples

```powershell
.\DellCommandUpdate.ps1
```

This example downloads and installs Dell Command Update if it isn't already installed. After installation, Dell Command Update will check for and install any Dell updates.

```
.\DellCommandUpdate.ps1 -Reboot
```

This example downloads and installs Dell Command Update if it isn't already installed. After installation, Dell Command Update will check for and install any Dell updates. Once complete, a message will be displayed, and a reboot will be forced after 60 seconds.

***

## Parameters

`-Reboot`

Switch parameter - if specified, notifies the user and forces a reboot after 60 seconds.


# Microsoft Office

PowerShell script to check for and install Microsoft Office application updates.

## Overview

{% hint style="info" %}
**Dev Insight:** This script was extremely useful when patching for [CVE-2020-23397](https://msrc.microsoft.com/update-guide/vulnerability/CVE-2023-23397).
{% endhint %}

This script will check for ClickToRun installations of Microsoft Office. If found, `OfficeC2RClient.exe` will be used to scan for and apply updates. If updates are found, users may be asked to close Microsoft Office applications to complete update installation.

**Prerequisites:** This script has no prerequisites.&#x20;

***

## Script

{% hint style="info" %}
Script will abort if no ClickToRun installations of Microsoft Office are detected.
{% endhint %}

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/UpdateOffice.ps1>" %}

## Examples

```powershell
.\UpdateOffice.ps1
```

This example checks for ClickToRun installations of Microsoft Office. If found, a Microsoft Office update scan will be initiated.

***

## Parameters

This script has no parameters.


# Microsoft Store Applications

PowerShell script to silently update Microsoft Store applications.

## Overview

{% hint style="info" %}
**Dev Insight:** Are you annoyed that Windows Update doesn't update Microsoft Store applications? I was too.
{% endhint %}

This script allows you to set Microsoft Store applications to update automatically and also initiates on-demand update scans.

**Prerequisites:** This script has no prerequisites.&#x20;

***

## Script

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/UpdateMicrosoftStoreApps.ps1>" %}

## Examples

### Example 1

```powershell
.\UpdateMicrosoftStoreApps.ps1
```

This example initiates a scan for Microsoft Store application updates and applies them.

### Example 2

```powershell
.\UpdateMicrosoftStoreApps.ps1 -AutoUpdate
```

This example enables automatic updates for Microsoft Store applications. It then initiates a scan for updates and applies them.

***

## Parameters

`-AutoUpdate`

Optional switch parameter that enables automatic updates for Microsoft Store applications.


# Windows Management Framework

PowerShell script to update WMF to 5.1 for easier management.

## Overview

{% hint style="info" %}
**Dev Insight:** Hopefully you won't find yourself needing to manage EOL operating systems with PowerShell, but if you do, having access to PowerShell 5.1 helps!
{% endhint %}

This script downloads and installs the necessary Windows Update files to update the Windows Management Framework to 5.1. The necessary .NET Framework version will also be installed if not already present.

**Prerequisites:** This script has no prerequisites.&#x20;

**Notes:**

* This script requires at least PowerShell 4.0 (meaning Windows 7 SP1 is the oldest supported OS).
* This script will abort if it detects it is running in PowerShell 5.1 (meaning WMF 5.1 is already installed).

***

## Script

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/UpdateWMF.ps1>" %}

## Examples

```powershell
.\UpdateWMF.ps1
```

This example downloads and installs the necessary Windows Update files to update the Windows Management Framework to 5.1.

***

## Parameters

This script has no parameters.


# Windows Updates

PowerShell script to silently install Windows updates.

## Overview

This script uses the [PSWindowsUpdate](https://www.powershellgallery.com/packages/PSWindowsUpdate) module to apply Windows updates silently, ignoring reboots. It also applies updates to installed Microsoft products.

{% embed url="<https://www.powershellgallery.com/packages/PSWindowsUpdate/2.2.1.5>" %}

**Prerequisites:** This script has no prerequisites.&#x20;

***

## Script

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/UpdateWindows.ps1>" %}

## Examples

```powershell
.\UpdateWindows.ps1
```

This example installs the `PSWindowsUpdate` module, checks for all Windows updates and installs them. Reboots are ignored.

***

## Parameters

While this script has no parameters, the `PSWindowsUpdate` module has many. I have included `Get-Help` output on parameters for reference.

{% hint style="info" %}
**Module Version:** 2.2.0.3
{% endhint %}

{% code overflow="wrap" fullWidth="false" %}

```
-ComputerName <string[]>
    Specify one or more computer names for remote connection. Interactive remote connection works only for checking updates. For download or install cmdlet creates an Invoke-WUJob task.

-SendReport <SwitchParameter>
    Send report email to specific recipients.

    Requires the parameter -PSWUSettings or declare the PSWUSettings.xml file (more preferred) in ModuleBase path.

-PSWUSettings <Hashtable>
    Required parameter for -SendReport.

    Passes the parameters (as hashtable) necessary to send the report: \r\n@{SmtpServer="your.smtp.server";From="sender@email.address" To="recipient@email.address";[Port=25];[Subject="AlternativeSubject"];[Properties="Alternative object properties"];[Style="Table|List"]}

    Send parameters can also be saved to a PSWUSettings.xml file in ModuleBase path: \r\nExport-Clixml @{SmtpServer="your.smtp.server";From="sender@email.address";To="recipient@email.address";[Port=25]}

-SendHistory <SwitchParameter>
    Send install history (Get-WUHistory) report after successful update installation or system startup.

-ScheduleJob <DateTime>
    Specify time when job will start.

-AcceptAll <SwitchParameter>
    Do not ask confirmation for updates. Download or Install all available updates.

-RecurseCycle <int>
    Specify number of cycles for check updates after successful update installation or system startup. First run is always main cycle (-RecurseCycle 1 or none). Second (-RecurseCycle 2) and n (-RecurseCycle n) cycle are recursive.

-Hide <SwitchParameter>
    Get list of updates and hide/unhide approved updates.

-Download <SwitchParameter>
    Get list of updates and download approved updates, but do not install it.

-ForceDownload <SwitchParameter>
    Forces the download of updates that are already installed or that cannot be installed. Works only with -Download.

-Install <SwitchParameter>
    Get list of updates and install approved updates.

-ForceInstall <SwitchParameter>
    A forced installation is an installation in which an update is installed even if the metadata indicates that the update is already installed. Before you use ForceInstall to force an installation, determine whether the update is installed and available. If an update is not installed, a forced installation fails. Works only with -Install.

-AutoReboot <SwitchParameter>
    Do not ask for reboot if it needed.

-IgnoreReboot <SwitchParameter>
    Do not ask for reboot if it needed, but do not reboot automaticaly.

-ScheduleReboot <DateTime>
    Specify time when system will be rebooted.

-ServiceID <string>
    Use specific Service Manager if it's available.

    Examples Of ServiceID: \r\n \r\n -- Windows Update 9482f4b4-e343-43b6-b170-9a65bc822c77 \r\n -- Microsoft Update 7971f918-a847-4430-9279-4a52d1efe18d \r\n -- Windows Store 117cab2d-82b1-4b5a-a08c-4d62dbee7782 \r\n -- Windows Server Update Service 3da21691-e39d-4da6-8a4b-b43877bcb1b7

-WindowsUpdate <SwitchParameter>
    Use Microsoft Update Service Manager - '7971f918-a847-4430-9279-4a52d1efe18d'

-MicrosoftUpdate <SwitchParameter>
    Use Windows Update Service Manager - '9482f4b4-e343-43b6-b170-9a65bc822c77'

-Criteria <string>
    Pre search criteria - native for WUAPI. Set own string that specifies the search criteria.
    https://docs.microsoft.com/pl-pl/windows/desktop/api/wuapi/nf-wuapi-iupdatesearcher-search

-UpdateType <string>
    Pre search criteria - native for WUAPI. Finds updates with a specific type, such as 'Driver' and 'Software'. Default value contains all updates.

-DeploymentAction <string>
    Pre search criteria - native for WUAPI. Finds updates that are deployed for a specific action, such as an installation or uninstallation that the administrator of a server specifies. "DeploymentAction='Installation'" finds updates that are deployed for installation on a destination computer. "DeploymentAction='Uninstallation'" depends on the other query criteria.

    "DeploymentAction='Uninstallation'" finds updates that are deployed for uninstallation on a destination computer. "DeploymentAction='Uninstallation'" depends on the other query criteria.

    If this criterion is not explicitly specified, each group of criteria that is joined to an AND operator implies "DeploymentAction='Installation'".

-IsAssigned <SwitchParameter>
    Pre search criteria - native for WUAPI. Finds updates that are intended for deployment by Automatic Updates. "IsAssigned=1" finds updates that are intended for deployment by Automatic Updates, which depends on the other query criteria.At most, one assigned Windows-based driver update is returned for each local device on a destination computer.

    "IsAssigned=0" finds updates that are not intended to be deployed by Automatic Updates.

-IsPresent <SwitchParameter>
    Pre search criteria - native for WUAPI. When set to 1, finds updates that are present on a computer.

    "IsPresent=1" finds updates that are present on a destination computer.If the update is valid for one or more products, the update is considered present if it is installed for one or more of the products.

    "IsPresent=0" finds updates that are not installed for any product on a destination computer.

-BrowseOnly <SwitchParameter>
    Pre search criteria - native for WUAPI. "BrowseOnly=1" finds updates that are considered optional. "BrowseOnly=0" finds updates that are not considered optional.

-AutoSelectOnWebSites <SwitchParameter>
    Pre search criteria - native for WUAPI. Finds updates where the AutoSelectOnWebSites property has the specified value.

    "AutoSelectOnWebSites=1" finds updates that are flagged to be automatically selected by Windows Update.

    "AutoSelectOnWebSites=0" finds updates that are not flagged for Automatic Updates.

-UpdateID <string[]>
    Pre search criteria - native for WUAPI. Finds updates with a specific UUID (or sets of UUIDs), such as '12345678-9abc-def0-1234-56789abcdef0'.

-NotUpdateID <string[]>
    Pre search criteria - native for WUAPI. Finds updates without a specific UUID (or sets of UUIDs), such as '12345678-9abc-def0-1234-56789abcdef0'.

-RevisionNumber <int>
    Pre search criteria - native for WUAPI. Finds updates with a specific RevisionNumber, such as '100'. This criterion must be combined with the UpdateID param.

-CategoryIDs <string[]>
    Pre search criteria - native for WUAPI. Finds updates that belong to a specified category (or sets of UUIDs), such as '0fa1201d-4330-4fa8-8ae9-b877473b6441'.

-IsInstalled <SwitchParameter>
    Pre search criteria - native for WUAPI. Finds updates that are installed on the destination computer.

-IsHidden <SwitchParameter>
    Pre search criteria - native for WUAPI. Finds updates that are marked as hidden on the destination computer. Default search criteria is only not hidden upadates.

-WithHidden <SwitchParameter>
    Pre search criteria - native for WUAPI. Finds updates that are both hidden and not on the destination computer. Overwrite IsHidden param. Default search criteria is only not hidden upadates.

-ShowPreSearchCriteria <SwitchParameter>
    Show choosen search criteria. Only works for pre search criteria.

-RootCategories <string[]>
    Post search criteria. Finds updates that contain a specified root category name 'Critical Updates', 'Definition Updates', 'Drivers', 'Feature Packs', 'Security Updates', 'Service Packs', 'Tools', 'Update Rollups', 'Updates', 'Upgrades', 'Microsoft'.

-Category <string[]>
    Post search criteria. Finds updates that contain a specified category name (or sets of categories name), such as 'Updates', 'Security Updates', 'Critical Updates', etc...

-KBArticleID <string[]>
    Post search criteria. Finds updates that contain a KBArticleID (or sets of KBArticleIDs), such as 'KB982861'.

-Title <string>
    Post search criteria. Finds updates that match part of title (case sensitive), such as '.NET Framework 4'.

-Severity <string[]>
    Post search criteria. Finds updates that match part of severity, such as 'Important', 'Critical', 'Moderate', etc...

-NotCategory <string[]>
    Post search criteria. Finds updates that not contain a specified category name (or sets of categories name), such as 'Updates', 'Security Updates', 'Critical Updates', etc...

-NotKBArticleID <string[]>
    Post search criteria. Finds updates that not contain a KBArticleID (or sets of KBArticleIDs), such as 'KB982861'.

-NotTitle <string>
    Post search criteria. Finds updates that not match part of title (case sensitive).

-NotSeverity <string[]>
    Post search criteria. Finds updates that not match part of severity.

-IgnoreUserInput <SwitchParameter>
    Post search criteria. Finds updates that the installation or uninstallation of an update can't prompt for user input.

-Silent <SwitchParameter>
    Post search criteria. Finds updates that the installation or uninstallation of an update can't prompt for user input.

    This is an alias of the IgnoreUserInput parameter.

-IgnoreRebootRequired <SwitchParameter>
    Post search criteria. Finds updates that specifies the restart behavior that not occurs when you install or uninstall the update.

-AutoSelectOnly <SwitchParameter>
    Install only the updates that have status AutoSelectOnWebsites on true.

-MaxSize <long>
    Post search criteria. Finds updates that have MaxDownloadSize less or equal. Size is in Bytes.

-MinSize <long>
    Post search criteria. Finds updates that have MaxDownloadSize greater or equal. Size is in Bytes.

-Debuger <SwitchParameter>
    Debuger return original exceptions. For additional debug information use $DebugPreference = "Continue"

<CommonParameters>
    This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
```

{% endcode %}


# Misc

Miscellaneous PowerShell scripts that can be useful for troubleshooting and other maintenance tasks.


# Reset Local Group Policy

PowerShell script to silently backup and reset existing local group policy objects.

## Overview

This script creates a backup of the files stored in `C:\Windows\System32\GroupPolicy` and `C:\Windows\System32\GroupPolicyUsers`. After the backup is created, the script will delete the existing files to reset all locally set Group Policy Objects to "Not Configured".

By default, backups are stored in `C:\Backups\Group Policy`.&#x20;

**To restore a backup:**&#x20;

1. Delete contents of `C:\Windows\System32\GroupPolicy`, if it exists.
2. Delete contents of `C:\Windows\System32\GroupPolicyUsers`, if it exists.
3. Copy the contents of the associated backup folder to `C:\Windows\System32`.
4. Run `gpupdate /force` from an administrative terminal.

**Prerequisites:** This script has no prerequisites.&#x20;

***

## Script

{% hint style="info" %}
**Note:** This script has no effect on Group Policy Objects applied from Active Directory.
{% endhint %}

{% @github-files/github-code-block url="<https://github.com/wise-io/scripts/blob/main/scripts/ResetLocalPolicies.ps1>" %}

## Examples

```powershell
.\ResetLocalPolicies.ps1
```

This example creates a backup of the existing local group policy files (if any) and resets them back to "Not Configured".

***

## Parameters

This script has no parameters.


