Expand-NinjaOneZip.ps1
19 Sep 2025Description
Purpose
Extracts the contents of a NinjaOne Zip file to a specified destination folder.
Detailed Description
The Expand-NinjaOneZip function extracts the contents of a NinjaOne Zip file to a specified destination folder.
Usage
Example 1
Expand-NinjaOneZip -ZipFile "C:\Temp\NinjaOne.zip" -Destination "C:\Temp\Extracted"
This example extracts the contents of the “NinjaOne.zip” file located in “C:\Temp” to the “C:\Temp\Extracted” folder.
Notes
No additional notes.
Script
function Expand-NinjaOneZip {
<#
.SYNOPSIS
Extracts the contents of a NinjaOne Zip file to a specified destination folder.
.DESCRIPTION
The Expand-NinjaOneZip function extracts the contents of a NinjaOne Zip file to a specified destination folder.
.PARAMETER ZipFile
Specifies the path to the NinjaOne Zip file to extract.
.PARAMETER Destination
Specifies the path to the destination folder where the contents of the Zip file will be extracted.
.EXAMPLE
Expand-NinjaOneZip -ZipFile "C:\Temp\NinjaOne.zip" -Destination "C:\Temp\Extracted"
This example extracts the contents of the "NinjaOne.zip" file located in "C:\Temp" to the "C:\Temp\Extracted" folder.
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[ValidateScript({ Test-Path -Path $_ -PathType Leaf })]
[string]$ZipFile,
[Parameter(Mandatory = $true)]
[ValidateScript({ Test-Path -Path $_ -PathType Container })]
[string]$Destination
)
# Import the Microsoft.PowerShell.Archive module
Import-Module -Name Microsoft.PowerShell.Archive
try {
# Unzip the NinjaOne Zip file
Expand-Archive -Path $ZipFile -DestinationPath $Destination -ErrorAction Stop
}
catch {
Write-Error "Failed to unzip file: $_"
}
}
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.